Using glDrawPixels

Hi to all,
it may be sound impossible, but i am having problems
with glDrawPixels() :stuck_out_tongue:

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:

glDrawPixels(640, 480, GL_RGBA, GL_UNSIGNED_BYTE, imageBuffer);

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,

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.

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?!?

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: