So basically my question is im making a 2D game with openGL and SDL.

So what im trying to do is resize the game and have the openGL quad scale to the size my window becomes.

void CApp::OnResize(int w, int h){

textureWidth = (float)w;
textureHeight = (float)h;

SDLWindow::SetGLWindow(w, h, Surf_Display);


bool SDLWindow::SetGLWindow(int width, int height, SDL_Surface * Surf_Display)
if((Surf_Display = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_RESIZABLE)) == NULL) {
    return false;

glClearColor(0, 0, 0, 0);

glViewport(0, 0, width, height);


glOrtho(0, width, height, 0, 1, -1);




return true;


So this works just fine. However while resizing the window, the image isnt scaling. It only scales after i release the mouse button. I am curious if i can scale the image at the same time?


1 Answer 1


I'm not too familiar with SDL (more experience with GLUT), but I looked around a bit and found this post. The reply you're looking for is near the bottom by the user 'rip-off'.

It seems that SDL will halt while certain events are occuring, such as resizing the window. However, the program still has to draw, so there are portions of it which are still executing. rip-off suggests taking control of the portion which continues executing by passing your own event filter to SDL_SetEventFilter, and calling your draw() function each time the event is a resize.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .