The Render function requires multiple executions before it gets called only once ( this is used for input data collection ). I could force call the Render function every time, and it will not break the code but it will end up being very slow.
Delayed update is being called many times outside the canvas ( not all the time ), the time or sequence of those calls can't be known.
Assuming I can't control the speed of the frame rate for the OnFrame function.
Is there a better way, without using timers or events, to repaint my canvas after the data colleciton had been complete ?
Here is what i got so far:
// called in many places
canvas.InputData( x );
// ---------------------- Canvas class -------------------
data = new Dictionary();
InputData( key, x )
{
data[ key ] = x;
Delayed_Render();
}
_counter = 0;
_request = false;
_delayed = false;
_complete = false;
Delayed_Render()
{
if( _request || ! _complete ) return;
_request = true;
_complete = false;
}
override OnFrame()
{
if( ++ _counter < 10 ) return;
_counter = 0;
if( _request )
{
_request = false;
_delayed = true;
Render();
}
}
override OnResize()
{
Render();
}
Render()
{
// ....................................
// code to render canvas using the data
// ....................................
if( _delayed )
{
_complete = true;
_delayed = false;
}
}
Aucun commentaire:
Enregistrer un commentaire