Jump to content
  • Advertisement
Sign in to follow this  
Last Attacker

OpenGL wxCanvas

This topic is 4801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I'm having trouble looking for help/tutorials on the web for using OpenGL in wxWidgets. Does anyone know of where I can find a good tutorial on wxCanvas in wxWidgets? Thanks! [Edited by - Last Attacker on May 25, 2005 7:32:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
There are always the OpenGL canvas samples in the wx directory where you extracted it.

Share this post


Link to post
Share on other sites
Yeah I know, but I need a tutorial that can explain to me how to implement it. For instance, I need to use a whole window and sometimes, just a small panel in a window for an OpenGL viewport.

Share this post


Link to post
Share on other sites
Quote:
Original post by Last Attacker
Yeah I know, but I need a tutorial that can explain to me how to implement it. For instance, I need to use a whole window and sometimes, just a small panel in a window for an OpenGL viewport.


First of all you need to create your own GLCanvas class inherited from the wxGlCanvas class like this:


class MyGLCanvas: public wxGLCanvas
{

public:

MyGLCanvas(wxWindow *parent, const wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "TestGLCanvas", int* attribList = 0);

~MyGLCanvas(void);

void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnEraseBackground(wxEraseEvent& event);

void OnMouseLeftDown(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event);
void OnMouseLeftUp(wxMouseEvent& event);

void OnMouseRightDown(wxMouseEvent& event);
void OnMouseRightUp(wxMouseEvent& event);

void OnMouseWheel(wxMouseEvent& event);

private:

DECLARE_EVENT_TABLE()
};



You can just inherit the constructor from the base class and implement the rest of the functions. To create one on your form just do:

	glCanvas = new MyGLCanvas(this, -1, wxPoint(188, 0), wxSize(200, 200), 0, "GLCanvas", 0); 


Then you can draw to your canvas in the OnPaint function, don't forget to create a " wxPaintDC dc(this);"

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!