wxGLContext(3)
π wxGLContext
okay bestie, so this is the Erlang module definition for wxGLContext β welcome to the OpenGL state machine corner of the universe β¨
π NAME
An instance of a wxGLContext is literally the state of an OpenGL state machine, and also the whole connection between OpenGL and your system. That's the vibe. π¦
π DESCRIPTION
So the OpenGL state is everything you can set with the OpenGL API β no cap: colors, rendering variables, buffer data ids, texture objects, all of it. π
And here's the slay part: you can have multiple rendering contexts share buffer data and textures. That's super useful when your app is using multiple threads to update data into the memory of the graphics card. π
Now, whether you use one single rendering context bound to multiple output windows, or give each window its own bound context β that's a developer decision, bestie. It's a choose-your-own-adventure. But keep this in mind: GPU makers may set different pointers to the same OGL function for different contexts π. So the way those pointers are retrieved from the OGL driver should be used again for each new context. Don't skip that.
Also, binding (making current) a rendering context with another instance of a wxGLCanvas only works if both wxGLCanvas instances were created with the same attributes. Same attributes or it's not giving. π
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. But ngl, it's advised to use only the core profile, because the compatibility profile may run a bit slower. π
The 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. periodt. β¨
The best way of knowing if your OpenGL environment supports a specific type of context? Create a wxGLContext instance and check isOK/1. If it returns false, just delete that instance and make a new one with other attributes. Simple as that, no drama. π
wxHAS_OPENGL_ES is defined on platforms that only have this implementation available (e.g. the iPhone) and don't support the full specification.
See: wxGLCanvas
wxWidgets docs: wxGLContext
π¦ DATA TYPES
wxGLContext() :: wx:wx_object().
β¨ FUNCTIONS β¨
destroy(This :: wxGLContext()) -> ok.β Destroys the object. bye bestie ππisOK(This) -> boolean() when This :: wxGLContext().β Checks if the underlying OpenGL rendering context was correctly created by the system with the requested attributes.
If this function returnsfalsethen thewxGLContextobject is useless and should be deleted and recreated with different attributes. π
Since: 3.1.0
new(Win, [Option]) -> wxGLContext()whenWin :: wxGLCanvas:wxGLCanvas(),Option :: {other, wxGLContext()}.β Constructor. πsetCurrent(This, Win) -> boolean()whenThis :: wxGLContext(),Win :: wxGLCanvas:wxGLCanvas().β Makes the OpenGL state that is represented by this rendering context current with thewxGLCanvaswin.
Note: win can be a differentwxGLCanvaswindow than the one that was passed to the constructor of this rendering context. If RC is an object of typewxGLContext, the statements
"RC.SetCurrent(win);"
and
"win.SetCurrent(RC);"
are equivalent, see wxGLCanvas:setCurrent/2. π
that's the whole page, hope it ate π
mwah, xoxo β brought to you by Ericsson AB, wx 2.6, and the Erlang module definition energy πΈβ¨
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms