Render to texture

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
_Dum0nde
Posts: 24
Joined: Thu Mar 17, 2005 3:26 pm

Render to texture

Post by _Dum0nde »

Hello,

I want to do something pretty simple needing RTT. I want to draw 1 letter and make it a texture and then render that letter with draw2DImage();

Based on the tutorial, I came out with this code. Unfortunately, it just renders a blank square...

Code: Select all

video::ITexture *Test::GetLetterTexture(std::wstring letter) {
	if (hub->irr_driver()->queryFeature(video::EVDF_RENDER_TO_TARGET)) {
		video::ITexture *renderTexture = hub->irr_driver()->createRenderTargetTexture(core::dimension2d<s32>(128, 128));
		hub->irr_driver()->setRenderTarget(renderTexture, true, true, video::SColor(255, 255, 255, 255));
		hub->irr_scenemgr()->drawAll();
		Util::fonts.fontTest->draw(question.c_str(), core::rect<s32>(0, 0, 128, 128), video::SColor(255, 0, 0, 0));
		hub->irr_driver()->setRenderTarget(0);
		return renderTexture;
	}

	return 0;
}
Do I need a camera to do RTT?
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

Do I need a camera to do RTT?
Yes.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
Guest

Post by Guest »

render_to_texture renders a view into a texture, so yes you will need a camera. but why dont you just paint a letter in gimp/paint and save that as a texture?
_Dum0nde
Posts: 24
Joined: Thu Mar 17, 2005 3:26 pm

Post by _Dum0nde »

I can't do that because that's the easy way ;)

I want the application to handle everything by itself. I'm working with Japanese kanji, I don't want to continually have to rely and manual input! (there's a lot of kanji!)

So, back on the problem. I added a camera, but still, it only renders a blank texture...

Code: Select all

video::ITexture *Test::GetQuestionEnTextures(std::wstring question) {
	if (hub->irr_driver()->queryFeature(video::EVDF_RENDER_TO_TARGET)) {
		video::ITexture *renderTexture = hub->irr_driver()->createRenderTargetTexture(core::dimension2d<s32>(128, 128));
		scene::ICameraSceneNode *camera = hub->irr_scenemgr()->addCameraSceneNode(0, core::vector3df(10,10,-80), core::vector3df(-10,10,-100));
		scene::ICameraSceneNode *lastCam = hub->irr_scenemgr()->getActiveCamera();
		hub->irr_scenemgr()->setActiveCamera(camera);

		hub->irr_driver()->setRenderTarget(renderTexture, true, true, video::SColor(255, 255, 255, 255));
		//hub->irr_scenemgr()->drawAll();
		Util::fonts.fontTest->draw(question.c_str(), core::rect<s32>(0, 0, 128, 128), video::SColor(255, 0, 0, 0));
		
		hub->irr_driver()->setRenderTarget(0);
		hub->irr_scenemgr()->setActiveCamera(lastCam);

		return renderTexture;
	}

	return 0;
}
Any ideas?
Post Reply