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.

I have 960x3000 map image in png and I'm scrolling it in a loop like this (it's called in 60 FPS loop):

glPushMatrix();
    glBindTexture( GL_TEXTURE_2D, mapTex[iBgImg]);
    glBegin(GL_QUADS);
    double mtstart = 0.0f - fBgVPos/(double)BgSize;
    double mtend = mtstart + mtsize;
    glTexCoord2d(0.0, mtstart); glVertex2f(fBgX, TOP_MARGIN);
    glTexCoord2d(1.0, mtstart); glVertex2f(fBgX + MAP_WIDTH, TOP_MARGIN);
    glTexCoord2d(1.0, mtend); glVertex2f(fBgX + MAP_WIDTH, BOTTOM_MARGIN);
    glTexCoord2d(0.0, mtend); glVertex2f(fBgX, BOTTOM_MARGIN);
    glEnd();
glPopMatrix();

unfortunately it isn't smooth when the game is in windowed mode. However, it is smooth in full screen mode. I'm using GLFW for windows. Maybe there is something wrong with my method? Is there anything better? Or could this be hardware problem?

Edit: Window is created using

 glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
 glfwOpenWindowHint(GLFW_REFRESH_RATE, 60);

and main loop is using glfwSwapInterval(1) to ensure 60 FPS;

share|improve this question
    
How do you call this function? Are you using some timer callback or displayfunc callback? –  zacharmarz Apr 23 '11 at 12:38
2  
Try to add glFinish; before SwapBuffers. It may make the animation look smoother. I can add more detail if that helps. –  Krom Stern Aug 2 '11 at 9:09
    
It helped, thanks a lot! –  GvS Oct 12 '11 at 15:46
add comment

1 Answer

up vote 1 down vote accepted

copied from my comment

You need to add glFinish; before SwapBuffers command. This will force OpenGL to display rendering ASAP, instead of waiting for more data you may pass to it or relying on OpenGL sense of "right time" to finish. It may make the animation look smoother, because in current code if OpenGL waited just 1ms more the whole frame according to refresh rate will be delayed by 1/60s and next frame after it will probably get skipped - hence the jaggy motion.

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.