Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Output Screen To BMPs


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Bretttido   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 October 2001 - 09:57 AM

I''m trying to figure out how to output the rendered image produced from my openGL program into a Bitmap file. If anyone knows of a good way to do this that doesn''t cut the framerate down to something like 0.1 fps, please let me know. I know how to write a bitmap file, but mainly all I need is how to access a pointer to the final image data (or something along those lines)

Sponsor:

#2 mkaltner   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 October 2001 - 10:27 AM

unsigned char* imageData = malloc(width*height*3);
memset(imageData, 0, width*height*3);
glReadPixels(0, 0, width-1, height-1, GL_RGB, GL_UNSIGNED_BYTE, imageData);

// write bitmap file here

free(imageData);

- Mike

Edited by - mkaltner on October 17, 2001 5:28:47 PM

#3 Bretttido   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 October 2001 - 10:39 AM

Exactly what i was looking for, thanks. I''ll try that out.

#4 Bretttido   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 November 2001 - 12:40 PM

By the way, the function should read:

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

as the third and fourth parameters define the actual width and hieght of the region to be read from, as opposed to the right/top bounds.

Edited by - Bretttido on November 7, 2001 7:40:57 PM

#5 Bretttido   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 November 2001 - 12:53 PM

Well, it looks like a silly WindowsXP error has resulted in me trying to fix a bug with creating my bitmap that never even existed. I was using the details-panel on the left of a window that displays the thumbnail of the bitmap (a lot quicker than openning up photoshop). And for some reason, the background color of what was rendered wasn''t being displayed at all. After hours of pulling out my hair, I finally decided to open up the bitmap in photoshop... and behold, the background color was there all along. Looks like the thumbnail preview attempts to figure out the background color and set it to white? Okay... POSSIBLY a useful feature if you like to see things with a different background then they were intended for =P; but look at this, I change the size of the picture from 300*200 to 296*200.. and boom, the background is displayed.

After tons of experiments, it looks like the thumbnail tests if the top right corner can be "paint-bucket-filled", and if a certain percent of the image is filled, it turns that to white. And oddly, the paint bucket fill-size seems to be 2 pixels. This is all just my speculation from a few crude experiments, so don''t quote me on it.

Anyone know what''s going on with this wacked-out thumbnail?



#6 outRider   Members   -  Reputation: 852

Like
Likes
Like

Posted 07 November 2001 - 03:59 PM

Are you sure you filled out the bitmap header properly? Some readers are particular about the details in the header.

------------
- outRider -

#7 Bretttido   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 November 2001 - 05:37 PM

Yes, the header is all correct. In fact, I''ve tried creating a bitmap from scratch with photoshop and see the same results.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS