ddn.lib.fltk.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 ddn.lib.fltk.gl;
import ddn.lib.fltk.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) extern(C) nothrow @nogcCreates a new OpenGL window with specified size.FltkGlWindow fltk_gl_window_new_xy(int x, int y, int w, int h, const(char) * title) extern(C) nothrow @nogcCreates a new OpenGL window with position and size.int fltk_gl_window_shown(FltkGlWindow win) extern(C) nothrow @nogcChecks if the window is currently shown.void fltk_gl_window_make_current(FltkGlWindow win) extern(C) nothrow @nogcMakes the OpenGL context current for this window.void fltk_gl_window_swap_buffers(FltkGlWindow win) extern(C) nothrow @nogcSwaps the front and back buffers.int fltk_gl_window_valid(FltkGlWindow win) extern(C) nothrow @nogcChecks if the OpenGL context is valid.int fltk_gl_window_context_valid(FltkGlWindow win) extern(C) nothrow @nogcChecks if the OpenGL context is valid for rendering.void fltk_gl_window_invalidate(FltkGlWindow win) extern(C) nothrow @nogcMarks the window as needing a redraw.void fltk_gl_window_redraw(FltkGlWindow win) extern(C) nothrow @nogcRequests a redraw of the window.void fltk_gl_window_set_mode(FltkGlWindow win, int mode) extern(C) nothrow @nogcSets the OpenGL mode flags.WindowPtr fltk_gl_window_as_window(FltkGlWindow win) extern(C) nothrow @nogcCasts a GL window to a base window handle.WidgetPtr fltk_gl_window_as_widget(FltkGlWindow win) extern(C) nothrow @nogcCasts a GL window to a widget handle.void fltk_gl_window_set_draw_callback(FltkGlWindow win, GlWindowDrawCallback callback, void * userdata) extern(C) nothrow @nogcSets the draw callback for a GL window.