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_;
117 switch (msg.severity())
119 case QOpenGLDebugMessage::NotificationSeverity:
122 case QOpenGLDebugMessage::HighSeverity:
125 case QOpenGLDebugMessage::MediumSeverity:
128 case QOpenGLDebugMessage::LowSeverity:
138 #define CASE(c) case QOpenGLDebugMessage::c: error += #c; break 139 switch (msg.source())
142 CASE(WindowSystemSource);
143 CASE(ShaderCompilerSource);
144 CASE(ThirdPartySource);
145 CASE(ApplicationSource);
149 error +=
" " ;
break;
156 #define CASE(c) case QOpenGLDebugMessage::c: error += #c; break 160 CASE(DeprecatedBehaviorType);
161 CASE(UndefinedBehaviorType);
162 CASE(PortabilityType);
163 CASE(PerformanceType);
174 qDebug() << qPrintable(error) <<
" " << qPrintable(msg.message()) <<
"\n";
190 unsigned int _l,
unsigned int _t,
191 unsigned int _w,
unsigned int _h,
195 _image = glWidget_->grabFramebuffer().copy(_l, _t, _w, _h).convertToFormat(QImage::Format_RGB32);
200 void glViewer::makeWidgetCurrent()
202 glWidget_->makeCurrent();
207 bool glViewer::createQFBO(QOpenGLFramebufferObject*& ptr, GLuint* _handle,
int _width,
int _height,
int* _samples)
210 format.setInternalTextureFormat(GL_RGBA);
211 format.setTextureTarget(GL_TEXTURE_2D);
215 format.setAttachment(QFramebufferObject::CombinedDepthStencil);
218 format.setSamples(*_samples);
226 *_handle = fb->handle();
227 *_samples = fb->format().samples();
239 void glViewer::blitQFBO(QOpenGLFramebufferObject* _ptr1,
const QRect& _size1, QOpenGLFramebufferObject* _ptr2,
const QRect& _size2)
241 QFramebufferObject::blitFramebuffer(_ptr1, _size1, _ptr2, _size2);
246 bool glViewer::bindQFBO(QOpenGLFramebufferObject* _ptr)
253 bool glViewer::QFBOResized(QOpenGLFramebufferObject* _ptr1)
260 void glViewer::deleteQFBO(QOpenGLFramebufferObject* _ptr)
unsigned int glWidth() const
get width of QGLWidget
void copyToImage(QImage &_image, GLenum _buffer=GL_BACK)
copy current framebuffer to an QImage
virtual void makeCurrent()
Makes this widget the current widget for OpenGL operations.
unsigned int glHeight() const
get height of QGLWidget
void processGLDebugMessage(const QOpenGLDebugMessage &msg)
process opengl debug messages
QOpenGLFramebufferObjectFormat QFramebufferObjectFormat
Framebuffer object that holds the pick cache.
virtual void swapBuffers()
Swaps the screen contents with the off-screen buffer.
QOpenGLFramebufferObject QFramebufferObject
Framebuffer object that holds the pick cache.