Hi all -
What I need to do is make a thumbnail of an opengl window image for when the window is not the foregroud window. I have it being rendered to the back buffer because if I do a SwapBuffers the image I want is there and in the bottom left corner and in the size I need. But glReadPixels just does not seem to work.
I am not concerned about performance issues at this time. When the window is not the foreground window the image will be fairly static. I just need to put a thumbnail up in a different window.
What's not working when you try using glReadPixels? Can you post some code?
It just comes out gray. I can post the source code tomorrow. Sorry about the cross post.
Heres the relevant code snippets ...
void C3DRender::RenderToBitmap(void *bits)
// without FBO
// render to the backbuffer and copy the backbuffer to a texture
// clear buffer
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_PIXEL_MODE_BIT); // for GL_DRAW_BUFFER and GL_READ_BUFFER
// draw a rotating teapot at the origin
// Draw here
// copy the frame buffer pixels to our bitmap
glReadPixels(0, 0, 280, 210, GL_RGBA, GL_UNSIGNED_BYTE, bits);
GLenum error = glGetError();
// copy the framebuffer pixels to a texture
glPopAttrib(); // GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
It gets called from this code snippet ...
void *bits = malloc(280 * 210 * 4);
small_bitmap = CreateBitmap(280, 210, 1, 24, bits);
Last edited by NewOpenGlProgrammer; 09-05-2012 at 09:54 AM.
Tags for this Thread