]> git.saurik.com Git - wxWidgets.git/blob - samples/opengl/cube/cube.h
as after recent change wxID_SEPARATOR is now -2, it is better for idMenuTitle to...
[wxWidgets.git] / samples / opengl / cube / cube.h
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CUBE_H_
13 #define _WX_CUBE_H_
14
15 #include "wx/glcanvas.h"
16
17 // Define a new application type
18 class MyApp: public wxApp
19 {
20 public:
21 bool OnInit();
22 };
23
24 // Define a new frame type
25 class TestGLCanvas;
26
27 class MyFrame: public wxFrame
28 {
29 public:
30 static MyFrame *Create(MyFrame *parentFrame, bool isCloneWindow = false);
31
32 void OnExit(wxCommandEvent& event);
33 void OnNewWindow(wxCommandEvent& event);
34 void OnDefRotateLeftKey(wxCommandEvent& event);
35 void OnDefRotateRightKey(wxCommandEvent& event);
36
37 private:
38
39 MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos,
40 const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
41
42
43 TestGLCanvas *m_canvas;
44
45 DECLARE_EVENT_TABLE()
46 };
47
48 #if wxUSE_GLCANVAS
49
50 class TestGLCanvas: public wxGLCanvas
51 {
52 friend class MyFrame;
53 public:
54 TestGLCanvas( wxWindow *parent, wxWindowID id = wxID_ANY,
55 const wxPoint& pos = wxDefaultPosition,
56 const wxSize& size = wxDefaultSize,
57 long style = 0, const wxString& name = _T("TestGLCanvas") );
58
59 TestGLCanvas( wxWindow *parent, const TestGLCanvas &other,
60 wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize, long style = 0,
62 const wxString& name = _T("TestGLCanvas") );
63
64 ~TestGLCanvas();
65
66 void OnPaint(wxPaintEvent& event);
67 void OnSize(wxSizeEvent& event);
68 void OnEraseBackground(wxEraseEvent& event);
69 void OnKeyDown(wxKeyEvent& event);
70 void OnKeyUp(wxKeyEvent& event);
71 void OnEnterWindow(wxMouseEvent& event);
72
73 void Render();
74 void InitGL();
75 void Rotate(GLfloat deg);
76 static GLfloat CalcRotateSpeed(unsigned long acceltime);
77 static GLfloat CalcRotateAngle( unsigned long lasttime,
78 unsigned long acceltime );
79 void Action( long code, unsigned long lasttime,
80 unsigned long acceltime );
81
82 private:
83 bool m_init;
84 GLuint m_gllist;
85 long m_rleft;
86 long m_rright;
87
88 static unsigned long m_secbase;
89 static int m_TimeInitialized;
90 static unsigned long m_xsynct;
91 static unsigned long m_gsynct;
92
93 long m_Key;
94 unsigned long m_StartTime;
95 unsigned long m_LastTime;
96 unsigned long m_LastRedraw;
97
98 DECLARE_EVENT_TABLE()
99 };
100
101 #endif // #if wxUSE_GLCANVAS
102
103 #endif // #ifndef _WX_CUBE_H_
104