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 _VJ_GL_WINDOW_H_
00034 #define _VJ_GL_WINDOW_H_
00035
00036 #include <vrj/vrjConfig.h>
00037 #include <vector>
00038
00039 #include <stdio.h>
00040 #include <vpr/vpr.h>
00041
00042 #ifdef VPR_OS_Darwin
00043 # include <OpenGL/gl.h>
00044 #else
00045 # include <GL/gl.h>
00046 #endif
00047
00048 #include <vrj/Display/Display.h>
00049 #include <vrj/Display/Viewport.h>
00050
00051 #include <vpr/Util/Debug.h>
00052
00053 #include <boost/concept_check.hpp>
00054
00055
00056 namespace vrj
00057 {
00058
00059 class Projection;
00060 class CameraProjection;
00061
00068 class VJ_CLASS_API GlWindow
00069 {
00070 public:
00071 GlWindow()
00072 : mVrjDisplay(NULL)
00073 , mDirtyContext(true)
00074 , mDirtyViewport(true)
00075 , in_stereo(false)
00076 , border(false)
00077 , window_is_open(false)
00078 , window_width(0)
00079 , window_height(0)
00080 , origin_x(0)
00081 , origin_y(0)
00082
00083 , mWindowId(getNextWindowId())
00084 , mAreEventSource(false)
00085 {
00086
00087 }
00088
00089
00090 virtual ~GlWindow()
00091 {;}
00092
00093 public:
00094
00099 virtual int open()
00100 {
00101 return 1;
00102 }
00103
00105 virtual int close()
00106 {
00107 return 1;
00108 }
00109
00114 virtual bool makeCurrent()
00115 {
00116 return false;
00117 }
00118
00123 virtual void configWindow(vrj::Display* displayWindow);
00124
00130 virtual void swapBuffers()
00131 {;}
00132
00136 virtual void checkEvents()
00137 {;}
00138
00142 virtual void finishSetup();
00143
00144 public:
00146 void setProjection(vrj::Projection* proj);
00147
00152 void setLeftEyeProjection();
00153
00158 void setRightEyeProjection();
00159
00161 void setViewBuffer(vrj::Viewport::View view);
00162
00174 void setViewport(float xo, float yo, float xSize, float ySize);
00175
00177 void updateViewport();
00178
00180 bool hasDirtyContext() const
00181 {
00182 return mDirtyContext;
00183 }
00184
00186 void setDirtyContext(bool val=true)
00187 {
00188 mDirtyContext = val;
00189 }
00190
00192 bool hasDirtyViewport() const
00193 {
00194 return mDirtyViewport;
00195 }
00196
00198 void setDirtyViewport(bool val=true)
00199 {
00200 mDirtyViewport = val;
00201 }
00202
00207 bool isOpen() const
00208 {
00209 return window_is_open;
00210 }
00211
00216 bool isStereo() const
00217 {
00218 return in_stereo;
00219 }
00220
00221 bool isEventSource() const
00222 {
00223 return mAreEventSource;
00224 }
00225
00226 vrj::Display* getDisplay()
00227 {
00228 return mVrjDisplay;
00229 }
00230
00234 int getId() const
00235 {
00236 return mWindowId;
00237 }
00238
00239
00240
00241 void updateOriginSize(int o_x, int o_y, int width, int height)
00242 {
00243 origin_x = o_x; origin_y = o_y;
00244 window_width = width; window_height = height;
00245
00246
00247 mVrjDisplay->setOriginAndSize(o_x, o_y, width, height);
00248 }
00249
00251 void getOriginSize(unsigned& o_x, unsigned& o_y, unsigned& width,
00252 unsigned& height) const
00253 {
00254 o_x = origin_x;
00255 o_y = origin_y;
00256 width = window_width;
00257 height = window_height;
00258 }
00259
00260 friend std::ostream& operator<<(std::ostream& out, GlWindow& win);
00261
00262 public:
00263 virtual bool createHardwareSwapGroup(std::vector<GlWindow*> wins)
00264 {
00265 boost::ignore_unused_variable_warning(wins);
00266 vprDEBUG(vprDBG_ALL,vprDBG_WARNING_LVL)
00267 << "WARNING: hardware swap not supported.\n" << vprDEBUG_FLUSH;
00268 return false;
00269 }
00270
00271 protected:
00272
00273
00274
00275 vrj::Display* mVrjDisplay;
00276
00277 bool mDirtyContext;
00278 bool mDirtyViewport;
00284 bool in_stereo;
00285
00286 bool border;
00287 bool window_is_open;
00288 int window_width, window_height;
00289 int origin_x, origin_y;
00290 int mWindowId;
00291 bool mAreEventSource;
00293 private:
00294 static vpr::Mutex mWinIdMutex;
00295 static int mCurMaxWinId;
00297 static int getNextWindowId();
00298 };
00299
00300
00301
00302
00303 }
00304 #endif