using irrlicht in a background application?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
scotchfaster
Posts: 15
Joined: Sun Feb 24, 2008 4:27 am

using irrlicht in a background application?

Post by scotchfaster »

First, I'm very excited to be using Irrlicht. It looks great.

My issue is that I need to use Irrlicht strictly to render to an offscreen buffer. I don't want a window, event handling or anything else.

createDevice and createDeviceEx both seem to want to create windows or go into fullscreen mode. Should I be using something lower-level, or do I need to create a hidden window and use createDeviceEx to render to that?

Any help would be appreciated.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Try using EDT_NULL as driver type.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
scotchfaster
Posts: 15
Joined: Sun Feb 24, 2008 4:27 am

Post by scotchfaster »

CuteAlien wrote:Try using EDT_NULL as driver type.
I saw that, but from the description, it didn't sound like what I'm looking for. It's described as "Null device, useful for applications to run the engine without visualisation. The null device is able to load textures, but does not render and display any graphics."

I do want it to render, and I do want to use hardware acceleration. I just want it to render only into my offscreen buffer.

Any more tips?
TheBeef
Posts: 25
Joined: Wed Feb 20, 2008 4:38 am

Post by TheBeef »

What exactly are you trying to do?

It sounds like you want to do everything that Irrlicht is supposed to, but only to an 'offscreen buffer,' for a 'background application.'
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Try using createDeviceEx and pass it a NULL window handle. That, or integrate the application into a wxWidgets or window form, and set that form to not visible.

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
scotchfaster
Posts: 15
Joined: Sun Feb 24, 2008 4:27 am

Post by scotchfaster »

TheBeef wrote:What exactly are you trying to do?

It sounds like you want to do everything that Irrlicht is supposed to, but only to an 'offscreen buffer,' for a 'background application.'
Yes, exactly right. I just want my application to run invisibly in the background, rendering images to an offscreen buffer. Don't ask me why, this is the requirement.

So I'm stumped. I have tried createDeviceEx using both NULL and a existing window handle. In both cases, Irrlicht created a new window.

I'm also not clear how to render to a bitmap. I can see how to render to a texture, but I hope there's a better way.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You render to a texture and then you render the texture to a file, formatting it correctly so that it's a bmp.

Or you can use the screenshot capability of irrlicht to save a screenshot to a file, that should do the trick i guess, check the API for the function.
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'm not sure if this is possible. AFAIK, both hw drivers require a window to set up the necessary drivers. It would indeed be necessary to pass Irrlicht a window handle which is already set up for the proper driver, and hide that one. Please check example 14 for how to pass the window handle in a way that Irrlicht uses that one instead of creating its own.
scotchfaster
Posts: 15
Joined: Sun Feb 24, 2008 4:27 am

Post by scotchfaster »

Thanks for all of your help.

So I am successfully rendering to a hidden window using a texture as a target, and obtaining the bitmap by calling the texture's Lock and Unlock methods.

This seems like a workable solution. The reason I wasn't thrilled with using a texture was mainly because of the size restriction. I really wanted to use 640 by 480, but am hoping that 512 x 512 will work. That decision is up to the client.

If there's a more flexible and/or more efficient solution, I'd love to hear it - otherwise I'll stick with this approach.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Which driver do you use for the render job? d3d and opengl do handle this stuff a little different, but there are also some bugfixes to come in the next version (opengl and ATI have a problem with FBO support, and d3d is limited to something smaller than the current window). Also, some drivers do support non-POT textures, for which you could check and choose the proper size depending on this (might happen automatically, show us your RTT init code).
scotchfaster
Posts: 15
Joined: Sun Feb 24, 2008 4:27 am

Post by scotchfaster »

hybrid wrote:Which driver do you use for the render job? d3d and opengl do handle this stuff a little different, but there are also some bugfixes to come in the next version (opengl and ATI have a problem with FBO support, and d3d is limited to something smaller than the current window). Also, some drivers do support non-POT textures, for which you could check and choose the proper size depending on this (might happen automatically, show us your RTT init code).
Actually, my solution doesn't work in OpenGL, only in DirectX and the software renderers. This makes me sad, because we will need a Mac version one day.

I am using a power of two (512 x 512) but it may be too big for OpenGL. And yes, I'm initializing the window to be 512 x 512 as well.

The other reason I'm not so psyched about using a texture is that they seem to always be 32 bits per pixel, and I have to convert it down to 24 bits. Not a big deal, but overhead I'd like to avoid.

Any other approaches I could try?
Post Reply