Changeset 13041 for OpenSceneGraph/trunk/include/osg/GraphicsContext
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osg/GraphicsContext (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/GraphicsContext
r13038 r13041 30 30 { 31 31 public: 32 32 33 33 struct OSG_EXPORT ScreenIdentifier 34 34 { … … 38 38 39 39 ScreenIdentifier(const std::string& in_hostName,int in_displayNum, int in_screenNum); 40 41 /** Return the display name in the form hostName::displayNum:screenNum. */ 40 41 /** Return the display name in the form hostName::displayNum:screenNum. */ 42 42 std::string displayName() const; 43 43 44 44 /** Read the DISPLAY environmental variable, and set the ScreenIdentifier accordingly. 45 45 * Note, if either of displayNum or screenNum are not defined then -1 is set respectively to … … 47 47 * call setUndefinedScreenDetailsToDefaultScreen() after readDISPLAY() to ensure valid values. */ 48 48 void readDISPLAY(); 49 49 50 50 /** Set the screenIndentifier from the displayName string. 51 51 * Note, if either of displayNum or screenNum are not defined then -1 is set to … … 65 65 int screenNum; 66 66 }; 67 67 68 68 /** GraphicsContext Traits object provides the specification of what type of graphics context is required.*/ 69 69 struct OSG_EXPORT Traits : public osg::Referenced, public ScreenIdentifier 70 70 { 71 71 Traits(DisplaySettings* ds=0); 72 72 73 73 // graphics context original and size 74 74 int x; … … 76 76 int width; 77 77 int height; 78 78 79 79 // window decoration and behaviour 80 80 std::string windowName; 81 81 bool windowDecoration; 82 82 bool supportsResize; 83 83 84 84 // buffer depths, 0 equals off. 85 85 unsigned int red; … … 105 105 unsigned int face; 106 106 unsigned int mipMapGeneration; 107 107 108 108 // V-sync 109 109 bool vsync; 110 110 111 111 // Swap Group 112 112 bool swapGroupEnabled; … … 116 116 // use multithreaded OpenGL-engine (OS X only) 117 117 bool useMultiThreadedOpenGLEngine; 118 118 119 119 // enable cursor 120 120 bool useCursor; … … 127 127 /** return true if glContextVersion is set in the form major.minor, and assign the appropriate major and minor values to the associated parameters.*/ 128 128 bool getContextVersion(unsigned int& major, unsigned int& minor) const; 129 129 130 130 // shared context 131 131 GraphicsContext* sharedContext; 132 132 133 133 osg::ref_ptr<osg::Referenced> inheritedWindowData; 134 134 135 135 // ask the GraphicsWindow implementation to set the pixel format of an inherited window 136 136 bool setInheritedWindowPixelFormat; 137 137 138 138 // X11 hint whether to override the window managers window size/position redirection 139 139 bool overrideRedirect; … … 178 178 179 179 virtual GraphicsContext* createGraphicsContext(Traits* traits) = 0; 180 180 181 181 virtual ~WindowingSystemInterface() {} 182 182 … … 208 208 } 209 209 }; 210 211 210 211 212 212 /** Set the query the windowing system for screens and create graphics context - this functor should be supplied by the windows toolkit. */ 213 213 static void setWindowingSystemInterface(WindowingSystemInterface* wsInterface); 214 214 215 215 /** Get the WindowingSystemInterface*/ 216 216 static WindowingSystemInterface* getWindowingSystemInterface(); 217 217 218 218 /** Create a graphics context for a specified set of traits.*/ 219 219 static GraphicsContext* createGraphicsContext(Traits* traits); 220 220 221 221 /** Create a contextID for a new graphics context, this contextID is used to set up the osg::State associate with context. 222 222 * Automatically increments the usage count of the contextID to 1.*/ … … 231 231 /** Decrement the usage count associate with a contextID. Once the contextID goes to 0 the contextID is then free to be reused.*/ 232 232 static void decrementContextIDUsageCount(unsigned int contextID); 233 233 234 234 typedef std::vector<GraphicsContext*> GraphicsContexts; 235 235 236 236 /** Get all the registered graphics contexts.*/ 237 237 static GraphicsContexts getAllRegisteredGraphicsContexts(); 238 238 239 239 /** Get all the registered graphics contexts associated with a specific contextID.*/ 240 240 static GraphicsContexts getRegisteredGraphicsContexts(unsigned int contextID); 241 241 242 242 /** Get the GraphicsContext for doing background compilation for GraphicsContexts associated with specified contextID.*/ 243 243 static void setCompileContext(unsigned int contextID, GraphicsContext* gc); … … 245 245 /** Get existing or create a new GraphicsContext to do background compilation for GraphicsContexts associated with specified contextID.*/ 246 246 static GraphicsContext* getOrCreateCompileContext(unsigned int contextID); 247 247 248 248 /** Get the GraphicsContext for doing background compilation for GraphicsContexts associated with specified contextID.*/ 249 249 static GraphicsContext* getCompileContext(unsigned int contextID); 250 250 251 251 public: 252 252 253 253 /** Add operation to end of OperationQueue.*/ 254 254 void add(Operation* operation); 255 255 256 256 /** Remove operation from OperationQueue.*/ 257 257 void remove(Operation* operation); … … 267 267 268 268 typedef std::list< ref_ptr<Operation> > GraphicsOperationQueue; 269 269 270 270 /** Get the operations queue, not you must use the OperationsMutex when accessing the queue.*/ 271 271 GraphicsOperationQueue& getOperationsQueue() { return _operations; } … … 282 282 283 283 public: 284 284 285 285 /** Get the traits of the GraphicsContext.*/ 286 286 inline const Traits* getTraits() const { return _traits.get(); } … … 292 292 /** Set the State object which tracks the current OpenGL state for this graphics context.*/ 293 293 inline void setState(State* state) { _state = state; } 294 294 295 295 /** Get the State object which tracks the current OpenGL state for this graphics context.*/ 296 296 inline State* getState() { return _state.get(); } 297 297 298 298 /** Get the const State object which tracks the current OpenGL state for this graphics context.*/ 299 299 inline const State* getState() const { return _state.get(); } … … 305 305 /** Returns the clear color. */ 306 306 inline const Vec4& getClearColor() const { return _clearColor; } 307 307 308 308 /** Set the clear mask used in glClear(..). 309 309 * Defaults to 0 - so no clear is done by default by the GraphicsContext, instead the Cameras attached to the GraphicsContext will do the clear. … … 313 313 /** Get the clear mask.*/ 314 314 inline GLbitfield getClearMask() const { return _clearMask; } 315 315 316 316 /** Do an OpenGL clear of the full graphics context/window. 317 317 * Note, must only be called from a thread with this context current.*/ 318 318 virtual void clear(); 319 319 320 320 double getTimeSinceLastClear() const { return osg::Timer::instance()->delta_s(_lastClearTick, osg::Timer::instance()->tick()); } 321 321 322 322 323 323 /** Realize the GraphicsContext.*/ … … 339 339 340 340 /** Make this graphics context current. 341 * Implemented by calling makeCurrentImplementation(). 341 * Implemented by calling makeCurrentImplementation(). 342 342 * Returns true on success. */ 343 343 bool makeCurrent(); 344 344 345 345 /** Make this graphics context current with specified read context. 346 346 * Implemented by calling makeContextCurrentImplementation(). 347 347 * Returns true on success. */ 348 348 bool makeContextCurrent(GraphicsContext* readContext); 349 349 350 350 /** Release the graphics context. 351 351 * Returns true on success. */ 352 352 bool releaseContext(); 353 353 354 354 /** Return true if the current thread has this OpenGL graphics context.*/ 355 355 inline bool isCurrent() const { return _threadOfLastMakeCurrent == OpenThreads::Thread::CurrentThread(); } … … 373 373 374 374 375 /** Realize the GraphicsContext implementation, 375 /** Realize the GraphicsContext implementation, 376 376 * Pure virtual - must be implemented by concrete implementations of GraphicsContext. */ 377 377 virtual bool realizeImplementation() = 0; … … 388 388 * Pure virtual - must be implemented by concrete implementations of GraphicsContext. */ 389 389 virtual bool makeCurrentImplementation() = 0; 390 390 391 391 /** Make this graphics context current with specified read context implementation. 392 392 * Pure virtual - must be implemented by concrete implementations of GraphicsContext. */ … … 408 408 * developers to provide custom behavior for swap. 409 409 * The callback must call 410 * GraphicsContext::swapBuffersImplementation() */ 410 * GraphicsContext::swapBuffersImplementation() */ 411 411 void setSwapCallback(SwapCallback* rc) { _swapCallback = rc; } 412 412 … … 468 468 /** Get the the const list of cameras associated with this graphics context.*/ 469 469 const Cameras& getCameras() const { return _cameras; } 470 470 471 471 /** set the default FBO-id, this id will be used when the rendering-backend is finished with RTT FBOs */ 472 472 void setDefaultFboId(GLuint i) { _defaultFboId = i; } 473 473 474 474 GLuint getDefaultFboId() const { return _defaultFboId; } 475 475 … … 481 481 482 482 protected: 483 483 484 484 GraphicsContext(); 485 485 GraphicsContext(const GraphicsContext&, const osg::CopyOp&); … … 499 499 void addCamera(osg::Camera* camera); 500 500 void removeCamera(osg::Camera* camera); 501 501 502 502 Cameras _cameras; 503 503 504 504 friend class osg::Camera; 505 505 506 ref_ptr<Traits> _traits; 506 ref_ptr<Traits> _traits; 507 507 ref_ptr<State> _state; 508 508 … … 511 511 512 512 OpenThreads::Thread* _threadOfLastMakeCurrent; 513 513 514 514 OpenThreads::Mutex _operationsMutex; 515 515 osg::ref_ptr<osg::RefBlock> _operationsBlock; … … 518 518 519 519 ref_ptr<GraphicsThread> _graphicsThread; 520 520 521 521 ref_ptr<ResizedCallback> _resizedCallback; 522 522 ref_ptr<SwapCallback> _swapCallback; 523 523 524 524 Timer_t _lastClearTick; 525 525 526 526 GLuint _defaultFboId; 527 527 };
