FLTK 1.4.4

Loading...
Searching...
No Matches
gl.h File Reference

This file defines wrapper functions for OpenGL in FLTK. More...

`#include "Enumerations.H"`
`#include <GL/gl.h>`

Go to the source code of this file.

## Functions
void | gl_color (Fl_Color i)
| Sets the curent OpenGL color to an FLTK color.
void | gl_color (int c)
| back compatibility
int | gl_descent ()
| Returns the current font's descent.
void | gl_draw (const char *)
| Draws a nul-terminated string in the current font at the current position.
void | gl_draw (const char *, float x, float y)
| Draws a nul-terminated string in the current font at the given position.
void | gl_draw (const char *, int n)
| Draws an array of n characters of the string in the current font at the current position.
void | gl_draw (const char *, int n, float x, float y)
| Draws n characters of the string in the current font at the given position.
void | gl_draw (const char *, int n, int x, int y)
| Draws n characters of the string in the current font at the given position.
void | gl_draw (const char *, int x, int y)
| Draws a nul-terminated string in the current font at the given position.
void | gl_draw (const char *, int x, int y, int w, int h, Fl_Align)
| Draws a string formatted into a box, with newlines and tabs expanded, other control characters changed to ^X.
void | gl_draw_image (const uchar *, int x, int y, int w, int h, int d=3, int ld=0)
void | gl_finish ()
| Releases an OpenGL context.
void | gl_font (int fontid, int size)
| Sets the current OpenGL font to the same font as calling fl_font().
int | gl_height ()
| Returns the current font's height.
void | gl_measure (const char *, int &x, int &y)
| Measure how wide and tall the string will be when drawn by the gl_draw() function.
void | gl_rect (int x, int y, int w, int h)
| Outlines the given rectangle with the current color.
void | gl_rectf (int x, int y, int w, int h)
| Fills the given rectangle with the current color.
void | gl_start ()
| Creates an OpenGL context.
int | gl_texture_pile_height ()
| Returns the current maximum height of the pile of pre-computed string textures.
void | gl_texture_pile_height (int max)
| Changes the maximum height of the pile of pre-computed string textures.
void | gl_texture_reset ()
| To call after GL operations that may invalidate textures used to draw text in GL scenes (e.g., switch between FL_DOUBLE / FL_SINGLE modes).
double | gl_width (const char *)
| Returns the width of the string in the current fnt.
double | gl_width (const char *, int n)
| Returns the width of n characters of the string in the current font.
double | gl_width (uchar)
| Returns the width of the character in the current font.

## Detailed Description

This file defines wrapper functions for OpenGL in FLTK.

To use OpenGL from within an FLTK application you MUST use gl_visual() to select the default visual before doing show() on any windows. Mesa will crash if you try to use a visual not returned by glxChooseVisual.

Historically, this did not always work well with Fl_Double_Window's! It can try to draw into the front buffer. Depending on the system this might either crash or do nothing (when pixmaps are being used as back buffer and GL is being done by hardware), work correctly (when GL is done with software, such as Mesa), or draw into the front buffer and be erased when the buffers are swapped (when double buffer hardware is being used)

## Function Documentation

## ◆ gl_color()

void gl_color | ( | Fl_Color | i | ) |

Sets the curent OpenGL color to an FLTK color.

For color-index modes it will use fl_xpixel(c), which is only right if the window uses the default colormap!

## ◆ gl_draw() [1/7]

void gl_draw | ( | const char * | str | ) |

Draws a nul-terminated string in the current font at the current position.

See also
  gl_texture_pile_height(int)

## ◆ gl_draw() [2/7]

void gl_draw | ( | const char * | str,
|  | float | x,
|  | float | y )

Draws a nul-terminated string in the current font at the given position.

See also
  gl_texture_pile_height(int)

## ◆ gl_draw() [3/7]

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

Draws an array of n characters of the string in the current font at the current position.

See also
  gl_texture_pile_height(int)

## ◆ gl_draw() [4/7]

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

Draws n characters of the string in the current font at the given position.

See also
  gl_texture_pile_height(int)

## ◆ gl_draw() [5/7]

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

Draws n characters of the string in the current font at the given position.

See also
  gl_texture_pile_height(int)

## ◆ gl_draw() [6/7]

void gl_draw | ( | const char * | str,
|  | int | x,
|  | int | y )

Draws a nul-terminated string in the current font at the given position.

See also
  gl_texture_pile_height(int)

## ◆ gl_draw() [7/7]

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

Draws 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().

## ◆ gl_font()

void gl_font | ( | int | fontid,
|  | int | size )

Sets the current OpenGL font to the same font as calling fl_font().

See also
  Fl::draw_GL_text_with_textures(int val)

## ◆ gl_rect()

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

Outlines the given rectangle with the current color.

If Fl_Gl_Window::ortho() has been called, then the rectangle will exactly fill the given pixel rectangle.

## ◆ gl_rectf()

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

Fills the given rectangle with the current color.

See also
  gl_rect(int x, int y, int w, int h)

## ◆ gl_texture_pile_height() [1/2]

int gl_texture_pile_height | ( | void |  | ) |

Returns the current maximum height of the pile of pre-computed string textures.

The default value is 100

See also
  Fl::draw_GL_text_with_textures(int)

## ◆ gl_texture_pile_height() [2/2]

void gl_texture_pile_height | ( | int | max | ) |

Changes the maximum height of the pile of pre-computed string textures.

Strings that are often re-displayed can be processed much faster if this pile is set high enough to hold all of them.

Parameters

  max | Maximum height of the texture pile

See also
  Fl::draw_GL_text_with_textures(int)