Archived

This topic is now archived and is closed to further replies.

Does double buffer work?

This topic is 5615 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites