RTT/OpenGL/Speed

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
Anteater

RTT/OpenGL/Speed

Post by Anteater »

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?
Elise
Posts: 48
Joined: Tue Jul 19, 2005 6:30 am
Contact:

Post by Elise »

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:

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); 
}
and watch the console window to see what values are printed out and when.
Anteater

Post by Anteater »

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?
Masdus
Posts: 186
Joined: Tue Aug 26, 2003 1:13 pm
Location: Australia

Post by Masdus »

you are using

Code: Select all

smgr->drawall();
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
Anteater

Post by Anteater »

I'm also drawAll()ing at the place in the regular code, too. (See the RTT tutorial).
Fred

Post by Fred »

"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.
Anteater

Post by Anteater »

RTT1 object IS visible when level1trigger == 13, so "or" in that sentance doesn't indicate that it is an or statement.
Post Reply