wxglcanvaswxglcanvas 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 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.
see also members
wxglcanvas::wxglcanvas
wxglcanvas::wxglcanvasvoid 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
wxglcanvas::getcontextwxglcontext* 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.
wxglcanvas::setcurrentvoid 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.
wxglcanvas::setcurrentvoid 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.
wxglcanvas::setcolourvoid setcolour(const char* colour) sets the current colour for this window, using the wxwidgets colour database to find a named colour.
wxglcanvas::swapbuffersvoid 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.
|