wxGLContext(3erl)
πΈ NAME πΈ
wxGLContext - Functions for wxGLContext class. Okay bestie, this is the wxGLContext(3erl) Erlang Module Definition page, and it's literally all about the OpenGL state machine plus the connection between OpenGL and the system. π¦
β¨ DESCRIPTION β¨
An instance of a wxGLContext represents the state of an OpenGL state machine and the connection between OpenGL and the system. It's giving main character energy for your OGL setup. π
The OpenGL state includes everything that can be set with the OpenGL API: colors, rendering variables, buffer data ids, texture objects, etc. Yes, she ate that whole list. It is possible to have multiple rendering contexts share buffer data and textures. This feature is specially useful when the application use multiple threads for updating data into the memory of the graphics card. That's the documented use case, and it's lowkey iconic. π₯ periodt.
Whether one only rendering context is used with or bound to multiple output windows or if each window has its own bound context is a developer decision. Main character choice, no cap. It is important to take into account that GPU makers may set different pointers to the same OGL function for different contexts. The way that these pointers are retrieved from the OGL driver should be used again for each new context. Don't skip that step, fr fr. π«Ά
Binding (making current) a rendering context with another instance of a wxGLCanvas however works only if the both wxGLCanvas instances were created with the same attributes. That's highkey a hard requirement, bestie. β οΈ
OpenGL version 3 introduced a new type of specification profile, the modern core profile. The old compatibility profile maintains all legacy features. Since wxWidgets 3.1.0 you can choose the type of context and even ask for a specified OGL version number. However, its advised to use only core profile as the compatibility profile may run a bit slower. So core profile is the recommended slay, but that's the docs talking. π
OpenGL core profile specification defines several flags at context creation that determine not only the type of context but also some features. Some of these flags can be set in the list of attributes used at wxGLCanvas ctor. But since wxWidgets 3.1.0 it is strongly encouraged to use the new mechanism: setting the context attributes with a wxGLContextAttrs (not implemented in wx) object and the canvas attributes with a wxGLAttributes (not implemented in wx) object. That's the new mechanism, bestie β note the not implemented in wx on both of those. π
The best way of knowing if your OpenGL environment supports a specific type of context is creating a wxGLContext instance and checking isOK/1. If it returns false, then simply delete that instance and create a new one with other attributes. Easy reset, no drama β obsessed with the simplicity. β
wxHAS_OPENGL_ES is defined on platforms that only have this implementation available (e.g. the iPhone) and don't support the full specification. Important little platform flag, iykyk. π
See: wxGLCanvas, wxGLContextAttrs (not implemented in wx), wxGLAttributes (not implemented in wx)
wxWidgets docs: wxGLContext
π§ DATA TYPES π§
wxGLContext() = wx:wx_object()
That's the only data type on this page, and she's iconic. π
π₯ EXPORTS π₯
new(Win) -> wxGLContext()
Types:
Win = wxGLCanvas:wxGLCanvas()
new(Win, Options :: [Option]) -> wxGLContext()
Types:
Win = wxGLCanvas:wxGLCanvas()Option = {other, wxGLContext()}
Constructor. That's the whole note, bestie β constructor. β¨
setCurrent(This, Win) -> boolean()
Types:
This = wxGLContext()Win = wxGLCanvas:wxGLCanvas()
Makes the OpenGL state that is represented by this rendering context current with the wxGLCanvas win. Current with the win, that's the move. π
Note:wincan be a differentwxGLCanvaswindow than the one that was passed to the constructor of this rendering context. IfRCis an object of typewxGLContext, the statementsRC.SetCurrent(win);andwin.SetCurrent(RC);are equivalent, seewxGLCanvas:setCurrent/2.
isOK(This) -> boolean()
Types:
This = wxGLContext()
Checks if the underlying OpenGL rendering context was correctly created by the system with the requested attributes. It's the vibe check for your context. β
If this function returns false then the wxGLContext object is useless and should be deleted and recreated with different attributes. Not me being dramatic β that's literally what the docs say. π
Since: 3.1.0
destroy(This :: wxGLContext()) -> ok
Destroys the object. Clean up your fave, bestie. π§Ή
Source/author: wxWidgets team. Β· version: wx 2.2.2.1 Β· footer/date marker: wxGLContext(3erl). Byeee, go make that OpenGL state machine current πβ¨
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms