00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _VRJ_GL_DRAW_MANAGER_H_
00034 #define _VRJ_GL_DRAW_MANAGER_H_
00035
00036 #include <vrj/vrjConfig.h>
00037 #include <vector>
00038
00039 #include <vpr/vpr.h>
00040
00041 #include <vpr/Sync/Semaphore.h>
00042 #include <vpr/Util/Singleton.h>
00043 #include <vpr/Thread/Thread.h>
00044 #include <vpr/Thread/TSObjectProxy.h>
00045
00046 #ifdef VPR_OS_Darwin
00047 # include <OpenGL/gl.h>
00048 # include <OpenGL/glu.h>
00049 #else
00050 # include <GL/gl.h>
00051 # include <GL/glu.h>
00052 #endif
00053
00054 #include <jccl/Config/ConfigElementPtr.h>
00055
00056 #include <vrj/Draw/DrawManager.h>
00057
00058 #include <vrj/Draw/OGL/GlWindow.h>
00059 #include <vrj/Draw/OGL/GlPipe.h>
00060 #include <vrj/Draw/OGL/GlUserData.h>
00061
00062 namespace vrj
00063 {
00064 class GlApp;
00065 class SimViewport;
00066
00085 class VJ_CLASS_API GlDrawManager : public DrawManager
00086 {
00087 public:
00088 friend class GlPipe;
00089 friend class GlContextDataBase;
00090
00095
00096
00098 virtual void start();
00099
00101 virtual void draw();
00102
00108 virtual void sync();
00109
00111 void main(void* nullParam);
00112
00114 virtual void initAPI();
00115
00124 virtual void addDisplay(Display* disp);
00125
00127 virtual void removeDisplay(Display* disp);
00128
00130 virtual void closeAPI();
00131
00133 virtual void outStream(std::ostream& out);
00134
00136 void drawAllPipes();
00137
00139 virtual void setApp(App* _app);
00140
00142 GlApp* getApp();
00143
00144
00145
00146 public:
00153 virtual bool configAdd(jccl::ConfigElementPtr element);
00154
00161 virtual bool configRemove(jccl::ConfigElementPtr element);
00162
00168 virtual bool configCanHandle(jccl::ConfigElementPtr element);
00169
00170
00171 public:
00178 GlUserData* currentUserData()
00179 { return &(*mUserData); }
00180
00186 int getCurrentContext()
00187 { return (*mContextId); }
00188
00189 protected:
00195 GlWindow* getGLWindow();
00196
00197 void setCurrentContext(int val)
00198 { (*mContextId) = val; }
00199
00201 void dirtyAllWindows();
00202
00204 bool isValidWindow(GlWindow* win);
00205
00206
00207 protected:
00208
00209 int numPipes;
00211
00212 GlApp* mApp;
00213 std::vector<GlWindow*> mWins;
00214 std::vector<GlPipe*> pipes;
00216
00217 vpr::TSObjectProxy<int> mContextId;
00218 vpr::TSObjectProxy<GlUserData> mUserData;
00220
00221 vpr::Semaphore drawTriggerSema;
00222 vpr::Semaphore drawDoneSema;
00223
00224
00225 bool mRunning;
00227 vpr::ThreadMemberFunctor<GlDrawManager>* mMemberFunctor;
00228 vpr::Thread* mControlThread;
00229
00230 protected:
00231 GlDrawManager();
00232
00233 virtual ~GlDrawManager()
00234 {
00235
00236
00237 }
00238
00239 GlDrawManager(const GlDrawManager& o)
00240 : DrawManager()
00241 {;}
00242
00243 void operator=(const GlDrawManager& o) {;}
00244
00245 vprSingletonHeader(GlDrawManager);
00246 };
00247
00248 }
00249
00250 #endif