BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::WFlags w_flags = 0);
45  GLRenderWindow(const GLRenderWindow& window, QWidget* parent_widget, const char* name = NULL, Qt::WFlags 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  float getDownsamplingFactor() const
80  {return down_sampling_factor_;}
81 
83 
84  protected:
85 
91  virtual void customEvent(QEvent* evt);
92 
93  void paintEvent(QPaintEvent* e);
94  static QGLFormat gl_format_;
95 
96  // ID of the fullscreen texture used to paste image into GPU framebuffer
97  GLuint m_screenTexID;
98  // type of the texture used
100  // format of the GL texture (GL_RGB, GL_RGBA, etc.)
102  // internal format specified when creating the textures
104  // data type of the GL texture (GL_FLOAT, GL_UNSIGNED_INT, etc.)
106 
107  void createTexture(const unsigned int winWidth, const unsigned int winHeight);
108  void deleteTexture();
109 
110  void checkGL();
111 
112  bool errorInGL(GLenum& error);
113  String getGLErrorString(GLenum error);
114 
118  //float stereo_delta_;
119  };
120 
121  } // namespace VIEW
122 
123 } // namespace BALL
124 
125 #endif // BALL_VIEW_RENDERING_GLRENDERWINDOW_H
void setDownsamplingFactor(float dsfactor)
Set the window's downsampling factor. This is a speed up factor.
void setStereoDelta(float delta)
Set the stereo delta for raytracing in pixels.
static QGLFormat gl_format_
#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's downsampling factor.