Horde3D

Next-Generation Graphics Engine
It is currently 24.11.2024, 20:04

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Screenshot function
PostPosted: 19.04.2010, 11:38 
Offline

Joined: 21.10.2009, 16:25
Posts: 7
Dear all,

I needed to write out frame-by-frame images from an animation as rendered by Horde, so I've added a simple screenshot functionality to the engine. I realize that this would be trivial to implement in any application, but I found it convenient to realize it as a "h3dutScreenshot()" function.

Would there be any interest in the code? If so, I could of course post it. Unfortunately, it does introduce a new dependency - I use libjpeg-turbo to compress the framebuffer image before writing to file.

Karsten


Top
 Profile  
Reply with quote  
 Post subject: Re: Screenshot function
PostPosted: 19.04.2010, 13:12 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
I guess rewriting your screenshot function to use TGA (so no need for a dependency) would be trivial, so posting it may be helpful for others in all cases, even it is currently used with jpeg.


Top
 Profile  
Reply with quote  
 Post subject: Re: Screenshot function
PostPosted: 19.04.2010, 14:14 
Offline

Joined: 21.10.2009, 16:25
Posts: 7
Ok, here is the code. I'm not really familiar with diff and patch, so I hope I didn't make any mistakes... all changes are relative to Beta4. The changes to Horde3d.h and egRendererBase class were made to be able to retrieve the size of the OpenGL window. Horde3DUtils.h and main.cpp contain the actual screenshot code. The changes will compile and link with either the IJG reference libjpeg or with libjpeg-turbo, a much faster alternative.

Using TGA would be trivial indeed, but it wasn't an option for me - I had to be able to write compressed images really fast. Saving a JPG screenshot takes 10-12 ms on my machine, so I can use it to capture longer sequences of real-time interactive stuff.


Attachments:
patches.zip [3.54 KiB]
Downloaded 757 times
Top
 Profile  
Reply with quote  
 Post subject: Re: Screenshot function
PostPosted: 20.04.2010, 00:16 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
karstux wrote:
The changes to Horde3d.h and egRendererBase class were made to be able to retrieve the size of the OpenGL window.

Just as a note, a similar function (h3dGetViewportParams) is available in the trunk.

karstux wrote:
Using TGA would be trivial indeed, but it wasn't an option for me - I had to be able to write compressed images really fast.

Yeah, TGA is too slow for capturing a video, as the disk writes for the raw data are much more expensive than running a compression algorithm.
It would be nice if someone would write an extremely lightweight one-file JPEG compressor one day (with the same philosophy as stbi that we use for image loading) ;)


Top
 Profile  
Reply with quote  
 Post subject: Re: Screenshot function
PostPosted: 15.07.2010, 13:00 
Offline

Joined: 16.05.2009, 12:43
Posts: 207
I used librevel to literally write out a video from the engine. Works pretty well.


Top
 Profile  
Reply with quote  
 Post subject: Re: Screenshot function
PostPosted: 16.07.2010, 02:00 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
marciano wrote:
Yeah, TGA is too slow for capturing a video, as the disk writes for the raw data are much more expensive than running a compression algorithm.

It would be nice if someone would write an extremely lightweight one-file JPEG compressor one day (with the same philosophy as stbi that we use for image loading) ;)
A much cooler option (though considerably more complex to implement), is real-time video compression on the GPU, a la Cameni's technique.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: Screenshot function
PostPosted: 19.07.2010, 21:20 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
swiftcoder wrote:
A much cooler option (though considerably more complex to implement), is real-time video compression on the GPU, a la Cameni's technique.

Indeed a cool idea!

BTW, we now have a TGA screenshot function in Horde3DUtils.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group