OpenGL Drawing Functions

FLTK provides some useful OpenGL drawing functions. They can be freely mixed with any OpenGL calls, and are defined by including <FL/gl.H> (which you should include instead of the OpenGL header <GL/gl.h>).

void gl_color(Fl_Color)

Set the current color to a FLTK color. For color-index modes it will use fl_xpixel(c), which is only right if this window uses the default colormap!

void gl_rect(int x, int y, int w, int h)
void gl_rectf(int x, int y, int w, int h)

Outline or fill a rectangle with the current color. If Fl_Gl_Window::ortho() has been called, then the rectangle will exactly fill the pixel rectangle passed.

void gl_font(Fl_Font fontid, int size)

Set the current OpenGL font to the same font you get by calling fl_font().

int gl_height()
int gl_descent()
float gl_width(const char *)
float gl_width(const char *, int n)
float gl_width(uchar)

Return information about the current OpenGL font.

void gl_draw(const char *)
void gl_draw(const char *, int n)

Draw a nul-terminated string or an array of n characters in the current OpenGL font at the current raster position.

void gl_draw(const char *, int x, int y)
void gl_draw(const char *, int n, int x, int y)
void gl_draw(const char *, float x, float y)
void gl_draw(const char *, int n, float x, float y)

Draw a nul-terminated string or an array of n characters in the current OpenGL font at the given position.

void gl_draw(const char *, int x, int y, int w, int h, Fl_Align)

Draw a string formatted into a box, with newlines and tabs expanded, other control characters changed to ^X, and aligned with the edges or center. Exactly the same output as fl_draw().