Hi,
It seems that when using a PBO with glDrawPixels, the latter ignores the format that I specify. First, I create the PBO:
glGenBuffersARB( 1, &PBO_ );
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER, PBO_ );
glBufferDataARB( GL_PIXEL_UNPACK_BUFFER, 256*256*4*sizeof(GLubyte), NULL, GL_DYNAMIC_DRAW );
GLubyte* t = (GLubyte*) glMapBufferARB( GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY );
for ( int i=0; i<256*256; i++ ) {
t[i*4+0] = i % 256;
t[i*4+1] = 0;
t[i*4+2] = i % 256;
}
glUnmapBufferARB( GL_PIXEL_UNPACK_BUFFER );
I know that I’m not filling in every fourth byte, but that shouldn’t matter. Now, I draw like this:
glDrawPixels( 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, 0 );
This seems to give the expected result: A purple gradient. However, these two other calls result in the same purple gradient, which I don’t expect:
glDrawPixels( 256, 256, GL_BGRA, GL_UNSIGNED_BYTE, 0 );
glDrawPixels( 256, 256, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0 );
It is my understanding that, with GL_PIXEL_UNPACK_BUFFER, glDrawPixels looks into the PBO for its source data. I still expect it to treat that data as it normally does. Where did I go wrong?
Best,
Koen