BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
renderSetup.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_VIEW_RENDERING_RENDERSETUP_H
6 #define BALL_VIEW_RENDERING_RENDERSETUP_H
7 
8 #ifndef BALL_VIEW_RENDERING_GLRENDERER_H
10 #endif
11 
12 #ifndef BALL_VIEW_RENDERING_RENDERTARGET_H
14 #endif
15 
16 #ifndef BALL_VIEW_RENDERING_GLRENDERWINDOW_H
18 #endif
19 
20 #ifndef BALL_SYSTEM_MUTEX_H
21 # include <BALL/SYSTEM/mutex.h>
22 #endif
23 
24 #include <QtCore/QThread>
25 
26 namespace BALL {
27  namespace VIEW {
28 
29  class Scene;
30 
37  : public QThread
38  {
39  public:
40  RenderSetup(Renderer* r, RenderTarget* t, Scene* scene, const Stage* stage);
41 
42  RenderSetup(const RenderSetup& rs);
43 
44  const RenderSetup& operator = (const RenderSetup& rs);
45 
46  // TODO: this should be boost smart pointers!
49 
50  enum STEREO_SETUP {
53  RIGHT_EYE
54  };
55 
58  void init();
59 
62  void resize(Size width, Size height);
63 
70  void pauseRendering() { rendering_paused_ = true; }
71 
77  void startRendering() { rendering_paused_ = false; }
78 
81  bool isPaused() const { return rendering_paused_; }
82 
98  void setReceiveBufferUpdates(bool do_receive) { receive_updates_ = do_receive; }
99 
102  bool receivesBufferUpdates() const { return receive_updates_; };
103 
109  void updateCamera(const Camera* camera = 0);
110 
116  void setOffset(const Vector3& offset);
117 
124  void setStereoMode(STEREO_SETUP stereo) { stereo_setup_ = stereo; };
125 
130  void bufferRepresentation(const Representation& rep);
131 
136  void removeRepresentation(const Representation& rep);
137 
144  void renderToBuffer();
145 
148  bool exportPNG(const String& filename);
149 
152  void setLights(bool reset_all = false);
153 
156  void updateBackgroundColor();
157 
163  Position prepareGridTextures(const RegularData3D& grid, const ColorMap& map);
164 
170  void removeGridTextures(const RegularData3D& grid);
171 
175  Vector3 mapViewportTo3D(Position x, Position y);
176 
180  Vector2 map3DToViewport(const Vector3& vec);
181 
184  void pickObjects(Position x1, Position y1, Position x2, Position y2, std::list<GeometricObject*>& objects);
185 
194  void showRuler(bool show);
195 
198  void projectionModeChanged();
199 
202  void useContinuousLoop(bool use_loop);
203 
206  bool isContinuous() { return use_continuous_loop_; }
207 
214  virtual void makeCurrent();
215 
216  virtual void run();
217 
218  protected:
219  // does the hard work and can be called from a continuous loop as well as from event-based rendering
220  void renderToBuffer_();
221 
225 
228 
230 
231  // switches between rendering continously and rendering upon events
233 
235  Stage const* stage_;
236 
237  // locks the renderer during updates and rendering
239 
243 
245 
246  // This pointer is used to avoid uneccessary RTTI calls and casting. If the target is not a
247  // GLRenderWindow or one of its derived classes, this pointer will simply be NULL
249  };
250  }
251 }
252 
253 #endif