summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-05-15 14:01:10 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-05-15 14:01:10 (GMT)
commit22f696333adb805fa72aca0a1b5cd20a48d14fbd (patch)
treecc17c682c0c2975a9ff6aa512da3b66f4336dd19
parentafc966e22a4a2f8f76fc5daa27044606f4c5bb4a (diff)
download2iv55-22f696333adb805fa72aca0a1b5cd20a48d14fbd.zip
2iv55-22f696333adb805fa72aca0a1b5cd20a48d14fbd.tar.gz
2iv55-22f696333adb805fa72aca0a1b5cd20a48d14fbd.tar.bz2
keyboard input now sends a message to allow keyboard processing.
-rw-r--r--matchblox/main.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/matchblox/main.cpp b/matchblox/main.cpp
index 32dbd27..9bcfd5d 100644
--- a/matchblox/main.cpp
+++ b/matchblox/main.cpp
@@ -12,6 +12,7 @@
#include <GL/glut.h>
#include "message_queue.h"
+#include "message_input.h"
#include "menu.h"
#include "C_MatchBloxEngine.h"
@@ -27,14 +28,12 @@ C_MatchBloxEngine *g_pEngine;
void init_gl(void)
{
GLfloat l_fLightpos[4] = {0.0, 1.0, 1.0, 0.0};
- GLfloat l_pfMaterial[] = {1.0f, 0.4f, 0.0f, 0.0f};
glClearColor(1, 0.4, 0.2, 1.0);
glClearDepth(1000.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, l_pfMaterial);
glLightfv(GL_LIGHT0, GL_POSITION, l_fLightpos);
glEnable(GL_NORMALIZE);
glDisable(GL_TEXTURE_2D);
@@ -45,6 +44,7 @@ void init_gl(void)
void idle_func(void)
{
//call engine idle func
+ MenuRun();
glutPostRedisplay();
}
@@ -55,12 +55,8 @@ void render_scene(void)
g_pEngine->Render(glutGet(GLUT_ELAPSED_TIME));
- glDisable(GL_LIGHTING);
-
MenuRender();
- glEnable(GL_LIGHTING);
-
glutSwapBuffers();
} // render_scene
@@ -79,6 +75,11 @@ void reshape(int w, int h)
void process_normal_keys(unsigned char key, int x, int y)
{
+ struct messageq_s message;
+ struct input_payload_keyboard payload;
+
+ message.recipient = MESSAGE_MENU | MESSAGE_RENDERER;
+ message.sender = MESSAGE_INPUT_KEYBOARD;
switch (key)
{
@@ -89,10 +90,17 @@ void process_normal_keys(unsigned char key, int x, int y)
g_pEngine->Abort();
g_pEngine->NewGame(0, 0, BS_LARGE);
break;
- case ' ':
- MenuNext();
- break;
}
+
+ payload.specialkey = FALSE;
+ payload.key = (int)key;
+ payload.modifier = glutGetModifiers();
+ payload.x = x;
+ payload.y = y;
+
+ message.payload = (struct input_payload_keyboard *)&payload;
+ message.payload_size = sizeof(payload);
+ messageq_send(&message);
} // process_normal_keys