Changeset 7535 for OpenSceneGraph/trunk/include/osgViewer/ViewerBase
- Timestamp:
- 10/02/07 23:23:58 (6 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgViewer/ViewerBase (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgViewer/ViewerBase
r7507 r7535 72 72 73 73 /** Set the threading model the rendering traversals will use.*/ 74 virtual void setThreadingModel(ThreadingModel threadingModel) = 0;74 virtual void setThreadingModel(ThreadingModel threadingModel); 75 75 76 76 /** Get the threading model the rendering traversals will use.*/ 77 77 ThreadingModel getThreadingModel() const { return _threadingModel; } 78 78 79 /** Let the viewer suggest the best threading model for the viewers camera/window setup and the hardware available.*/ 80 virtual ThreadingModel suggestBestThreadingModel(); 81 82 /** Set up the threading and processor affinity as per the viewers threading model.*/ 83 virtual void setUpThreading(); 84 85 /** Return true if viewer threads are running. */ 86 bool areThreadsRunning() const { return _threadsRunning; } 87 88 /** Stop any threads begin run by viewer.*/ 89 virtual void stopThreading(); 90 91 /** Start any threads required by the viewer.*/ 92 virtual void startThreading(); 93 94 enum BarrierPosition 95 { 96 BeforeSwapBuffers, 97 AfterSwapBuffers 98 }; 99 100 /** Set the position of the end barrier. 101 * AfterSwapBuffers will may result is slightly higher framerates, by may 102 * lead to inconcistent swapping between different windows. 103 * BeforeSwapBuffers may lead to slightly lower framerate, but improve consistency in timing of swap buffers, 104 * especially important if you are likely to consistently break frame.*/ 105 void setEndBarrierPosition(BarrierPosition bp); 106 107 /** Get the end barrier position.*/ 108 BarrierPosition getEndBarrierPosition() const { return _endBarrierPosition; } 109 110 79 111 80 112 /** Set the done flag to singnal the viewer's work is done and should exit the frame loop.*/ … … 134 166 /** Remove an update operation.*/ 135 167 void removeUpdateOperation(osg::Operation* operation); 168 169 170 /** Set the graphics operation to call on realization of the viewers graphics windows.*/ 171 void setRealizeOperation(osg::Operation* op) { _realizeOperation = op; } 172 173 /** Get the graphics operation to call on realization of the viewers graphics windows.*/ 174 osg::Operation* getRealizeOperation() { return _realizeOperation.get(); } 175 176 177 /** Check to see if windows are still open, if not set viewer done to true. */ 178 void checkWindowStatus(); 179 136 180 137 181 … … 145 189 /** Render a complete new frame. 146 190 * Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). */ 147 virtual void frame(double simulationTime=USE_REFERENCE_TIME) = 0;191 virtual void frame(double simulationTime=USE_REFERENCE_TIME); 148 192 149 193 virtual void advance(double simulationTime=USE_REFERENCE_TIME) = 0; … … 153 197 virtual void updateTraversal() = 0; 154 198 155 virtual void renderingTraversals() = 0;199 virtual void renderingTraversals(); 156 200 157 201 typedef std::vector<osg::Camera*> Cameras; … … 176 220 virtual void getViews(Views& views, bool onlyValid=true) = 0; 177 221 178 179 /** Set the graphics operation to call on realization of the viewers graphics windows.*/ 180 void setRealizeOperation(osg::Operation* op) { _realizeOperation = op; } 181 182 /** Get the graphics operation to call on realization of the viewers graphics windows.*/ 183 osg::Operation* getRealizeOperation() { return _realizeOperation.get(); } 184 185 /** Set up the threading and processor affinity as per the viewers threading model.*/ 186 virtual void setUpThreading() = 0; 187 188 /** Return true if viewer threads are running. */ 189 bool areThreadsRunning() const { return _threadsRunning; } 190 191 /** Stop any threads begin run by viewer.*/ 192 virtual void stopThreading() = 0; 193 194 /** Start any threads required by the viewer.*/ 195 virtual void startThreading() = 0; 222 virtual double elapsedTime() = 0; 223 224 virtual osg::FrameStamp* getViewerFrameStamp() = 0; 196 225 197 226 /** Get the keyboard and mouse usage of this viewer.*/ … … 200 229 protected: 201 230 231 inline void makeCurrent(osg::GraphicsContext* gc) 232 { 233 if (_currentContext==gc) return; 234 235 releaseContext(); 236 237 if (gc && gc->valid() && gc->makeCurrent()) _currentContext = gc; 238 } 239 240 inline void releaseContext() 241 { 242 if (_currentContext.valid() && _currentContext->valid()) 243 { 244 _currentContext->releaseContext(); 245 } 246 _currentContext = 0; 247 } 248 249 virtual void viewerInit() = 0; 250 251 202 252 osg::ref_ptr<osg::Stats> _stats; 203 253 254 bool _firstFrame; 204 255 bool _done; 205 256 int _keyEventSetsDone; … … 208 259 ThreadingModel _threadingModel; 209 260 bool _threadsRunning; 261 262 BarrierPosition _endBarrierPosition; 263 264 osg::ref_ptr<osg::BarrierOperation> _startRenderingBarrier; 265 osg::ref_ptr<osg::BarrierOperation> _endRenderingDispatchBarrier; 266 osg::ref_ptr<osg::EndOfDynamicDrawBlock> _endDynamicDrawBlock; 210 267 211 268 osg::ref_ptr<osgGA::EventVisitor> _eventVisitor; … … 216 273 osg::ref_ptr<osg::Operation> _realizeOperation; 217 274 275 osg::observer_ptr<osg::GraphicsContext> _currentContext; 218 276 }; 277 219 278 } 220 279
