$szTitle = "wxglcanvas"; include "./_header.inc"; ?>
wxglcanvas is a class for displaying opengl graphics.
there are two ways to use this class:
for the older (before wx 2.7.x) and simpler method, create a wxglcanvas window using one of the three constructors that implicitly create a rendering context, call wxglcanvas::setcurrent to direct normal opengl commands to the window, and then call wxglcanvas::swapbuffers to show the opengl buffer on the window.
for the newer (wx 2.7.x+) method, create a wxglcanvas window using the constructor that does not create an implicit rendering context, create an explicit instance of a wxglcontext that is initialized with the wxglcanvas yourself, then use either wxglcanvas::setcurrent with the instance of the wxglcontext or wxglcontext::setcurrent with the instance of the wxglcanvas to bind the opengl state that is represented by the rendering context to the canvas, and then call wxglcanvas::swapbuffers to swap the buffers of the opengl canvas and thus show your current output.
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 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 on 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
members
wxglcanvas::wxglcanvas
wxglcanvas::getcontext
wxglcanvas::setcurrent
wxglcanvas::setcurrent
wxglcanvas::setcolour
wxglcanvas::swapbuffers
void wxglcanvas(wxwindow* parent, wxwindowid id = -1, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style=0, const wxstring& name="glcanvas", int* attriblist = 0, const wxpalette& palette = wxnullpalette)
void wxglcanvas(wxwindow* parent, wxglcontext* sharedcontext, wxwindowid id = -1, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style=0, const wxstring& name="glcanvas", int* attriblist = 0, const wxpalette& palette = wxnullpalette)
void wxglcanvas(wxwindow* parent, wxglcanvas* sharedcanvas, wxwindowid id = -1, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style=0, const wxstring& name="glcanvas", int* attriblist = 0, const wxpalette& palette = wxnullpalette)
void wxglcanvas(wxwindow* parent, wxwindowid id = wxid_any, int* attriblist = 0, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style=0, const wxstring& name="glcanvas", const wxpalette& palette = wxnullpalette)
constructors. the first three constructors implicitly create an instance of wxglcontext. the fourth constructur is identical to the first, except for the fact that it does not create such an implicit rendering context, which means that you have to create an explicit instance of wxglcontext yourself (highly recommended for future compatibility with wxwidgets and the flexibility of your own program!).
note that if you used one of the first three constructors, wxglcanvas::getcontext returns the pointer to the implicitly created instance, and the wxglcanvas::setcurrent method without the parameter should be used. if however you used the fourth constructor, wxglcanvas::getcontext always returns null and the wxglcanvas::setcurrent method with the parameter must be used!
parent
sharedcontext
id
pos
size
style
name
attriblist
attriblist[index]= wx_gl_depth_size; attriblist[index+1]=32; and so on.palette
wxglcontext* getcontext()
obtains the context that is associated with this canvas if one was implicitly created (by use of one of the first three constructors). always returns null if the canvas was constructed with the fourth constructor.
void setcurrent()
if this canvas was created with one of the first three constructors, a call to this method makes the implicit rendering context of this canvas current with this canvas, so that subsequent opengl calls modify the opengl state of the implicit rendering context.
if this canvas was created with the fourth constructor, this method should not be called (use the setcurrent method below with the parameter instead)!
note that this function may only be called after the window has been shown.
void setcurrent( const wxglcontext rc )
if this canvas was created with one of the first three constructors, this method should not be called (use the setcurrent above without the parameter instead)!
if this canvas was created with the fourth constructor, a call to this method makes the opengl state that is represented by the opengl rendering context rc current with this canvas, and if win is an object of type wxglcanvas, the statements win.setcurrent(rc); and rc.setcurrent(win); are equivalent, see wxglcontext::setcurrent.
note that this function may only be called after the window has been shown.
void setcolour(const char* colour)
sets the current colour for this window, using the wxwidgets colour database to find a named colour.
void swapbuffers()
swaps the double-buffer of this window, making the back-buffer the front-buffer and vice versa, so that the output of the previous opengl commands is displayed on the window.
include "./_footer.inc"; ?>