summaryrefslogtreecommitdiffstats
path: root/menu_demo/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'menu_demo/main.c')
-rw-r--r--menu_demo/main.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/menu_demo/main.c b/menu_demo/main.c
new file mode 100644
index 0000000..c859d9c
--- /dev/null
+++ b/menu_demo/main.c
@@ -0,0 +1,75 @@
+#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#include <gl\gl.h>
+
+#include "glut.h"
+#include "main.h"
+#include "menu.h"
+
+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);
+
+ init_gl();
+ MenuInit();
+
+ glutMainLoop();
+
+ return 0;
+}
+
+void init_gl(void)
+{
+ double l_dHalfWidth = SCREEN_WIDTH / 2;
+ double l_dHalfHeight = SCREEN_HEIGHT / 2;
+
+ glDepthFunc(GL_LESS);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_TEXTURE_2D);
+
+ glMatrixMode(GL_PROJECTION);
+
+ glOrtho(-l_dHalfWidth,
+ l_dHalfWidth,
+ -l_dHalfHeight,
+ l_dHalfHeight,
+ -1,
+ 1
+ );
+
+ glMatrixMode(GL_MODELVIEW);
+}
+
+void render_scene(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glClearColor(1, 1, 1, 0);
+
+ MenuRender();
+
+ glutSwapBuffers();
+}
+
+void process_normal_keys(unsigned char key, int x, int y)
+{
+ // escape
+ if (key == 27) exit(0);
+}
+
+void process_special_keys(int key, int x, int y)
+{
+ switch (key)
+ {
+ // do sumting
+ }
+}