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