wxGLCanvas - Functions for wxGLCanvas class
Please see following description for synopsis
wxGLCanvas(3) Erlang Module Definition wxGLCanvas(3)
NAME
wxGLCanvas - Functions for wxGLCanvas class
DESCRIPTION
wxGLCanvas is a class for displaying OpenGL graphics. It is always used
in conjunction with wxGLContext as the context can only be made current
(i.e. active for the OpenGL commands) when it is associated to a
wxGLCanvas.
More precisely, you first need to create a wxGLCanvas window and then
create an instance of a wxGLContext that is initialized with this
wxGLCanvas and then later use either setCurrent/2 with the instance of
the wxGLContext or wxGLContext:setCurrent/2 with the instance of the
wxGLCanvas (which might be not the same as was used for the creation of
the context) to bind the OpenGL state that is represented by the ren-
dering context to the canvas, and then finally call swapBuffers/1 to
swap the buffers of the OpenGL canvas and thus show your current out-
put.
Please note that wxGLContext always uses physical pixels, even on the
platforms where wxWindow uses logical pixels, affected by the coordi-
nate scaling, on high DPI displays. Thus, if you want to set the OpenGL
view port to the size of entire window, you must multiply the result
returned by wxWindow:getClientSize/1 by wxWindow:getContentScaleFac-
tor/1 before passing it to glViewport(). Same considerations apply to
other OpenGL functions and other coordinates, notably those retrieved
from wxMouseEvent in the event handlers.
Notice that versions of wxWidgets previous to 2.9 used to implicitly
create a wxGLContext inside wxGLCanvas itself. This is still supported
in the current version but is deprecated now and will be removed in the
future, please update your code to create the rendering contexts
explicitly.
To set up the attributes for the canvas (number of bits for the depth
buffer, number of bits for the stencil buffer and so on) you pass them
in the constructor using a wxGLAttributes (not implemented in wx)
instance. You can still use the way before 3.1.0 (setting up the cor-
rect values of the attribList parameter) but it's discouraged.
Note: On those platforms which use a configure script (e.g. Linux and
macOS) OpenGL support is automatically enabled if the relative headers
and libraries are found. To switch it on under the other platforms
(e.g. Windows), you need to edit the setup.h file and set wxUSE_GLCAN-
VAS to 1 and then also pass USE_OPENGL=1 to the make utility. You may
also need to add opengl32.lib (and glu32.lib for old OpenGL versions)
to the list of the libraries your program is linked with.
See: wxGLContext, wxGLAttributes (not implemented in wx), wxGLContex-
tAttrs (not implemented in wx)
This class is derived (and can use functions) from: wxWindow
wxEvtHandler
wxWidgets docs: wxGLCanvas
DATA TYPES
wxGLCanvas() = wx:wx_object()
EXPORTS
new(Parent) -> wxGLCanvas()
Types:
Parent = wxWindow:wxWindow()
new(Parent, Options :: [Option]) -> wxGLCanvas()
Types:
Parent = wxWindow:wxWindow()
Option =
{id, integer()} |
{attribList, [integer()]} |
{pos, {X :: integer(), Y :: integer()}} |
{size, {W :: integer(), H :: integer()}} |
{style, integer()} |
{name, unicode:chardata()} |
{palette, wxPalette:wxPalette()}
This constructor is still available only for compatibility rea-
sons.
Please use the constructor with wxGLAttributes (not implemented
in wx) instead.
If attribList is not specified, wxGLAttributes::PlatformDe-
faults() (not implemented in wx) is used, plus some other
attributes (see below).
setCurrent(This, Context) -> boolean()
Types:
This = wxGLCanvas()
Context = wxGLContext:wxGLContext()
Makes the OpenGL state that is represented by the OpenGL render-
ing context context current, i.e.
it will be used by all subsequent OpenGL calls.
This is equivalent to wxGLContext:setCurrent/2 called with this
window as parameter.
Note: This function may only be called when the window is shown
on screen, in particular it can't usually be called from the
constructor as the window isn't yet shown at this moment.
Return: false if an error occurred.
swapBuffers(This) -> boolean()
Types:
This = wxGLCanvas()
Swaps the double-buffer of this window, making the back-buffer
the front-buffer and vice versa, so that the output of the pre-
vious OpenGL commands is displayed on the window.
Return: false if an error occurred.
destroy(This :: wxGLCanvas()) -> ok
Destroys the object.
wxWidgets team. wx 2.1.1 wxGLCanvas(3)