From c00a15aa99bd0a32d4c4faa3f42698a8485fdb72 Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Wed, 14 May 2008 12:45:18 +0000 Subject: first integration step. --- matchblox/Makefile | 4 ++-- matchblox/main.cpp | 67 ++++++++++++++++++++++-------------------------------- 2 files changed, 29 insertions(+), 42 deletions(-) diff --git a/matchblox/Makefile b/matchblox/Makefile index 0222105..5522125 100644 --- a/matchblox/Makefile +++ b/matchblox/Makefile @@ -6,11 +6,11 @@ CC=gcc all: matchblox_menu matchblox_engine - $(CXX) $(LDFLAGS) main.o bitmap.o button.o font.o menu.o C_3DObject.o C_Hand.o C_Block.o C_Log.o C_Environment.o C_Box.o C_MatchBloxEngine.o -o MatchBlox + $(CXX) $(LDFLAGS) main.o message_queue.o bitmap.o button.o font.o menu.o C_3DObject.o C_Hand.o C_Block.o C_Log.o C_Environment.o C_Box.o C_MatchBloxEngine.o -o MatchBlox matchblox_common: - $(CC) $(CFLAGS) -o message_queue -c common/message_queue.c + $(CC) $(CFLAGS) -o message_queue.o -c common/message_queue.c $(CC) $(CFLAGS) -o bitmap.o -c common/bitmap.c $(CC) $(CFLAGS) -o font.o -c common/font.c diff --git a/matchblox/main.cpp b/matchblox/main.cpp index dc4ec64..06cbca6 100644 --- a/matchblox/main.cpp +++ b/matchblox/main.cpp @@ -1,13 +1,24 @@ -#include +#ifdef G_OS_WIN32 + #define WIN32_LEAN_AND_MEAN 1 + #include +#else + #define FALSE 0 + #define TRUE !FALSE +#endif + #include +#include + +#include "message_queue.h" -#include "MessageQueue.h" #include "C_MatchBloxEngine.h" #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 -msgQueue g_Queue; +#define KEY_ESCAPE 27 + + C_MatchBloxEngine *g_pEngine; void init_gl(void) @@ -56,25 +67,19 @@ void reshape(int w, int h) void process_normal_keys(unsigned char key, int x, int y) { - // escape - if (key == 27) - { - exit(0); - } - else + + switch (key) { - if (key == 'n') - { + case KEY_ESCAPE: + exit(0); + break; + case 'n': g_pEngine->Abort(); g_pEngine->NewGame(0, 0, BS_LARGE); - } - 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); + break; + case ' ': + + break; } } // process_normal_keys @@ -86,13 +91,7 @@ void process_special_keys(int key, int x, int y) { // 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 @@ -100,14 +99,7 @@ void process_special_keys(int key, int x, int y) 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 @@ -117,14 +109,7 @@ void process_mouse(int button, int state, int x, int y) 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 @@ -132,10 +117,12 @@ void process_passive_mouse(int x, int y) int main(int argc, char **argv) { + messageq_init(); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT); - glutCreateWindow("MatchBloxEngine demo"); + glutCreateWindow("MatchBlox"); glutReshapeFunc(reshape); glutDisplayFunc(render_scene); -- cgit v0.12