I have implemented iterators , i know this quesion is a stupid one but though i m in a little bit of confussion .
Ques: Where in the main loop i must call the update function where all the iterators are started.
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
}
Should i call it
1.after driver->endscene();
2.between beginscene and endscene
3.Before begin scene
4.Or drop the idea calling the update function in main loop
Plz tell me the better option to go for for better efficiancy
thanx
updating an entity
Most likely, computation and objects update
should be done after the rendering.
The best place for update is BEFORE or AFTER
the the rendering routine.
"Even irrlicht engine do the internal updates and
other computation before and after DrawAll routine
by calling OnPreRender() first before rendering
and OnPostRender() right after everything has been drawn."
I will never attempt to do some object updates while
in rendering mode.
I know theres a much better way, but here's how i've done mine.
while(device->run())
{
//
UpdateCustomMenu();
UpdateAllObjects();
//
RenderAll(); // << this is were i call beginScene and endScene
//
UpdateInput();
UpdateNet();
//
UpdateMisc();
//
}
should be done after the rendering.
The best place for update is BEFORE or AFTER
the the rendering routine.
"Even irrlicht engine do the internal updates and
other computation before and after DrawAll routine
by calling OnPreRender() first before rendering
and OnPostRender() right after everything has been drawn."
I will never attempt to do some object updates while
in rendering mode.
I know theres a much better way, but here's how i've done mine.
while(device->run())
{
//
UpdateCustomMenu();
UpdateAllObjects();
//
RenderAll(); // << this is were i call beginScene and endScene
//
UpdateInput();
UpdateNet();
//
UpdateMisc();
//
}
u can even try out overriding the OnPreRender() and OnPostRender() methods according to ur needs. Try making ur objcet class as a child of ISceneNode and define the methods . OnPostRender has one special feature that it has its argument as the time and u can get the time tick for ur better calculations. It hardly matters if u call upon updates before or after the render , it all depends on u and ur critical sections. If there is any critical calculation on an object which must be there before its rendering then call before else do afterwards.
Picking up on what kushagra said, I would keep the game and render objects seperate, which is the opposite, ie don't subclass ISceneNode.
Game objects/structures shouldn't need to know anything about how it's rendered, but hold a pointer to it's on screen representation instead.
________
Dc medical marijuana dispensary
Game objects/structures shouldn't need to know anything about how it's rendered, but hold a pointer to it's on screen representation instead.
________
Dc medical marijuana dispensary
Last edited by area51 on Thu Feb 24, 2011 11:54 pm, edited 1 time in total.