-
Notifications
You must be signed in to change notification settings - Fork 0
/
wxgears.h
101 lines (83 loc) · 2.41 KB
/
wxgears.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/////////////////////////////////////////////////////////////////////////////
// Name: wxtest.h
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TEST_H_
#define _WX_TEST_H_
#include "wx/defs.h"
#include "wx/app.h"
#include "wx/menu.h"
#include "wx/dcclient.h"
#include "wx/glcanvas.h"
/* Define a new application type */
class MyApp: public wxApp
{
public:
bool OnInit();
};
/* Define a new frame type */
class TestGLCanvas;
class MyFrame: public wxFrame
{
wxTimer m_timer;
bool running;
wxCheckBox *m_gradient;
wxButton *m_start;
wxTextCtrl *m_frame_rate;
wxBoxSizer *m_topSizer;
public:
MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
void OnSize(wxSizeEvent& event);
void OnExit(wxCommandEvent& event);
void OnTimer(wxTimerEvent& event);
void OnStart(wxCommandEvent& event);
void OnShowGradient(wxCommandEvent& event);
void OnUpdateShowGradient(wxUpdateUIEvent& event);
void startTimer();
// void SetCanvas( TestGLCanvas *canvas ) { m_canvas = canvas; }
// TestGLCanvas *GetCanvas() { return m_canvas; }
private:
TestGLCanvas *m_canvas;
DECLARE_EVENT_TABLE()
};
class TestGLCanvas: public wxGLCanvas
{
double view_rotx, view_roty, view_rotz,angle;
GLint gear1, gear2, gear3;
GLubyte *pixels;
wxStopWatch stopwatch;
int dcnt,fcnt;
int height;
int width;
int prevMouseX,prevMouseY;
void gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
GLint teeth, GLfloat tooth_depth);
void InitGL();
void init_gears();
void draw_gears();
void draw_gradient();
void make_gradient();
void render();
public:
int timer_interval;
double frame_rate;
double elaped_time;
bool running;
bool show_gradient;
TestGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxT("TestGLCanvas"));
void time_tick();
void OnSize(wxSizeEvent& event);
void OnPaint(wxPaintEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void OnMouseDown( wxMouseEvent& event );
void OnMouseMove( wxMouseEvent& event);
void animate();
void reset();
void reshape(int width, int height);
private:
DECLARE_EVENT_TABLE()
};
#endif //