fltk.core.gl
FLTK OpenGL Library Bindings
This package provides low-level D bindings for the FLTK OpenGL library (libfltk_gl), which adds OpenGL rendering support to FLTK windows.
Features:
- OpenGL context creation and management
- Double buffering support
- GL context sharing between windows
- Overlay support (where available)
Memory Management:
- GL windows created with
fltk_gl_window_new()must be destroyed withfltk_gl_window_delete() - GL contexts are managed automatically by FLTK
Thread Safety:
- OpenGL contexts are thread-specific
- Use
make_current()before GL calls in each thread
Example:
import fltk.core.gl;
import fltk.core.enums : FltkMode;
void main() {
if (!hasGlSupport()) {
writeln("OpenGL not available");
return;
}
// Create GL window with double buffering and depth buffer
auto mode = FltkMode.DOUBLE | FltkMode.DEPTH;
auto win = fltk_gl_window_new(640, 480, "OpenGL Demo");
if (win !is null) {
fltk_gl_window_show(win);
// ... render loop ...
fltk_gl_window_delete(win);
}
}
License
Copyright
Types 5
Opaque handle for Fl_Gl_Window.
This is the primary type for OpenGL-capable windows in FLTK. It inherits from Fl_Window and provides OpenGL context management.
private void * ptrAlias for GL window handle
Opaque handle for GL context.
Represents an OpenGL rendering context. Usually managed internally by Fl_Gl_Window, but exposed for advanced context sharing scenarios.
private void * ptrAlias for GL context handle
GL window draw callback function type.
Called when the GL window needs to redraw its OpenGL content. The GL context is made current before the callback is invoked.
Parameters
win | The GL window |
userdata | User-provided data pointer |
Functions 25
bool isValid(FltkGlWindow window) @safe nothrow @nogcChecks if a GL window handle is valid (non-null).bool isValid(FltkGlContext context) @safe nothrow @nogcChecks if a GL context handle is valid (non-null).FltkGlWindow fltk_gl_window_new(int w, int h, const(char) * title)Creates a new OpenGL window with specified size.FltkGlWindow fltk_gl_window_new_xy(int x, int y, int w, int h, const(char) * title)Creates a new OpenGL window with position and size.void fltk_gl_window_make_current(FltkGlWindow win)Makes the OpenGL context current for this window.int fltk_gl_window_context_valid(FltkGlWindow win)Checks if the OpenGL context is valid for rendering.void fltk_gl_window_set_draw_callback(FltkGlWindow win, GlWindowDrawCallback callback, void * userdata)Sets the draw callback for a GL window.