gui-native-win-opengl initializes an OpenGL 2D rendering layer for a Win32 window via wgl. It selects a compatible pixel format using a standard PIXELFORMATDESCRIPTOR, creates a context with wglCreateContext, and verifies it with wglMakeCurrent.
This module is part of the native Windows GUI backend and is not intended for direct use in application code. OpenGL layer selection is controlled by the GUI.createWindow options object.
opengl := import('gui-native-win-opengl')
{ initOpenGL2DLayer: initOpenGL2DLayer } := import('gui-native-win-opengl')
| Constant | Value | Description |
|---|---|---|
PFD_DRAW_TO_WINDOW |
4 | Pixel format flag: render to window DC |
PFD_SUPPORT_OPENGL |
32 | Pixel format flag: support OpenGL |
PFD_DOUBLEBUFFER |
1 | Pixel format flag: double-buffered |
Attempts to initialize an OpenGL context on window. The sequence is:
- Acquire the window DC with
GetDC. - Build a 40-byte
PIXELFORMATDESCRIPTORrequesting 32-bit RGBA with 24-bit depth and 8-bit stencil, double-buffered, drawn to a window. - Select a pixel format with
ChoosePixelFormat/SetPixelFormat. - Create the context with
wglCreateContextand verify it withwglMakeCurrent. - Release the resources and return the context handle.
Returns { type: :ok, context, pixelFormat, makeCurrentResult } on success, or { type: :error, error: string, ... } on failure.
result := initOpenGL2DLayer(window)
if result.type = :ok {
true -> {
window.openglContext <- result.context
window.openglPixelFormat <- result.pixelFormat
}
_ -> printf('OpenGL init failed: {{0}}', result.error)
}
Note: The context is released (wglMakeCurrent(0,0)) immediately after creation. Callers are responsible for making it current before issuing draw calls.