Skip to content

GL \ Initialization

Luca Piccioni edited this page Apr 13, 2017 · 7 revisions

When the WGL_ARB_create_context extension is implemented, it is possible to create an OpenGL context specifying attributes. But how we can know whether WGL_ARB_create_context is supported without creating a temporary context? We can't.

When Gl is accessed, its static constructor will create a temporary OpenGL context to query the available extensions, and collect and cache all information about the default implementation. This information can be accessed via Gl.CurrentVersion and Gl.CurrentExtensions properties.

To make the OpenGL.Net initialization deterministic, you can execute the static method Gl.Initialize(), forcing the static constructor execution. This is particularly useful when you manually manage the OpenGL context creation, instead of using the DeviceContext abstraction.

Clone this wiki locally