#ifndef GRAPHICSIMMEDIATEDEFERRED_H
#define GRAPHICSIMMEDIATEDEFERRED_H

#include <gobj.h>

/*!
\brief Display a scene where some geometry can be pre 
       rendered.

There are two types of graphics, pre rendered graphics
 and immediate graphics.  The client pushes gobjs to 
 graphicsDeferred and graphicsImmediate repsectively.

Motivation comes when graphics changes infrequently
 and when rendering it immediately is costly.


By having two graphics containers, one for immediate
 graphics which is evaluated every time draw() is called,
 and another for infrequently changing graphics which
 when update is called draw() is called.  

Use:

Push gobj's constructed with new onto 
 graphicsDeferred and graphicsImmediate as by default 
 memory management is enabled.

gobj's in the deferred container should write to
 the global graphics stream with gobjpush(new gobj..).
 Because when graphicsDeferred.draw() is called the
 graphics needs to be created.




For example immediate graphics can use direct OpenGL calls.
 Whereas deferred could push graphics constructed with gobj's
 which wrap the OpenGL calls. 

Deferred graphics is simply graphics that is less frequently
 updated. 
*/
class graphicsImmediateDeferred : public gobj
{
public:

  /** The containers by default delete their contents. */
  graphicsImmediateDeferred();

  /** The deferred graphics is written here on update. */ 
  gobjContainer gdynamic;

  /** Drawn when update() called. */
  gobjContainer graphicsDeferred;
  /** Always draw what is in this container. */
  gobjContainer graphicsImmediate;

  /** Can swap the draw order. */
  bool drawDeferredFirst;

  /** Draw to the global graphics stream. */
  void draw();

  /** When the static geometry changes the scene is recalculated. */
  virtual void update();

};


#endif


