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
renderWindow.h
BALL::VIEW::GLRenderWindow::FB_INTERNAL_TEXTURE_FORMAT
GLenum FB_INTERNAL_TEXTURE_FORMAT
Definition: glRenderWindow.h:106
QEvent
BALL::String
Definition: string.h:56
BALL::VIEW::GLRenderWindow::m_screenTexID
GLuint m_screenTexID
Definition: glRenderWindow.h:100
BALL::VIEW::GLRenderWindow::ignoreEvents
void ignoreEvents(bool ignore)
Force the window to ignore paint events.
Definition: glRenderWindow.h:66
BALL
Definition: constants.h:12
BALL::VIEW::GLRenderWindow::FB_TEXTURE_TARGET
GLenum FB_TEXTURE_TARGET
Definition: glRenderWindow.h:102
BALL::VIEW::GLRenderWindow::ignore_events_
bool ignore_events_
Definition: glRenderWindow.h:119
BALL::VIEW::GLRenderWindow::down_sampling_factor_
float down_sampling_factor_
Definition: glRenderWindow.h:120
BALL::VIEW::GLRenderWindow::setDownsamplingFactor
void setDownsamplingFactor(float dsfactor)
Set the window's downsampling factor. This is a speed up factor.
Definition: glRenderWindow.h:69
BALL::VIEW::ColorRGBA
Definition: colorRGBA.h:31
BALL::VIEW::GLRenderWindow::stereo_delta_
float stereo_delta_
Definition: glRenderWindow.h:85
BALL_SIZE_TYPE
BALL::VIEW::GLRenderWindow::contex_mutex_
Mutex contex_mutex_
Definition: glRenderWindow.h:118
global.h
BALL::VIEW::GLRenderWindow::setStereoDelta
void setStereoDelta(float delta)
Set the stereo delta for raytracing in pixels.
Definition: glRenderWindow.h:73
BALL::VIEW::GLRenderWindow::gl_format_
static QGLFormat gl_format_
Definition: glRenderWindow.h:97
string.h
BALL::VIEW::GLRenderWindow::FB_TEXTURE_FORMAT
GLenum FB_TEXTURE_FORMAT
Definition: glRenderWindow.h:104
QWidget
mutex.h
BALL::VIEW::GLRenderWindow::FB_TEXTURE_DATATYPE
GLenum FB_TEXTURE_DATATYPE
Definition: glRenderWindow.h:108
colorRGBA.h
BALL::VIEW::GLRenderWindow::getDownsamplingFactor
float getDownsamplingFactor() const
Get the window's downsampling factor.
Definition: glRenderWindow.h:82
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
QGLWidget
BALL::VIEW::GLRenderWindow
Definition: glRenderWindow.h:37
BALL::TMutex< BALL_DEFAULT_MUTEX_TYPE >
BALL::VIEW::TRenderWindow
Definition: renderWindow.h:33