Greetings friends.
I'm experienced with C++ and Irrlicht, but I've hit a stumbling block I'm hoping someone can direct me out of.
I want to render a scene with Irrlicht, but I don't want to display it directly; I just want to render the frame into eg a char array.
I don't expect the OpenGL or DirectX renderers will particularly want to do this. However, I only need low resolution - 320 x 240 max (don't even ask what the project is ) - so I figure all I need do is tweak one of the software renderers to render into an array.
I've been having a look through the source, and I think once I find the right method to amend it should be fairly straight forward, but my eyes are glazing... I could really use a suggestion on the particular method I should look into editing/replacing.
Many thanks for any help you can offer.
Rendering to a array
-
- Posts: 13
- Joined: Tue Jun 09, 2009 11:53 am
- Location: Wales, UK
- Contact:
Maybe the "Render to Texture" tutorial on the Irrlicht sourceforge page might help you. I think it just renders to a buffer within a texture.
Dustbin::Games on the web: https://www.dustbin-online.de/
Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
-
- Posts: 13
- Joined: Tue Jun 09, 2009 11:53 am
- Location: Wales, UK
- Contact:
-
- Posts: 13
- Joined: Tue Jun 09, 2009 11:53 am
- Location: Wales, UK
- Contact:
Awesome -- works great. Thanks for the pointer Brainsaw, wheel reinvention avoided.
Trivial use case example rendering to a bitmap file:
Trivial use case example rendering to a bitmap file:
Code: Select all
// Create render target
if (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET)) exit(1);
video::ITexture* rt = driver->addRenderTargetTexture(core::dimension2d<s32>(256,256), "RTT1");
driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));
// Render once, testing
device->run();
driver->beginScene(true, true, 0);
driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255)); // Set + clear RTT
smgr->drawAll();
driver->endScene();
// Create image from RTT
video::IImage* image = driver->createImageFromData (
rt->getColorFormat(),
rt->getSize(),
rt->lock(),
true
);
rt->unlock();
// Save it
driver->writeImageToFile(image,"look_it_works.bmp");
image->drop();