Contents Up Previous Next

wxGLCanvas

wxGLCanvas is a class for displaying OpenGL graphics. There are wrappers for OpenGL on Windows, and GTK+ and Motif.

To use this class, create a wxGLCanvas window, call wxGLCanvas::SetCurrent to direct normal OpenGL commands to the window, and then call wxGLCanvas::SwapBuffers to show the OpenGL buffer on the window.

To set up the attributes for the rendering context (number of bits for the depth buffer, number of bits for the stencil buffer and so on) you should set up the correct values of the attribList parameter. The values that should be set up and their meanings will be described below.

To switch wxGLCanvas support on under Windows, edit setup.h and set wxUSE_GLCANVAS to 1. You may also need to have to add opengl32.lib to the list of libraries your program is linked with. On Unix, pass --with-opengl to configure to compile using OpenGL or Mesa.

Derived from

wxWindow
wxEvtHandler
wxObject

Include files

<wx/glcanvas.h>

Window styles

There are no specific window styles for this class.

See also window styles overview.

Constants

The generic GL implementation doesn't support many of these options, such as stereo, auxiliary buffers, alpha channel, and accum buffer. Other implementations may support them.

WX_GL_RGBA Use true colour
WX_GL_BUFFER_SIZE Bits for buffer if not WX_GL_RGBA
WX_GL_LEVEL 0 for main buffer, >0 for overlay, <0 for underlay
WX_GL_DOUBLEBUFFER Use doublebuffer
WX_GL_STEREO Use stereoscopic display
WX_GL_AUX_BUFFERS Number of auxiliary buffers (not all implementation support this option)
WX_GL_MIN_RED Use red buffer with most bits (> MIN_RED bits)
WX_GL_MIN_GREEN Use green buffer with most bits (> MIN_GREEN bits)
WX_GL_MIN_BLUE Use blue buffer with most bits (> MIN_BLUE bits)
WX_GL_MIN_ALPHA Use alpha buffer with most bits (> MIN_ALPHA bits)
WX_GL_DEPTH_SIZE Bits for Z-buffer (0,16,32)
WX_GL_STENCIL_SIZE Bits for stencil buffer
WX_GL_MIN_ACCUM_RED Use red accum buffer with most bits (> MIN_ACCUM_RED bits)
WX_GL_MIN_ACCUM_GREEN Use green buffer with most bits (> MIN_ACCUM_GREEN bits)
WX_GL_MIN_ACCUM_BLUE Use blue buffer with most bits (> MIN_ACCUM_BLUE bits)
WX_GL_MIN_ACCUM_ALPHA Use blue buffer with most bits (> MIN_ACCUM_ALPHA bits)

See also

wxGLContext

Members

wxGLCanvas::wxGLCanvas
wxGLCanvas::GetContext
wxGLCanvas::SetCurrent
wxGLCanvas::SetColour
wxGLCanvas::SwapBuffers


wxGLCanvas::wxGLCanvas

void wxGLCanvas(wxWindow* parent, wxWindowID id = -1, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="GLCanvas", int* attribList = 0, const wxPalette& palette = wxNullPalette)

void wxGLCanvas(wxWindow* parent, wxGLCanvas* sharedCanvas = NULL, wxWindowID id = -1, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="GLCanvas", int* attribList = 0, const wxPalette& palette = wxNullPalette)

void wxGLCanvas(wxWindow* parent, wxGLContext* sharedContext = NULL, wxWindowID id = -1, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="GLCanvas", int* attribList = 0, const wxPalette& palette = wxNullPalette)

Constructor.

parent

sharedcontext

id

pos

size

style

name

attribList

attribList[index]= WX_GL_DEPTH_SIZE;
attribList[index+1]=32;
and so on.
palette


wxGLCanvas::GetContext

wxGLContext* GetContext()

Obtains the context that is associated with this canvas.


wxGLCanvas::SetCurrent

void SetCurrent()

Sets this canvas as the current recipient of OpenGL calls. Each canvas contains an OpenGL device context that has been created during the creation of this window. So this call sets the current device context as the target device context for OpenGL operations.

Note that this function may only be called after the window has been shown.


wxGLCanvas::SetColour

void SetColour(const char* colour)

Sets the current colour for this window, using the wxWidgets colour database to find a named colour.


wxGLCanvas::SwapBuffers

void SwapBuffers()

Displays the previous OpenGL commands on the window.