00001
00002
00003
00004
00005 #ifndef BALL_VIEW_RENDERING_GLRENDERWINDOW_H
00006 #define BALL_VIEW_RENDERING_GLRENDERWINDOW_H
00007
00008 #ifndef BALL_COMMON_GLOBAL_H
00009 # include <BALL/COMMON/global.h>
00010 #endif
00011
00012 #ifndef BALL_DATATYPE_STRING_H
00013 # include <BALL/DATATYPE/string.h>
00014 #endif
00015
00016 #ifndef BALL_VIEW_RENDERING_RENDERWINDOW_H
00017 # include <BALL/VIEW/RENDERING/renderWindow.h>
00018 #endif
00019
00020 #ifndef BALL_VIEW_DATATYPE_COLORRGBA_H
00021 # include <BALL/VIEW/DATATYPE/colorRGBA.h>
00022 #endif
00023
00024 #ifndef BALL_SYSTEM_MUTEX_H
00025 # include <BALL/SYSTEM/mutex.h>
00026 #endif
00027
00028 #include <QtOpenGL/qgl.h>
00029
00030 namespace BALL
00031 {
00032 namespace VIEW
00033 {
00037 class BALL_VIEW_EXPORT GLRenderWindow
00038 : public RenderWindow<float>,
00039 public QGLWidget
00040 {
00041
00042 public:
00043 GLRenderWindow();
00044 GLRenderWindow(QWidget* parent_widget, const char* name = NULL, Qt::WFlags w_flags = 0);
00045 GLRenderWindow(const GLRenderWindow& window, QWidget* parent_widget, const char* name = NULL, Qt::WFlags w_flags = 0);
00046
00047 virtual ~GLRenderWindow();
00048
00049
00050 virtual bool init();
00051 virtual bool resize(const unsigned int width, const unsigned int height);
00052 virtual void refresh();
00053
00054
00055 virtual void renderText(int x, int y, const String& text, const ColorRGBA& color, Size size = 16);
00056
00057 virtual void renderText(float x, float y, float z, const String& text, const ColorRGBA& color, Size size = 16);
00058
00060 void lockGLContext();
00061
00063 void unlockGLContext();
00064
00066 void ignoreEvents(bool ignore) {ignore_events_ = ignore;}
00067
00068 protected:
00069 void paintEvent(QPaintEvent* e);
00070 static QGLFormat gl_format_;
00071
00072
00073 GLuint m_screenTexID;
00074
00075 GLenum FB_TEXTURE_TARGET;
00076
00077 GLenum FB_TEXTURE_FORMAT;
00078
00079 GLenum FB_INTERNAL_TEXTURE_FORMAT;
00080
00081 GLenum FB_TEXTURE_DATATYPE;
00082
00083 void createTexture(const unsigned int winWidth, const unsigned int winHeight);
00084 void deleteTexture();
00085
00086 void checkGL();
00087
00088 bool errorInGL(GLenum& error);
00089 String getGLErrorString(GLenum error);
00090
00091 mutable Mutex contex_mutex_;
00092 bool ignore_events_;
00093
00094 bool is_buffered_;
00095 };
00096
00097 }
00098
00099 }
00100
00101 #endif // BALL_VIEW_RENDERING_GLRENDERWINDOW_H