1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGLCanvas demo program
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/glcanvas.h"
16 // the rendering context used by all GL canvases
17 class TestGLContext
: public wxGLContext
20 TestGLContext(wxGLCanvas
*canvas
);
22 // render the cube showing it at given angles
23 void DrawRotatedCube(float xangle
, float yangle
);
26 // textures for the cube faces
30 // Define a new application type
31 class MyApp
: public wxApp
34 MyApp() { m_glContext
= NULL
; m_glStereoContext
= NULL
; }
36 // Returns the shared context used by all frames and sets it as current for
38 TestGLContext
& GetContext(wxGLCanvas
*canvas
, bool useStereo
);
40 // virtual wxApp methods
41 virtual bool OnInit();
45 // the GL context we use for all our mono rendering windows
46 TestGLContext
*m_glContext
;
47 // the GL context we use for all our stereo rendering windows
48 TestGLContext
*m_glStereoContext
;
51 // Define a new frame type
52 class MyFrame
: public wxFrame
55 MyFrame(bool stereoWindow
= false);
58 void OnClose(wxCommandEvent
& event
);
59 void OnNewWindow(wxCommandEvent
& event
);
60 void OnNewStereoWindow(wxCommandEvent
& event
);
65 class TestGLCanvas
: public wxGLCanvas
68 TestGLCanvas(wxWindow
*parent
, int *attribList
= NULL
);
71 void OnPaint(wxPaintEvent
& event
);
72 void Spin(float xSpin
, float ySpin
);
73 void OnKeyDown(wxKeyEvent
& event
);
74 void OnSpinTimer(wxTimerEvent
& WXUNUSED(event
));
76 // angles of rotation around x- and y- axis
82 m_stereoWarningAlreadyDisplayed
;
89 NEW_STEREO_WINDOW
= wxID_HIGHEST
+ 1