Jump to content
  • Advertisement
Sign in to follow this  
kmyadam

OpenGL Capture the output of OpenGl program

This topic is 4931 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

Hi, I am working with OpenGL on Linux. i want the output of the program to be saved as an image file. How is this task done in OpenGL. Should i write a program to redirect the output to an image file or should i use an application software. Please anyone help me in this regard.

Share this post


Link to post
Share on other sites
Advertisement
You can read the current screen (as an array of pixel values) with glReadPixels, and then once you have an array of pixel values you just need to hand it to *insert image saving library*. For example, with SDL, just use the array to create a surface and use SDL_SaveBMP.

Share this post


Link to post
Share on other sites
yaa, i am aware of glReadPixel but i dont know how to save it using SDL, i never used it. can you tell me where can i find some related info

Share this post


Link to post
Share on other sites
Webpage is libsdl.org, check out I think SDL_CreateSurfaceFromRGB, and SDL_SaveBMP which is pretty simple. I can paste my screenshot code when I get home, if you still need it then.

Share this post


Link to post
Share on other sites
I will be greatful to you, if you can post me the sample code of the screen shot code.

Also is SDL a library? should i install in it in my system ? or it comes with the OpenGL package on Linux itself???


Share this post


Link to post
Share on other sites
It's a cross-platform library with a bunch of useful utility stuff, like creating a window, loading images, playing sounds, detecting input, etc, and you can make OpenGL run on top of it (unfortunately, I don't have any good tutorial links handy). I use it as the base code for all of my personal projects :D. You need to download it seperately, if you want to use it.

Alternatively, anything like DevIL, lib[type of image format], or just a set of BMP functions (win32 has them, although I forget what they are called, and XWin probably does too), would work. The BMP format is pretty simple, so you might even be able to just code a quick function to export the pictures. Targa is another easy format to work with.

It's worth noting that if you want to export as a format other than BMP, you'll need to use DevIL (or an equivalent image loading/saving library) or write your own exporter. I'm a big fan of saving as BMP and converting to PNG, so I don't need to touch PNG code.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!