Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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);
glClearDepth(1.0f);

glViewport(0, 0, width, height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

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

glMatrixMode(GL_MODELVIEW);

glEnable(GL_TEXTURE_2D);

glLoadIdentity();

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?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.