diff options
author | Kyle K <kylek389@gmail.com> | 2011-07-02 14:59:16 -0500 |
---|---|---|
committer | Kamil Kaminski <kamilkss@gmail.com> | 2011-07-02 14:59:16 -0500 |
commit | 01d6561d73d11a28fd339d46e73e12fd5658300a (patch) | |
tree | 4c421770be1b335f4ae38042480ed905f232c60c /sdl/window.c | |
parent | 616f2216d80848f88605be75fd03049f6d635378 (diff) | |
download | GLPyramid-01d6561d73d11a28fd339d46e73e12fd5658300a.tar.gz GLPyramid-01d6561d73d11a28fd339d46e73e12fd5658300a.tar.bz2 GLPyramid-01d6561d73d11a28fd339d46e73e12fd5658300a.zip |
split more
Diffstat (limited to 'sdl/window.c')
-rw-r--r-- | sdl/window.c | 37 |
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); +} + |