I am having trouble with OpenGL GLSL and Render Targets. In my case, a GLSL shader which works fine when we do a normal rendering doesn't work anymore when we render the same scene to a RenderTargetTexture. To test, I added the following code to the Irrlicht Shader tutorial (using the shaders provided in the tutorial) to create a simple RTT:
In main()
Code: Select all
video::ITexture* rt = 0;
//make the render target texture to draw the view window
rt = driver->addRenderTargetTexture(core::dimension2d<u32>(128,128), "RTT1",irr::video::ECF_A8R8G8B8);
device->getGUIEnvironment()->addImage(
rt,
core::position2d<s32>(0,50));
Code: Select all
if (rt)
{
// draw scene into render target
// set render target texture
driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));
smgr->drawAll();
// set back old render target
// The buffer might have been distorted, so clear it
driver->setRenderTarget(0, true, true, 0);
}
BUT, If I run with low level shaders instead of GLSL (choosing not to run high level shaders), then both cubes render correctly in the RTT view.
Any thoughts? I'm new to shaders and I would rather try to write them in GLSL than in the shader assembly language, for obvious reasons. I'm using OpenGL and GLSL 4.4, and also Cg shaders aren't supported. I'm using RTT because the 3d view is only a portion of the GUI in my game.
Thanks