#include <math.h> //For trig functions
+static int screen_width = 0;
+static int screen_height = 0;
+
/**
* @function Graphics_Init
* @purpose Initialise the SDL/OpenGL graphics system
glDisable(GL_DEPTH_TEST);
SDL_WM_SetCaption(caption, NULL);
+
+ screen_width = w; screen_height = h;
+
atexit(Graphics_Destroy);
}
//SDL_Flip(screen);
}
+/**
+ * @function Process_Events
+ * @purpose Handle any SDL events recieved.
+ */
+void Process_Events()
+{
+ static float view_v[3] = {0,0,0};
+ static float view_speed = 5.0;
+ static float view_scale = 1;
+ SDL_Event event;
+
+
+
+
+ while (SDL_PollEvent(&event))
+ {
+ switch (event.type)
+ {
+ case SDL_KEYDOWN:
+ switch (event.key.keysym.sym)
+ {
+ case SDLK_LEFT:
+ view_v[0] += view_speed;
+ break;
+ case SDLK_RIGHT:
+ view_v[0] -= view_speed;
+ break;
+ case SDLK_UP:
+ view_v[1] += view_speed;
+ break;
+ case SDLK_DOWN:
+ view_v[1] -= view_speed;
+ break;
+ case SDLK_i:
+ view_v[0] = 0; view_v[1] = 0; view_v[2] = 0;
+ view_scale = 1;
+ glLoadIdentity();
+ break;
+ default:
+ break;
+ }
+ break;
+ case SDL_KEYUP:
+ switch (event.key.keysym.sym)
+ {
+ case SDLK_LEFT:
+ case SDLK_RIGHT:
+ view_v[0] = 0;
+ break;
+ case SDLK_UP:
+ case SDLK_DOWN:
+ view_v[1] = 0;
+ default:
+ break;
+ }
+ break;
+
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ int mouse[2];
+ SDL_GetMouseState(mouse, mouse+1);
+
+ switch (event.button.button)
+ {
+ case SDL_BUTTON_WHEELUP:
+
+ view_scale = 1.05;
+ glTranslatef(screen_width/2.0, screen_height/2.0,0.0);
+ glScaled(view_scale, view_scale, 1);
+ glTranslatef(-screen_width/2.0, -screen_height/2.0, 0.0);
+ break;
+ case SDL_BUTTON_WHEELDOWN:
+ view_scale = 0.95;
+ glTranslatef(screen_width/2.0, screen_height/2.0,0.0);
+ glScaled(view_scale, view_scale, 1);
+ glTranslatef(-screen_width/2.0, -screen_height/2.0, 0.0);
+ break;
+ default:
+ break;
+
+ }
+
+ break;
+ }
+ case SDL_MOUSEBUTTONUP:
+ break;
+ case SDL_QUIT:
+ exit(EXIT_SUCCESS);
+ break;
+ }
+ }
+
+
+ glTranslatef(view_v[0], view_v[1], view_v[2]);
+ //SDL_Delay(1);
+}
+