58 #include "QtBaseViewer.hh" 61 #include <QOffscreenSurface> 63 #include <QOpenGLContext> 64 #include <QOpenGLDebugLogger> 67 #include <QOpenGLWidget> 68 #include <QOpenGLFramebufferObject> 80 glWidget_->context()->swapBuffers(glWidget_->context()->surface());
86 void glViewer::startGLDebugLogger()
89 if (OpenFlipper::Options::debug())
91 delete glDebugLogger_;
92 glDebugLogger_ =
new QOpenGLDebugLogger(
this);
93 if (glDebugLogger_->initialize())
95 connect(glDebugLogger_, SIGNAL(messageLogged(QOpenGLDebugMessage)),
this, SLOT(
processGLDebugMessage(QOpenGLDebugMessage)));
96 glDebugLogger_->startLogging(QOpenGLDebugLogger::SynchronousLogging);
104 void glViewer::deleteGLDebugLogger()
107 delete glDebugLogger_;
114 if (msg.severity() & QOpenGLDebugMessage::HighSeverity)
115 std::cerr << msg.message().toStdString() << std::endl;
118 else if (!
glstate_->compatibilityProfile() && msg.type() == QOpenGLDebugMessage::DeprecatedBehaviorType)
119 std::cerr << msg.message().toStdString() << std::endl;
127 unsigned int _l,
unsigned int _t,
128 unsigned int _w,
unsigned int _h,
132 _image = glWidget_->grabFramebuffer().copy(_l, _t, _w, _h).convertToFormat(QImage::Format_RGB32);
137 void glViewer::makeWidgetCurrent()
139 glWidget_->makeCurrent();
144 bool glViewer::createQFBO(QOpenGLFramebufferObject*& ptr, GLuint* _handle,
int _width,
int _height,
int* _samples)
147 format.setInternalTextureFormat(GL_RGBA);
148 format.setTextureTarget(GL_TEXTURE_2D);
152 format.setAttachment(QFramebufferObject::CombinedDepthStencil);
155 format.setSamples(*_samples);
163 *_handle = fb->handle();
164 *_samples = fb->format().samples();
176 void glViewer::blitQFBO(QOpenGLFramebufferObject* _ptr1,
const QRect& _size1, QOpenGLFramebufferObject* _ptr2,
const QRect& _size2)
178 QFramebufferObject::blitFramebuffer(_ptr1, _size1, _ptr2, _size2);
183 bool glViewer::bindQFBO(QOpenGLFramebufferObject* _ptr)
190 bool glViewer::QFBOResized(QOpenGLFramebufferObject* _ptr1)
197 void glViewer::deleteQFBO(QOpenGLFramebufferObject* _ptr)
QOpenGLFramebufferObjectFormat QFramebufferObjectFormat
Framebuffer object that holds the pick cache.
void copyToImage(QImage &_image, GLenum _buffer=GL_BACK)
copy current framebuffer to an QImage
QOpenGLFramebufferObject QFramebufferObject
Framebuffer object that holds the pick cache.
ACG::GLState * glstate_
Gl State.
unsigned int glHeight() const
get height of QGLWidget
virtual void makeCurrent()
Makes this widget the current widget for OpenGL operations.
void processGLDebugMessage(const QOpenGLDebugMessage &msg)
process opengl debug messages
unsigned int glWidth() const
get width of QGLWidget
virtual void swapBuffers()
Swaps the screen contents with the off-screen buffer.