summaryrefslogtreecommitdiffstats
path: root/MatchBloxEngine/MatchBloxEngine/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'MatchBloxEngine/MatchBloxEngine/main.cpp')
-rw-r--r--MatchBloxEngine/MatchBloxEngine/main.cpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/MatchBloxEngine/MatchBloxEngine/main.cpp b/MatchBloxEngine/MatchBloxEngine/main.cpp
new file mode 100644
index 0000000..df9e82d
--- /dev/null
+++ b/MatchBloxEngine/MatchBloxEngine/main.cpp
@@ -0,0 +1,129 @@
+#include <GL/glut.h>
+#include <stdlib.h>
+
+
+#include "MessageQueue.h"
+
+#define SCREEN_WIDTH 640
+#define SCREEN_HEIGHT 480
+
+msgQueue g_Queue;
+
+void init_gl(void)
+{
+ glClearColor(0.2, 1, 0.2, 1);
+ glClearDepth(1000.0);
+} // init_gl
+
+void idle_func(void)
+{
+ //call engine idle func
+
+ glutPostRedisplay();
+}
+
+void render_scene(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+
+ glutSwapBuffers();
+
+} // render_scene
+
+
+
+void process_normal_keys(unsigned char key, int x, int y)
+{
+ // escape
+ if (key == 27)
+ {
+ exit(0);
+ }
+ else
+ {
+ msgStruct l_msg;
+ l_msg.m_MessageType = KEY_PRESS;
+ l_msg.parm1 = key;
+ l_msg.parm2 = x;
+ l_msg.parm3 = y;
+
+ g_Queue.push(l_msg);
+ }
+} // process_normal_keys
+
+
+
+void process_special_keys(int key, int x, int y)
+{
+ switch (key)
+ {
+ // do sumting
+ }
+ msgStruct l_msg;
+ l_msg.m_MessageType = SPECIAL_KEY;
+ l_msg.parm1 = key;
+ l_msg.parm2 = x;
+ l_msg.parm3 = y;
+
+ g_Queue.push(l_msg);
+
+} // process_special_keys
+
+
+
+void process_mouse(int button, int state, int x, int y)
+{
+ msgStruct l_msg;
+ l_msg.m_MessageType = MOUSE_PRESS;
+ l_msg.parm1 = button;
+ l_msg.parm2 = state;
+ l_msg.parm3 = x;
+ l_msg.parm4 = y;
+
+ g_Queue.push(l_msg);
+
+
+} // process_mouse
+
+
+
+void process_passive_mouse(int x, int y)
+{
+ //process_mouse(-1, -1, x, y);
+ msgStruct l_msg;
+ l_msg.m_MessageType = MOUSE_MOVE;
+ l_msg.parm1 = x;
+ l_msg.parm2 = y;
+ l_msg.parm3 = 0;
+ l_msg.parm4 = 0;
+
+ g_Queue.push(l_msg);
+
+} // process_passive_mouse
+
+
+
+int main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT);
+ glutCreateWindow("Menu demo");
+ glutDisplayFunc(render_scene);
+ glutIdleFunc(render_scene);
+ glutKeyboardFunc(process_normal_keys);
+ glutSpecialFunc(process_special_keys);
+ glutMouseFunc(process_mouse);
+ glutPassiveMotionFunc(process_passive_mouse);
+
+ init_gl();
+ //MenuInit(SCREEN_WIDTH, SCREEN_HEIGHT);
+
+ glutMainLoop();
+
+ return 0;
+
+} // main
+
+