From 01d6561d73d11a28fd339d46e73e12fd5658300a Mon Sep 17 00:00:00 2001 From: Kyle K Date: Sat, 2 Jul 2011 14:59:16 -0500 Subject: split more --- sdl/window.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 sdl/window.c (limited to 'sdl/window.c') diff --git a/sdl/window.c b/sdl/window.c new file mode 100644 index 0000000..3ecd99c --- /dev/null +++ b/sdl/window.c @@ -0,0 +1,37 @@ +/* window.c + * + * Window + * + * + */ + +#include +#include +#include +#include "window.h" + +extern const unsigned int bpp; + +void window_resize(int w, int h) +{ + printf("window: resizing to %dx%d\n", w, h); + GLfloat fAspect = (GLfloat) w / (GLfloat) h; + if (h == 0) + h = 1; + glViewport(0, 0, w, h); + + /* reset coordinate system */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + /* produce the perspective projection */ + /* void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) */ + gluPerspective(40.0f, fAspect, 1.0, 40.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + /* this needs to be ran again, glut does it for you I suppose */ + SDL_SetVideoMode(w, h, bpp, SDL_OPENGL | SDL_RESIZABLE); +} + -- cgit v1.2.3