fltk.gl.window
FLTK OpenGL Window Class
This module provides the GlWindow class that wraps FLTK's Fl_Gl_Window. GlWindow provides OpenGL rendering capabilities with RAII resource management.
The GlWindow class provides:
- RAII-based resource management
- OpenGL context activation and management
- Double buffering support
- Scoped context activation for safe GL calls
License
BSD-3-ClauseCopyright
Copyright © 2025 DDN (D Developer Network) Members
Types 2
OpenGL-capable window.
GlWindow provides a window with an OpenGL rendering context. Use makeCurrent() before making GL calls and swapBuffers() after rendering to display the result.
The window supports a customizable draw callback that is invoked when the window needs to redraw its OpenGL content. Set the onDraw property to provide your rendering code.
Example:
auto win = new GlWindow(640, 480, "OpenGL Demo");
win.mode = Mode.DOUBLE | Mode.DEPTH;
win.onDraw = () {
// OpenGL rendering code here
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// ... draw scene ...
};
win.show();
run();FltkGlWindow _handleThe underlying GL window handlestring _titleStored title for referencevoid delegate() nothrow @nogc _onDrawDraw callback delegatevoid drawTrampoline(FltkGlWindow win, void * userdata) nothrow @nogcStatic trampoline function to bridge C callback to D delegate.void delegate() nothrow @nogc onDraw()Gets the draw callback delegate.void onDraw(void delegate() nothrow @nogc dg)Sets the draw callback delegate.this(int width, int height, string title = null)Creates a new OpenGL window with the specified size.this(int x, int y, int width, int height, string title = null)Creates a new OpenGL window with position and size.~thisDestroys the GL window and releases resources.Scoped OpenGL context activation.
This struct provides RAII-style context management. When created, it makes the associated window's GL context current. This ensures GL calls are made in the correct context.
Example:
{
auto ctx = window.activate();
// All GL calls here use window's context
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
// ...
glEnd();
window.swapBuffers();
}GlWindow _window