Skip to content

GL \ Initialization

pointcache edited this page Nov 28, 2018 · 7 revisions

OpenGL.Net initializes itself when Gl is accessed for the first time. The initialization process consists of creating a native window and an OpenGL context for introspecting versions, extensions and limits. This information can be accessed via Gl.CurrentVersion, Gl.CurrentExtensions and Gl.CurrentLimits properties, and they are relative to the compatible context created at initialization time.

Static initialization

To initialize OpenGL.Net explicitly, 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. Indeed, the static initialization of Gl will screw the OpenGL context current on the thread, and can be avoided by calling Gl.Initialize().

Skip initializations

By setting certain environment variables, OpenGL.Net can be configured to skip sub-systems initialization. This is useful in case some initialization procedure cause problems in a specific environment.

  • OPENGL_NET_GL_STATIC_INIT: set this environment variable to 'NO' (case sensitive) in order to skip GL static constructor initialization. You can execute GL initialization by calling explicitly Gl.Initialize(). This is useful in some debugger environment that has difficulties to debug static constructor code.
  • OPENGL_NET_INIT: set this environment variable to 'NO' (case sensitive) in order to skip GL initialization. The method Gl.Initialize() will do nothing, skipping the entire GL initialization procedure described above. This is useful to speed up initialization time, but you have to care about it explicitly in you application.
  • OPENGL_NET_EGL_STATIC_INIT: set this environment variable to 'NO' (case sensitive) in order to skip EGL static constructor initialization. You can execute EGL initialization by calling explicitly Egl.Initialize().
Clone this wiki locally