-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.cpp
More file actions
132 lines (107 loc) · 3.11 KB
/
example.cpp
File metadata and controls
132 lines (107 loc) · 3.11 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include<dslab.h>
#include<iostream>
using namespace std;
class MyDataEngine :public DataEngine
{
private:
double theta[3];
public:
virtual void Init()
{
cout << "Initialization" << endl;
glEnable(GL_DEPTH_TEST);
}
virtual void think(double iElapsed)
{
theta[0] += 0.1*3.1415926*(iElapsed / 1E12);
theta[1] += 0.06*3.1415926*(iElapsed / 1E12);
}
virtual void createMenu(wxMenu *menuDataEngine)
{
// start of from 500
menuDataEngine->Append(500,wxT("First"),wxT("Help"));
menuDataEngine->Append(501,wxT("Second"),wxT("Help2"));
}
virtual void extendViewMenu(wxMenu *menuDataEngine)
{
// start of from 500
menuDataEngine->Append(502,wxT("First View"),wxT("Help"));
menuDataEngine->Append(503,wxT("Second View"),wxT("Help2"));
DS_start_rendering();
}
virtual void handleMenu(int id)
{
cout << "Menu " << id << endl;
wxMessageBox( wxT("Hello there..."), wxT("About"), wxOK | wxICON_INFORMATION );
}
virtual void beforeQuit(){
// Do some data cleanup / file sync / close
cout << "Preparing DataEngine for exit" << endl;
};
virtual void render(size_t width, size_t height)
{
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
if ( width <= height ) {
glOrtho( -2.0, 2.0, -2.0 * (GLfloat) height / (GLfloat) width,
2.0 * (GLfloat) height / (GLfloat) width, -10.0, 10.0 );
} else {
glOrtho( -2.0 * (GLfloat) width / (GLfloat) height,
2.0 * (GLfloat) width / (GLfloat) height, -2.0, 2.0, -10.0, 10.0 );
}
glMatrixMode( GL_MODELVIEW );
GLdouble size = 0.75;
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glRotatef( theta[0], 1.0, 0.0, 0.0 );
glRotatef( theta[1], 0.0, 1.0, 0.0 );
glRotatef( theta[2], 0.0, 0.0, 1.0 );
glColor3f( 1.0, 0.0, 0.0 );
glBegin(GL_POLYGON);
glColor3f( 1.0, 1.0, 1.0 );
glVertex3f( 0.5, -0.5, 0.5 );
glVertex3f( 0.5, 0.5, 0.5 );
glVertex3f( -0.5, 0.5, 0.5 );
glVertex3f( -0.5, -0.5, 0.5 );
glEnd();
glBegin(GL_POLYGON);
glColor3f( 1.0, 0.0, 1.0 );
glVertex3f( 0.5, -0.5, -0.5 );
glVertex3f( 0.5, 0.5, -0.5 );
glVertex3f( 0.5, 0.5, 0.5 );
glVertex3f( 0.5, -0.5, 0.5 );
glEnd();
glBegin(GL_POLYGON);
glColor3f( 0.0, 1.0, 0.0 );
glVertex3f( -0.5, -0.5, 0.5 );
glVertex3f( -0.5, 0.5, 0.5 );
glVertex3f( -0.5, 0.5, -0.5 );
glVertex3f( -0.5, -0.5, -0.5 );
glEnd();
glBegin(GL_POLYGON);
glColor3f( 0.0, 0.0, 1.0 );
glVertex3f( 0.5, 0.5, 0.5 );
glVertex3f( 0.5, 0.5, -0.5 );
glVertex3f( -0.5, 0.5, -0.5 );
glVertex3f( -0.5, 0.5, 0.5 );
glEnd();
glBegin(GL_POLYGON);
glColor3f( 1.0, 0.0, 0.0 );
glVertex3f( 0.5, -0.5, -0.5 );
glVertex3f( 0.5, -0.5, 0.5 );
glVertex3f( -0.5, -0.5, 0.5 );
glVertex3f( -0.5, -0.5, -0.5 );
glEnd();
}
virtual void mouseClick(size_t x, size_t y)
{
cout << "Click @" << x <<","<< y << endl;
}
};
/*Instantiate it and make it available to the library*/
MyDataEngine eng;
DataEngine *getDataEngineImplementation()
{
return (DataEngine*) ŋ
}