Welcome, Guest! Login | Register
iRenderingEnable(bool); issue to watch out for !
434 Posts

When running a multi-user project as the server, it's a good idea to use "iRenderingEnable(bool);" to reduce the CPU usage by your project by disabling graphics output.

So i created a small script to turn on a sprite ( setup as full screen and black) ( if you just turn off the the engine rendering with out clearing the screen first, you'll end up seeing what ever the graphics buffer last displayed on screen, which i think looks crappy).

So it seemed simple enough to settup....

Not so, took me 2 hours of playing around to figure out the problem.

When you turn off rending, this also disables any graphics commands like iObjectHide or show.

What i had to do was to add a timer delay that starts the timer, applies the graphic command, waits till the timer is done, then turns off the rendering.

bool On = true, KeyDwn = false;
float Timer = 0;

/// OBJ_0 = sprite to display ( black screen to clear / overwrite the buffer )

void Main(){

   // one shot keypress control
   if(!iKeyDown(-1)) KeyDwn = false;

   // keypress to toggle rendering On / Off
   if(iKeyDown(iKeyCode("DIK_F1")) && !KeyDwn){

      // one shot keypress control
      KeyDwn = true;

      // redering control
      On = !On;

      // set timer value to wait
      Timer = 1;

      // toggles sprite show/hide

   // countdown to 0 timer
   if(Timer > 0) Timer -= 0.016667;

   // apply render state when timer is less then 0
   if(Timer < 0){

      // reset timer to 0, waiting for keypress
      Timer = 0;
Created on: 4 months ago
Edited on: 4 months ago
193 Posts

Quote from: TinSoldier

When you turn off rending, this also disables any graphics commands like iObjectHide or show.

Internally, iObjectHide/iObjectShow should only toggle a internal bool value in the object's struct class. Disabling/enabling the show/hide functions if rendering is disabled is useless. Unrelated, but yeah, I gave my opinion.
Created on: 4 months ago
Or use the advanced reply form here...