summaryrefslogtreecommitdiffstats
path: root/sdl/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'sdl/window.c')
-rw-r--r--sdl/window.c37
1 files changed, 37 insertions, 0 deletions
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 <SDL/SDL.h>
+#include <SDL/SDL_image.h>
+#include <GL/glew.h>
+#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);
+}
+