Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Only parts of the screen gets updated

  1. #1
    Newbie Newbie
    Join Date
    Aug 2012
    Posts
    2

    Only parts of the screen gets updated

    I am currently making my first 3D OpenGL game (with SDL). You're supposed to find missing children in a forest, and you can place stones behind you, so you know where you've been.

    Some times when I 'save' a kid, or when I place a stone, only a part of the screen gets updated/rendered (the part is a square ~1/4 of the screen).
    Edit: For some reason, without doing anything to the code, the whole screen is freezing.

    The only thing I can do to fix it is to make the program draw something new, or remove something from the 'drawing-list' (like saving a new kid or placing a new stone) when the bug is occurring.
    The game itself is running, it's only the rendering part that freezes up.

    I have tried to capture the bug on video with Fraps and Bandicam, but when the bug happens, the recording doesn't get that. It shows that it is running like normal.

    I would like to add some source code, but I have no idea what portion of the code is bugged.
    Maybe some of you have seen/heard of it before, and know what could be the cause?

    This is how I set up the window:
    Code :
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    buffer = SDL_SetVideoMode(width, height, myBpp, SDL_OPENGL | SDL_RESIZABLE); // buffer = SDL_Surface

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    302
    Quote Originally Posted by BlueByte View Post

    Some times when I 'save' a kid, or when I place a stone, only a part of the screen gets updated/rendered (the part is a square ~1/4 of the screen).
    My first guess is that the glViewport call didn't get the right parameters (or you didn't call it at all), you added a scissor test or have a stencil test? If that aren't the causes, a screenshot might be helpful.

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421
    Quote Originally Posted by menzel View Post
    My first guess is that the glViewport call didn't get the right parameters (or you didn't call it at all), you added a scissor test or have a stencil test? If that aren't the causes, a screenshot might be helpful.
    glViewport doesn't clip. Yes, Scissor test does have an effect. Also, make sure you are clearing your depth buffer.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    302
    Clipping might not be the correct term, but if you set glViewport(0,0, wight/2, height/2) you end up with 75% of your window not being rendered, which sound like "the part is a square ~1/4 of the screen".

  5. #5
    Newbie Newbie
    Join Date
    Aug 2012
    Posts
    2
    Thanks so much for your replies! I read them all and tried out all sorts of stuff.
    Finally, it looks like I needed to include the glFinish() function after the rendering.

    I hope I've fixed it, at least. The glitching hasn't been present for a while now, after using glFinish()

  6. #6
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421
    Sounds like you are using a single buffered context. Use double buffered.
    http://www.opengl.org/wiki/Common_Mi...sh_and_glFlush
    Last edited by V-man; 09-01-2012 at 05:08 AM.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •