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.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/MatchBloxEngine/MatchBloxEngine/main.cpp b/MatchBloxEngine/MatchBloxEngine/main.cpp
index df9e82d..0ddf8eb 100644
--- a/MatchBloxEngine/MatchBloxEngine/main.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/main.cpp
@@ -1,18 +1,27 @@
#include <GL/glut.h>
-#include <stdlib.h>
-
+#include <iostream>
#include "MessageQueue.h"
+#include "C_MatchBloxEngine.h"
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
msgQueue g_Queue;
+C_MatchBloxEngine *g_pEngine;
void init_gl(void)
{
- glClearColor(0.2, 1, 0.2, 1);
+ glClearColor(0.9, 0.9, 0.9, 1.0);
glClearDepth(1000.0);
+ glShadeModel(GL_SMOOTH);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ //glEnable(GL_COLOR_MATERIAL);
+ glEnable(GL_NORMALIZE);
+
+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
} // init_gl
void idle_func(void)
@@ -25,13 +34,24 @@ void idle_func(void)
void render_scene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
+
+ g_pEngine->Render(1000);
glutSwapBuffers();
} // render_scene
-
+void reshape(int w, int h)
+{
+ //set the new viewport dimension
+ glViewport(0, 0, w, h);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(90.0, ((GLdouble)h)/((GLdouble)w), 0.5, 100.0);
+ glTranslated(0.0, 0.0, -0.5);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
void process_normal_keys(unsigned char key, int x, int y)
{
@@ -109,9 +129,11 @@ int main(int argc, char **argv)
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT);
- glutCreateWindow("Menu demo");
+ glutCreateWindow("MatchBloxEngine demo");
+
+ glutReshapeFunc(reshape);
glutDisplayFunc(render_scene);
- glutIdleFunc(render_scene);
+ glutIdleFunc(idle_func);
glutKeyboardFunc(process_normal_keys);
glutSpecialFunc(process_special_keys);
glutMouseFunc(process_mouse);
@@ -120,6 +142,8 @@ int main(int argc, char **argv)
init_gl();
//MenuInit(SCREEN_WIDTH, SCREEN_HEIGHT);
+ g_pEngine = new C_MatchBloxEngine("models", "");
+
glutMainLoop();
return 0;