PDA

View Full Version : writing to the framebuffer



seelofo
08-29-2010, 01:22 PM
Hey guys,

i have a problem with writing both RGBA and Depth info to the framebuffer.

i successfully filled an array with the Color info and another with the depth info using
glreadpixels(0,0,width,height,GL_RGBA,GL_UNSIGNED_ INT_8_8_8_8,&somebuffer);
glreadpixels(0,0,width,height,GL_DEPTH_COMPONENT,G L_FLOAT,&someotherbuffer);

what i want to do is write them to a cleared framebuffer. so i used gldrawpixels like this:

for the color:
glWindowPos2i(0,0);
gldrawpixels(width,height,GL_RGBA,GL_UNSIGNED_INT_ 8_8_8_8,&somebuffer);

and for the depth:
glWindowPos2i(0,0);
gldrawpixels(width,height,GL_DEPTH_COMPONENT,GL_FL OAT,&someotherbuffer);

when i call gldrawpixels for the color only it works perfectly fine, but with the two of them the image gets all green ..... is there something i'm doing wrong....?

i avoided glrasterpos because i didn't want anything to do with the current transformation. i just wanted to clear the buffer and just fill it with the data i already saved.

thanks in advance.

arekkusu
08-29-2010, 01:50 PM
As per the DrawPixels documentation:

1) COLOR groups will pull the depth value from the current raster position
2) DEPTH groups will pull the color value from the current raster position

If you don't want COLOR DrawPixels to modify the depth buffer, then disable depth testing or depthmask.

If you don't want DEPTH DrawPixels to modify the color buffer, then disable colormask. Note that you must have depth testing enabled in order to modify the depth buffer at all, so you probably also want to set DepthFunc to ALWAYS.

seelofo
09-01-2010, 08:18 AM
Thanks, i'll try that.