if (rtt1)
{
ref1node->setVisible(false);
driver->setRenderTarget(rtt1,true,true,SColor(0,0,0,0));
smgr->drawAll();
ref1node->setVisible(true);
driver->setRenderTarget(0);
}
Ok. The above code is what I use for the game I'm making for the render to texture thing. I'm using the camera that's already in use as the one to RTT with. Thats why there's no camera change in the above code. It does tend to run a little slow, though. Therefor, I'd like to limit it to the part of the game when the RTT object is visible, or when the level trigger = 13. So;
if (rtt1 && level1trigger == 13)
{
ref1node->setVisible(false);
driver->setRenderTarget(rtt1,true,true,SColor(0,0,0,0));
smgr->drawAll();
ref1node->setVisible(true);
driver->setRenderTarget(0);
}
But then my scene doesn't animate! Why?
RTT/OpenGL/Speed
Since the only difference between the two code samples above is in the if()-line, it would seem logical that the problem lies there. Either 'level1trigger' never gets the value 13 or it get's it at wrong time. If you use debugger, Watch the 'level1trigger'-variable and see what values it gets and when it gets them. Otherwise #include <iostream>, change the code to:
and watch the console window to see what values are printed out and when.
Code: Select all
if (rtt1)
{
std::cout << level1trigger << std::endl;
ref1node->setVisible(false);
driver->setRenderTarget(rtt1,true,true,SColor(0,0,0,0));
smgr->drawAll();
ref1node->setVisible(true);
driver->setRenderTarget(0);
}
I know level1trigger = 13, it's just that adding "&& level1trigger == 13"
seems to stop the ENTIRE game from animating. adding ANYTHING to the
"if(rtt1)" part of code makes the scene stop animating. However, by itself,
if (rtt1)
{
ref1node->setVisible(false);
driver->setRenderTarget(rtt1,true,true,SColor(0,0,0,0));
smgr->drawAll();
ref1node->setVisible(true);
driver->setRenderTarget(0);
}
works fine.
Whats up with that?
seems to stop the ENTIRE game from animating. adding ANYTHING to the
"if(rtt1)" part of code makes the scene stop animating. However, by itself,
if (rtt1)
{
ref1node->setVisible(false);
driver->setRenderTarget(rtt1,true,true,SColor(0,0,0,0));
smgr->drawAll();
ref1node->setVisible(true);
driver->setRenderTarget(0);
}
works fine.
Whats up with that?
you are using in the rtt loop. Shouldn't that be oustide. Without seeing the rest of your code it would seem that you are only rendering the whole scence when that loop executes
Code: Select all
smgr->drawall();
"RTT object is visible, or when the level trigger = 13"
"(rtt1 && level1trigger == 13)"
I hate to point out the obvious, but your code doesn't match your description.
&& is AND, yet your description says "OR".
If nothing is drawn as expected, then the IF statement is never satisfied. Print out the values of your variables used in the IF to confirm that they do or don't satisfy the clause.
Oh and use a debugger - it's so much easier.
"(rtt1 && level1trigger == 13)"
I hate to point out the obvious, but your code doesn't match your description.
&& is AND, yet your description says "OR".
If nothing is drawn as expected, then the IF statement is never satisfied. Print out the values of your variables used in the IF to confirm that they do or don't satisfy the clause.
Oh and use a debugger - it's so much easier.