PDA

View Full Version : Only parts of the screen gets updated



BlueByte
08-30-2012, 07:32 PM
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:


SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
buffer = SDL_SetVideoMode(width, height, myBpp, SDL_OPENGL | SDL_RESIZABLE); // buffer = SDL_Surface

menzel
08-31-2012, 01:22 AM
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.

V-man
08-31-2012, 04:32 AM
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.

menzel
08-31-2012, 04:56 AM
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".

BlueByte
08-31-2012, 08:40 AM
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()

V-man
09-01-2012, 05:02 AM
Sounds like you are using a single buffered context. Use double buffered.
http://www.opengl.org/wiki/Common_Mistakes#glFinish_and_glFlush