PDA

View Full Version : Using glDrawPixels



LucaFr
07-30-2009, 04:25 AM
Hi to all,
it may be sound impossible, but i am having problems
with glDrawPixels() :P

I am using a glut program example made by others (it is
one of the bullet sdk demo examples).
I want to display and image and do rendering on it. If i use, in the glutMoveAndDisplayCallback(), the glDrawPixels in this way:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
glDrawPixels(640, 480, GL_RGBA, GL_UNSIGNED_BYTE, imageBuffer);
glEnable(GL_DEPTH_TEST);
glSwapBuffers();


all works ok! If, instead of calling glSwapBuffers(), i do
some other rendering stuff (like the ones made by the bullet sdk demo), and finally call glSwapBuffers(), i cannot see anything.
The other rendering stuff makes change to (eventually) the projection matrix, to the modelview matrix and render some cubes with shadows and other things.

Where is the problem? Once i call glDrawPixels(), the back buffer should be filled with the right pixels. After this, i don't call any glClear(GL_COLOR_BUFFER_BIT), so i am a bit confused...
Any idea?
Thanks a lot,
Luca

dletozeun
07-30-2009, 06:32 AM
Are you sure that the "other rendering stuff" does not redraw all pixels? You may try to render just one triangle after the DrawPixels call and see if it still happens.

LucaFr
07-30-2009, 07:20 AM
It seems that after glDrawPixels there is a call to glRasterPos3f(0,0,0) is the problem.
If i comment this call, all works ok.

Maybe when i make the second call to glDrawPixels() (for the second frame), the previous call to glRasterPos3f create problems... but what i don't understand is this: isn't (0,0,0,1) the default value for the raster position?!?

dletozeun
08-02-2009, 08:25 AM
glRasterPos3f(0,0,0) alone does not make much sense, remember that the specified object position will be transformed by the current modelview and projection matrices. So if you don't set projection matrix correctly it may lead to unexpected results.

See the spec if it is not already done:
http://www.opengl.org/sdk/docs/man/xhtml/glRasterPos.xml