PDA

View Full Version : Screen Capture



azant
08-08-2008, 02:23 PM
I am trying to do a screen capture and write it to a jpeg file. My understanding is that the framebuffer will contain whats being rendered to the display and using PixelRead should grab whats in the framebuffer. What I am seeing is just a black image rather than whats rendered on the display.


GLubyte* pixelBuffer = new GLubyte[sizeof(GLubyte)*width*height*3];

glReadBuffer(GL_FRONT);

GLint ReadBuffer;
glGetIntegerv(GL_READ_BUFFER,&ReadBuffer);
glPixelStorei(GL_READ_BUFFER,GL_RGB);

GLint PackAlignment;
glGetIntegerv(GL_PACK_ALIGNMENT,&PackAlignment);
glPixelStorei(GL_PACK_ALIGNMENT,1);

glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixelBuffer);



Any ideas on what I am doing wrong? I am developing on a Dell Optiplex GX620 with an Intel 82945G/GZ graphics controller.

OpenGL Driver Info
==================
Vendor: Tungsten Graphics, Inc
Version: 1.4 Mesa 7.1 rc1
Renderer: Mesa DRI Intel(R) 945G 20061102 x86/MMX/SSE2

Color Bits(R,G,B,A): (8, 8, 8, 8)
Depth Bits: 24
Stencil Bits: 8

azant

roswell
08-08-2008, 02:52 PM
The problem could be elsewhere, but if you want to debug it, just fill your buffer with some color, like white, to
see it it's actually being overwritten. Also make sure your writing functions are working. Fill it with some known
color to see if it's actually being written correctly.

memset( pixelBuffer, 0xFF, sizeof(GLubyte)*width*height*3 );

azant
08-11-2008, 10:14 AM
As you suggested, I filled my pixelbuffer with another color prior to the glReadPixels call, but still get the same result. Likewise,the writing function seem to be working correctly. I initialized this to a different color which was overwritten by the initialized color in pixelBuffer. So it seems pixelBuffer is not reading the framebuffer for some reason.

My video card does not support GL_ARB_pixel_buffer_objects, which should not matter for glPixelRead right? Or maybe my graphics card does not support openGL also? Guess I will try to find a system which I know supports openGL and run my code on that. Thanks for you suggestions.

azant

dletozeun
08-11-2008, 01:48 PM
oops bad thread... :D

dletozeun
08-11-2008, 01:57 PM
Hem,... I have a suggestion now:

Try in a first step to copy to framebuffer to a texture with glCopyTexImage2D and then clear the framebuffer and draw the last texture on a quad. This way you could check if your allocations, arrays, file writing,... are wrong or not.