BALL  1.4.2
 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<float>,
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 
68  protected:
69  void paintEvent(QPaintEvent* e);
70  static QGLFormat gl_format_;
71 
72  // ID of the fullscreen texture used to paste image into GPU framebuffer
73  GLuint m_screenTexID;
74  // type of the texture used
76  // format of the GL texture (GL_RGB, GL_RGBA, etc.)
78  // internal format specified when creating the textures
80  // data type of the GL texture (GL_FLOAT, GL_UNSIGNED_INT, etc.)
82 
83  void createTexture(const unsigned int winWidth, const unsigned int winHeight);
84  void deleteTexture();
85 
86  void checkGL();
87 
88  bool errorInGL(GLenum& error);
89  String getGLErrorString(GLenum error);
90 
93 
95  };
96 
97  } // namespace VIEW
98 
99 } // namespace BALL
100 
101 #endif // BALL_VIEW_RENDERING_GLRENDERWINDOW_H