Jump to content
  • Advertisement
Sign in to follow this  
Mystery

OpenGL How to save a scene in opengl

This topic is 5067 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to save an object that I have created in opengl to some image file excluding the background? If so, how should I go about doing it. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

The first thing is to render your object alone (without drawing the background).

Render it to the screen then use glcopypixel or something like that to copy the screen pixel to an array for example. And then you can store it in a raw image or in bmp if you write the headings.

see this link

hope that helps

neyna.

Share this post


Link to post
Share on other sites
What you need is glReadPixels. It takes the contents of the frame buffer, and saves it to a location you specify. More information here and here.

As to excluding the background, you could use a stencil test. I haven't used stencil testing for a while (since I did stencil shadowing), so I can't remember off the top of my head exactly how you'd do it, but that's the only way I can think of to solve your problem. Unless you render the object separately from rest of the environment, that is...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!