Does double buffer work?

Started by
8 comments, last by Gizmo42 21 years, 8 months ago
Hello, I am new to OpenGl, and I just wrote OpenGL tetris. It runs in 800x600 (fullscreen), but I have the following problem. Although I have 100+ fps, you can clearly see redrawing of the screen. (in fact 640x480 is the same issue) It is strange, however, because I am trying to use doublebuffer via nehe''s code: DrawGLScene(); SwapBuffers(hDC); Is any possibility for example for retrace waiting or something like that, or am I missing something obvious here. Thanks a lot for answers. Jan.
Advertisement
and one more thing. I turned off VSync and
it seems to have 350+ frames.
for interested people, try
http://www.volny.cz/kavani/alfaverz.rar
It is just work version of my tetris, so take it easy :-) No criticising yet, please. Just try to help me to spot my mistake.

Thanks a lot
Jan
Nice game. I didnt have any problems though.

Do you have the latest drivers for your graphics card?
Thanks,
I have nVidia GeForce4 MX-420 with latest detonators,
I tried it also on some ATI Cards and problem occurs also there.

Note, that it isn''t visible on the first look. You have to watch
the falling piece, because it''s the only one where I am able to spot the problem. Somehow it looks like it''s leaving trace of some kind behind. And also it starts from the second half of the screen.

Jan
if you watch the rotating one you see the same..
my questions:
what sort of depthtest do you do?
do you perform some sort of backfaceculling?

could you post the code for:
drawing the cubes
setting the base settings (depthbuffer/backfaceculling and such)

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Thanks a lot for your reply.
It seems I don''t know a lot of things.

Well, actually what I am doing here is following:
I have a matrix int field[24][12].
I''ve created a list
tetris_block = glGenLists(1);
glNewList(tetris_block,GL_COMPILE);
glBegin(GL_QUADS);

... Definition of simple Cube follows ...
glEnd();
glEndList();

Engine actually works only with 2d matrix, where it sets
numbers according to game. (0 - no cube in this place,
1 - static cube in this place, 2 - active piece I am
"driving" now) So rotations and so is done thus. The whole
drawing is done by walking through this matrix and calling
glCallList(tetris_block) on positions:
1

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
...
...
for (loopy = 0;loopy < PLAYFIELDY;loopy++) {
for (loopx = 0;loopx < 12;loopx++) {
if (field[loopy][loopx] > 0) {
glColor3f(1.0f,1.0f,1.0f);
glLoadIdentity();
glTranslatef(loopx*0.6+XBORDER,YTOP-0.6*loopy,-20.0f);
glCallList(tetris_block);
}
}
}

where XBORDER is leftomost position on SCREEN.
And that''s about it.

Thanks again
Jan
And this could be possible interesting too.

glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

Jan
For those interested,
new version is at www.volny.cz/kavani/alfaverz.rar

however problem with flickering still occurs :-(

Jan
All V''Sync does is limit the number of FPS to that of the refresh rate on your monitor. It can be a cause of some problems. Common ones are tearing in the graphics, etc...

Make sure you aren''t updating the screen more then once, or drawing an item more then once.



-AfroFire
AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
This is however not my situation.
First idea that occurs to me was, that I am
for some reason drawing at first screen without
shape and after that with it. I double checked, and
In each iteration moving shape is present. I also
tried to change different face cullings, and only
effect I achieved was partially cubes (eq. without back
face aso.)

Jan

This topic is closed to new replies.

Advertisement