Archived

This topic is now archived and is closed to further replies.

TheMummy

glReadPixels

Recommended Posts

Hi there, I am currently writing a litte tool that reads wgl bitmap fonts and writes them into a file ... to get platform independent fonts. At first I put every letter from 32 - 255 into one frame to get the maximum size of the font. So I call glReadPixels the first time and check the size. Then I create a buffer and open an output file. After that I render every letter and read it with glReadPixels but during this call to glReadPixels the porgram always crashes... I commented the line and the access violation is gone Whats wrong ? Edited by - TheMummy on November 18, 2001 5:04:27 PM

Share this post


Link to post
Share on other sites
My guess would be that you''ve not allocated your pixel array (last parameter to glReadPixels) or that it has the wrong size.

Share this post


Link to post
Share on other sites
make sure your read buffer is set to the back buffer (assuming double buffering). make sure your pixel store settings are set correctly and make sure you allocate enough memory to store the amount of ascii characters you need. make sure the file is open and set for writing.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
quote:
Original post by jenova
make sure your read buffer is set to the back buffer (assuming double buffering) ...


errhm so do you mean I have to call glReadPixels after switching the buffers or right before ???

Render Frame
SwitchBuffer
glReadPixels --- The way I set it

or

Render Frame
glReadPixels
SwitchBuffer

Share this post


Link to post
Share on other sites
well, i meant that you need to set the correct read buffer. i.e. if you are going to draw the scene first, then use:

"glReadBuffer(GL_FRONT);".

also the default "glPixelStore" settings, might not be what you want.

and the only other thing is to allocate enough memory for storing the pixel data. you might want to create a static array for testing purposes that''s the size of the screen.

i.e. "char bitmap[640][480][4];" // 640x480, 32-bit color.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
Yes thanks you both were right !
I didn''t alocate enough memory !! I read w*h pixels and alcoated memory for (w-1)*(h-1) pixels ........
So I can continue now ...

Share this post


Link to post
Share on other sites