wxGLContext(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’… 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 returns false then the wxGLContext object is useless and should be deleted and recreated with different attributes. 😭

Since: 3.1.0

  • new(Win, [Option]) -> wxGLContext() when Win :: wxGLCanvas:wxGLCanvas(), Option :: {other, wxGLContext()}. β€” Constructor. πŸŽ€
  • setCurrent(This, Win) -> boolean() when This :: wxGLContext(), Win :: wxGLCanvas:wxGLCanvas(). β€” Makes the OpenGL state that is represented by this rendering context current with the wxGLCanvas win.
Note: win can be a different wxGLCanvas window than the one that was passed to the constructor of this rendering context. If RC is an object of type wxGLContext, 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