00001 00009 #ifndef DRAWMGR_H 00010 #define DRAWMGR_H 00011 00012 #include "streamwrap.H" 00013 // Gluebase includes 00014 #define OUTSIDE_GLUE_CORE 00015 #include <std/hash.H> 00016 #include <std/strings.H> 00017 #include <mlib/points.H> 00018 00019 #include "glwrap.H" 00020 #include "SelectMgr.H" 00021 00022 class DrawObj; 00023 class ScreenGrab; 00024 class ScreenGrabInt; 00025 class Texture; 00026 00027 class DRAWMGR 00028 { 00029 public: 00030 00031 // add/remove objects from the manager 00032 static void registerObj(DrawObj* o); 00033 static void register2DObj(DrawObj* o); 00034 static void removeObj(DrawObj* o, bool display=true); 00035 00036 // access registered objects 00037 static int numObjects() { 00038 return _objects.num() + _2dObjects.num(); 00039 } 00040 00041 00042 00043 static DrawObj* getObject(const int num) { 00044 if (num < _objects.num()) 00045 return _objects[num]; 00046 else if (num < (_objects.num() + _2dObjects.num())) 00047 return _2dObjects[num - _objects.num()]; 00048 else 00049 return NULL; 00050 } 00051 00052 00053 // draws a single DrawObj* - generally called automatically for all 00054 // registered objects from within DRAWMGR::draw() 00055 // but can call it from within your own DrawObj's draw method to draw 00056 // a second DrawObj that you want to manage on your own. 00057 static void drawObject(DrawObj* const d); 00058 00059 // called by a GL program to do initialization and drawing 00060 static void contextInit(); 00061 static void draw(int pass=0); 00062 static void frameDone(); 00063 00064 // frame/time management 00065 static double elapsedTime(); 00066 static double timeSinceLastFrame(); 00067 static long frameCount() { return _frameCount; } 00068 00069 static void offsetTime(const double offset) { _startTime -= offset; } 00070 00071 // access to screengrab class 00072 static ScreenGrab* screenGrab() { return _screenGrab; } 00073 00074 static void drawPaperBackground(); 00075 00076 static float paperXOffset() { return _paperXOffset; } 00077 static float paperYOffset() { return _paperYOffset; } 00078 00079 static void setPaperXOffset(float o) { _paperXOffset = o; } 00080 static void setPaperYOffset(float o) { _paperYOffset = o; } 00081 00082 static float paperRepeat() { return _paperRepeat; } 00083 static void setPaperRepeat(float r) { _paperRepeat = r; } 00084 00085 protected: 00086 static GLenum getLight(const int i); 00087 00088 // 3D objects 00089 static ARRAY<DrawObj*> _objects; 00090 00091 // 2D screen space objects 00092 static ARRAY<DrawObj*> _2dObjects; 00093 00094 // time values 00095 static double _startTime; 00096 static double _lastFrameTime; 00097 00098 // frame count 00099 static long _frameCount; 00100 00101 // facility for saving views as image files 00102 static ScreenGrab* _screenGrab; 00103 static ScreenGrabInt* _screenGrabInt; 00104 00105 static int _useDLs; 00106 00107 // for rendering a paper texture as the screen background 00108 static Texture *_paperTexture; 00109 static float _paperRepeat; 00110 static float _paperXOffset; 00111 static float _paperYOffset; 00115 static int _paperPass; 00116 }; 00117 00118 #endif