Problem with scrolling background in one OpenGL loop

Posted by GvS on Game Development See other posts from Game Development or by GvS
Published on 2011-04-23T11:59:51Z Indexed on 2012/04/05 17:47 UTC
Read the original article Hit count: 207

Filed under:
|
|

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;

© Game Development or respective owner

Related posts about opengl

Related posts about 2d