BALL  1.5.0
glRenderWindow.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_GLRENDERWINDOW_H
6 #define BALL_VIEW_RENDERING_GLRENDERWINDOW_H
7 
8 #ifndef BALL_COMMON_GLOBAL_H
9 # include <BALL/COMMON/global.h>
10 #endif
11 
12 #ifndef BALL_DATATYPE_STRING_H
13 # include <BALL/DATATYPE/string.h>
14 #endif
15 
16 #ifndef BALL_VIEW_RENDERING_RENDERWINDOW_H
18 #endif
19 
20 #ifndef BALL_VIEW_DATATYPE_COLORRGBA_H
22 #endif
23 
24 #ifndef BALL_SYSTEM_MUTEX_H
25 # include <BALL/SYSTEM/mutex.h>
26 #endif
27 
28 #include <QtOpenGL/qgl.h>
29 
30 namespace BALL
31 {
32  namespace VIEW
33  {
38  : public RenderWindow,
39  public QGLWidget
40  {
41 
42  public:
44  GLRenderWindow(QWidget* parent_widget, const char* name = NULL, Qt::WindowFlags w_flags = 0);
45  GLRenderWindow(const GLRenderWindow& window, QWidget* parent_widget, const char* name = NULL, Qt::WindowFlags w_flags = 0);
46 
47  virtual ~GLRenderWindow();
48 
49  /* RenderWindow methods */
50  virtual bool init();
51  virtual bool resize(const unsigned int width, const unsigned int height);
52  virtual void refresh();
53 
54  // render the given text in the given color and size at window coordinates (x, y)
55  virtual void renderText(int x, int y, const String& text, const ColorRGBA& color, Size size = 16);
56  // render the given text in the given color and size at world coordinates (x, y, z)
57  virtual void renderText(float x, float y, float z, const String& text, const ColorRGBA& color, Size size = 16);
58 
60  void lockGLContext();
61 
63  void unlockGLContext();
64 
66  void ignoreEvents(bool ignore) {ignore_events_ = ignore;}
67 
69  void setDownsamplingFactor(float dsfactor)
70  {down_sampling_factor_ = dsfactor;}
71 
73  void setStereoDelta(float delta)
74  {stereo_delta_ = delta;}
75 
76  void setupStereo(float eye_separation, float focal_length);
77 
79  void safeBufferSwap();
80 
82  float getDownsamplingFactor() const
83  {return down_sampling_factor_;}
84 
86 
87  protected:
88 
94  virtual void customEvent(QEvent* evt);
95 
96  void paintEvent(QPaintEvent* e);
97  static QGLFormat gl_format_;
98 
99  // ID of the fullscreen texture used to paste image into GPU framebuffer
101  // type of the texture used
103  // format of the GL texture (GL_RGB, GL_RGBA, etc.)
105  // internal format specified when creating the textures
107  // data type of the GL texture (GL_FLOAT, GL_UNSIGNED_INT, etc.)
109 
110  void createTexture(const unsigned int winWidth, const unsigned int winHeight);
111  void deleteTexture();
112 
113  void checkGL();
114 
115  bool errorInGL(GLenum& error);
116  String getGLErrorString(GLenum error);
117 
121  //float stereo_delta_;
122  };
123 
124  } // namespace VIEW
125 
126 } // namespace BALL
127 
128 #endif // BALL_VIEW_RENDERING_GLRENDERWINDOW_H
void setStereoDelta(float delta)
Set the stereo delta for raytracing in pixels.
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
void ignoreEvents(bool ignore)
Force the window to ignore paint events.
float getDownsamplingFactor() const
Get the window&#39;s downsampling factor.
void setDownsamplingFactor(float dsfactor)
Set the window&#39;s downsampling factor. This is a speed up factor.
Definition: constants.h:12
static QGLFormat gl_format_