]>
Commit | Line | Data |
---|---|---|
8b089c5e JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: cube.h | |
3 | // Purpose: wxGLCanvas demo program | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
8b089c5e | 7 | // Copyright: (c) Julian Smart |
2f6c54eb | 8 | // Licence: wxWindows licence |
8b089c5e JS |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _WX_CUBE_H_ | |
12 | #define _WX_CUBE_H_ | |
13 | ||
9d705dfa | 14 | #include "wx/glcanvas.h" |
8b089c5e | 15 | |
50f5d508 VZ |
16 | // the rendering context used by all GL canvases |
17 | class TestGLContext : public wxGLContext | |
18 | { | |
19 | public: | |
20 | TestGLContext(wxGLCanvas *canvas); | |
21 | ||
22 | // render the cube showing it at given angles | |
23 | void DrawRotatedCube(float xangle, float yangle); | |
24 | ||
25 | private: | |
378a3872 VZ |
26 | // textures for the cube faces |
27 | GLuint m_textures[6]; | |
50f5d508 VZ |
28 | }; |
29 | ||
8b089c5e | 30 | // Define a new application type |
451c13c8 | 31 | class MyApp : public wxApp |
8b089c5e JS |
32 | { |
33 | public: | |
e8481866 | 34 | MyApp() { m_glContext = NULL; m_glStereoContext = NULL; } |
43c742d0 | 35 | |
451c13c8 VZ |
36 | // Returns the shared context used by all frames and sets it as current for |
37 | // the given canvas. | |
e8481866 | 38 | TestGLContext& GetContext(wxGLCanvas *canvas, bool useStereo); |
43c742d0 VZ |
39 | |
40 | // virtual wxApp methods | |
41 | virtual bool OnInit(); | |
42 | virtual int OnExit(); | |
43 | ||
44 | private: | |
e8481866 | 45 | // the GL context we use for all our mono rendering windows |
50f5d508 | 46 | TestGLContext *m_glContext; |
e8481866 VZ |
47 | // the GL context we use for all our stereo rendering windows |
48 | TestGLContext *m_glStereoContext; | |
8b089c5e JS |
49 | }; |
50 | ||
51 | // Define a new frame type | |
451c13c8 | 52 | class MyFrame : public wxFrame |
8b089c5e JS |
53 | { |
54 | public: | |
e8481866 | 55 | MyFrame(bool stereoWindow = false); |
8b089c5e | 56 | |
264f2261 | 57 | private: |
1f602af6 | 58 | void OnClose(wxCommandEvent& event); |
ec299508 | 59 | void OnNewWindow(wxCommandEvent& event); |
e8481866 | 60 | void OnNewStereoWindow(wxCommandEvent& event); |
8b089c5e | 61 | |
5cf036d0 | 62 | DECLARE_EVENT_TABLE() |
8b089c5e JS |
63 | }; |
64 | ||
43c742d0 | 65 | class TestGLCanvas : public wxGLCanvas |
8b089c5e | 66 | { |
8b089c5e | 67 | public: |
e8481866 | 68 | TestGLCanvas(wxWindow *parent, int *attribList = NULL); |
5cf036d0 | 69 | |
264f2261 | 70 | private: |
5cf036d0 | 71 | void OnPaint(wxPaintEvent& event); |
e4545e01 | 72 | void Spin(float xSpin, float ySpin); |
5cf036d0 | 73 | void OnKeyDown(wxKeyEvent& event); |
e4545e01 | 74 | void OnSpinTimer(wxTimerEvent& WXUNUSED(event)); |
5cf036d0 | 75 | |
50f5d508 VZ |
76 | // angles of rotation around x- and y- axis |
77 | float m_xangle, | |
78 | m_yangle; | |
8b089c5e | 79 | |
e4545e01 | 80 | wxTimer m_spinTimer; |
e8481866 VZ |
81 | bool m_useStereo, |
82 | m_stereoWarningAlreadyDisplayed; | |
e4545e01 | 83 | |
43c742d0 | 84 | DECLARE_EVENT_TABLE() |
8b089c5e JS |
85 | }; |
86 | ||
e8481866 VZ |
87 | enum |
88 | { | |
89 | NEW_STEREO_WINDOW = wxID_HIGHEST + 1 | |
90 | }; | |
91 | ||
43c742d0 | 92 | #endif // _WX_CUBE_H_ |