OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Renderer.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGVIEWER_RENDERER
15 #define OSGVIEWER_RENDERER 1
16 
17 #include <OpenThreads/Condition>
18 #include <osg/Timer>
19 #include <osgDB/DatabasePager>
20 #include <osgUtil/SceneView>
21 #include <osgViewer/Export>
22 
23 namespace osgViewer {
24 
26 {
27  public:
29 
30  virtual void checkQuery(osg::Stats* stats, osg::State* state,
31  osg::Timer_t startTick) = 0;
32 
33  virtual void beginQuery(unsigned int frameNumber, osg::State* state) = 0;
34  virtual void endQuery(osg::State* state) = 0;
35  virtual void initialize(osg::State* state, osg::Timer_t startTick);
36  protected:
37 
39 };
40 
42 {
43  public:
44 
45  Renderer(osg::Camera* camera);
46 
47  osgUtil::SceneView* getSceneView(unsigned int i) { return _sceneView[i].get(); }
48  const osgUtil::SceneView* getSceneView(unsigned int i) const { return _sceneView[i].get(); }
49 
50  void setDone(bool done) { _done = done; }
51  bool getDone() { return _done; }
52 
53  void setGraphicsThreadDoesCull(bool flag);
54  bool getGraphicsThreadDoesCull() const { return _graphicsThreadDoesCull; }
55 
56 
57  virtual void cull();
58  virtual void draw();
59  virtual void cull_draw();
60 
61  virtual void compile();
62 
63  void setCompileOnNextDraw(bool flag) { _compileOnNextDraw = flag; }
64  bool getCompileOnNextDraw() const { return _compileOnNextDraw; }
65 
66  virtual void operator () (osg::Object* object);
67 
68  virtual void operator () (osg::GraphicsContext* context);
69 
70  virtual void release();
71 
72  virtual void reset();
73 
75  void setCameraRequiresSetUp(bool flag);
76  bool getCameraRequiresSetUp() const;
77 
78  protected:
79  void initialize(osg::State* state);
80  virtual ~Renderer();
81 
82  virtual void updateSceneView(osgUtil::SceneView* sceneView);
83 
85 
86  bool _done;
90 
92 
94  {
97  typedef std::list<osgUtil::SceneView*> SceneViewList;
98  SceneViewList _queue;
100 
101  ThreadSafeQueue();
102  ~ThreadSafeQueue();
103 
105  void release();
106 
108  void reset();
109 
111  osgUtil::SceneView* takeFront();
112 
114  void add(osgUtil::SceneView* sv);
115  };
116 
117 
120 
124 };
125 
126 }
127 
128 #endif
void setDone(bool done)
Definition: Renderer.h:50
This class provides an object-oriented thread mutex interface.
Definition: Mutex.h:31
bool _graphicsThreadDoesCull
Definition: Renderer.h:87
This class provides an object-oriented thread condition interface.
Definition: Condition.h:32
OpenThreads::Condition _cond
Definition: Renderer.h:96
#define OSGVIEWER_EXPORT
Definition: Export.h:40
osgUtil::SceneView * getSceneView(unsigned int i)
Definition: Renderer.h:47
bool getGraphicsThreadDoesCull() const
Definition: Renderer.h:54
ThreadSafeQueue _availableQueue
Definition: Renderer.h:118
unsigned long long Timer_t
Definition: Timer.h:24
bool _compileOnNextDraw
Definition: Renderer.h:88
osg::ref_ptr< OpenGLQuerySupport > _querySupport
Definition: Renderer.h:122
void setCompileOnNextDraw(bool flag)
Definition: Renderer.h:63
std::list< osgUtil::SceneView * > SceneViewList
Definition: Renderer.h:97
osg::Timer_t _startTick
Definition: Renderer.h:123
bool getCompileOnNextDraw() const
Definition: Renderer.h:64
osg::observer_ptr< osg::Camera > _camera
Definition: Renderer.h:84
const osg::GLExtensions * _extensions
Definition: Renderer.h:38
ThreadSafeQueue _drawQueue
Definition: Renderer.h:119
const osgUtil::SceneView * getSceneView(unsigned int i) const
Definition: Renderer.h:48