Hi!
Consider the following little program, running under Linux with a TNT2 card
and nVidia GLX:
---- snip ----
#include <SDL.h>
#include <GL/gl.h>
static void window_resized(int w, int h)
{
SDL_SetVideoMode(w, h, 16, SDL_OPENGL | SDL_RESIZABLE);
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1, 1, 0, -1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
glVertex2i(0, 0); glVertex2i(1, 1);
glVertex2i(1, 0); glVertex2i(0, 1);
glEnd();
SDL_GL_SwapBuffers();
}
int main(void)
{
SDL_Surface *s;
SDL_Event e;
int done = 0;
SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
s = SDL_SetVideoMode(320, 240, 16, SDL_OPENGL | SDL_RESIZABLE);
window_resized(320, 240);
while (!done) {
SDL_WaitEvent(&e);
switch (e.type) {
case SDL_VIDEORESIZE:
window_resized(e.resize.w, e.resize.h);
break;
case SDL_QUIT:
done = 1;
break;
}
}
SDL_Quit();
return 0;
}
---- snap ----
It is supposed to show a window with a diagonal white cross that resizes when
you resize the window. My concern is with the SDL_SetVideoMode() call in
window_resized(). It is appearently necessary, otherwise OpenGL gets the
geometry wrong. Why is this?
Bye,
Christian–
/ Coding on PowerPC and proud of it
/ http://www.uni-mainz.de/~bauec002/