diff options
Diffstat (limited to 'menu_demo/main.c')
-rw-r--r-- | menu_demo/main.c | 286 |
1 files changed, 144 insertions, 142 deletions
diff --git a/menu_demo/main.c b/menu_demo/main.c index 2cea607..a48ff52 100644 --- a/menu_demo/main.c +++ b/menu_demo/main.c @@ -1,142 +1,144 @@ -#ifdef G_OS_WIN32
- #define WIN32_LEAN_AND_MEAN 1
- #include <windows.h>
-#endif
-
-#include <stdlib.h>
-#include <GL/gl.h>
-#include <GL/glut.h>
-#include <math.h>
-
-#include "menu.h"
-
-#define SCREEN_WIDTH 640
-#define SCREEN_HEIGHT 480
-
-
-void init_gl(void)
-{
-
-} // init_gl
-
-
-void render_blox(void)
-{
- static double l_dAngle = 0.0;
-
- glPushMatrix();
- glTranslated(0, 0, -20);
- glTranslated(sin(l_dAngle * (float)3.1415 / 180.0f) * 5,
- sin(l_dAngle * (float)3.1415 / 180.0f) * 5,
- -5 + sin(l_dAngle * (float)3.1415 / 180.0f) * 5);
- glRotated(l_dAngle, 0.5, 0.5, 1);
-
- // draw big cube
- glutSolidCube(4);
-
- glPushMatrix();
- // draw smaller cube
- glTranslated(0, sin(l_dAngle * (float)3.1415 / 180.0f) * 5, 0);
- glutSolidCube(2);
- glPopMatrix();
-
- glPopMatrix();
-
- l_dAngle += 0.1;
-
-} // render_blox
-
-
-void render_scene(void)
-{
- float l_pfMaterial[] = {1.0f, 0.4f, 0.0f, 0.0f};
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glClearColor(1, 0.4, 0.2, 1);
- glDisable(GL_TEXTURE_2D);
-
- // enable default lighting
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, l_pfMaterial);
-
- // render 3d shit
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(45, 1.0, 1.0, 100.0);
- glMatrixMode(GL_MODELVIEW);
-
- render_blox();
-
- glDisable(GL_LIGHTING);
-
- MenuRender();
- glutSwapBuffers();
-
-} // render_scene
-
-
-
-void process_normal_keys(unsigned char key, int x, int y)
-{
- // escape
- if (key == 27) exit(0);
- if (key == ' ') MenuNext();
-
-} // process_normal_keys
-
-
-
-void process_special_keys(int key, int x, int y)
-{
- switch (key)
- {
- // do sumting
- }
-
-} // process_special_keys
-
-
-
-void process_mouse(int button, int state, int x, int y)
-{
- MenuMouseClick(button, state, x, y);
-
-} // process_mouse
-
-
-
-void process_passive_mouse(int x, int y)
-{
- MenuMouseMove(x, y);
-
-} // 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);
-
- ShowCursor(FALSE);
-
- glutMainLoop();
-
- return 0;
-
-} // main
-
-
+#ifdef G_OS_WIN32 + #define WIN32_LEAN_AND_MEAN 1 + #include <windows.h> +#else + #define FALSE 0 + #define TRUE !FALSE +#endif + +#include <stdlib.h> +#include <GL/gl.h> +#include <GL/glut.h> +#include <math.h> + +#include "menu.h" + +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 + + +void init_gl(void) +{ + +} // init_gl + + +void render_blox(void) +{ + static double l_dAngle = 0.0; + + glPushMatrix(); + glTranslated(0, 0, -20); + glTranslated(sin(l_dAngle * (float)3.1415 / 180.0f) * 5, + sin(l_dAngle * (float)3.1415 / 180.0f) * 5, + -5 + sin(l_dAngle * (float)3.1415 / 180.0f) * 5); + glRotated(l_dAngle, 0.5, 0.5, 1); + + // draw big cube + glutSolidCube(4); + + glPushMatrix(); + // draw smaller cube + glTranslated(0, sin(l_dAngle * (float)3.1415 / 180.0f) * 5, 0); + glutSolidCube(2); + glPopMatrix(); + + glPopMatrix(); + + l_dAngle += 0.1; + +} // render_blox + + +void render_scene(void) +{ + float l_pfMaterial[] = {1.0f, 0.4f, 0.0f, 0.0f}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClearColor(1, 0.4, 0.2, 1); + glDisable(GL_TEXTURE_2D); + + // enable default lighting + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, l_pfMaterial); + + // render 3d shit + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45, 1.0, 1.0, 100.0); + glMatrixMode(GL_MODELVIEW); + + render_blox(); + + glDisable(GL_LIGHTING); + + MenuRender(); + glutSwapBuffers(); + +} // render_scene + + + +void process_normal_keys(unsigned char key, int x, int y) +{ + // escape + if (key == 27) exit(0); + if (key == ' ') MenuNext(); + +} // process_normal_keys + + + +void process_special_keys(int key, int x, int y) +{ + switch (key) + { + // do sumting + } + +} // process_special_keys + + + +void process_mouse(int button, int state, int x, int y) +{ + MenuMouseClick(button, state, x, y); + +} // process_mouse + + + +void process_passive_mouse(int x, int y) +{ + MenuMouseMove(x, y); + +} // 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); + glutSetCursor(GLUT_CURSOR_NONE); + + init_gl(); + MenuInit(SCREEN_WIDTH, SCREEN_HEIGHT); + + glutMainLoop(); + + return 0; + +} // main + + |