Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

#shaders: start of shaders fix

Jeremy Bullockd165bbb42cd8
diff --git a/toonz/sources/include/stdfx/shaderinterface.h b/toonz/sources/include/stdfx/shaderinterface.h
index f52214b17..abbc9253d 100644
--- a/toonz/sources/include/stdfx/shaderinterface.h
+++ b/toonz/sources/include/stdfx/shaderinterface.h
@@ -17,7 +17,7 @@
// Qt includes
#include <QString>
#include <QDateTime>
-#include <QGLShader>
+#include <QOpenGLShader>
// STD includes
#include <vector>
@@ -36,7 +36,7 @@
// Forward declarations
-class QGLShaderProgram;
+class QOpenGLShaderProgram;
//=========================================================
@@ -175,7 +175,7 @@ public: // Sub-classes
public:
QString m_name; //!< A name associated to the shader action
TFilePath m_path; //!< The shader program's file path
- QGLShader::ShaderType m_type; //!< The shader type
+ QOpenGLShader::ShaderType m_type; //!< The shader type
public:
bool isValid() const { return !m_path.isEmpty(); }
@@ -203,7 +203,7 @@ public: // Public methods
Returns a compiled shader program against current OpenGL context, and the
last modified date of the associated shader file.
*/
- std::pair<QGLShaderProgram *, QDateTime> makeProgram(
+ std::pair<QOpenGLShaderProgram *, QDateTime> makeProgram(
const ShaderData &sd, int varyingsCount = 0,
const GLchar **varyingNames = 0) const;
diff --git a/toonz/sources/include/stdfx/shadingcontext.h b/toonz/sources/include/stdfx/shadingcontext.h
index 127f72e7e..4fe77b85b 100644
--- a/toonz/sources/include/stdfx/shadingcontext.h
+++ b/toonz/sources/include/stdfx/shadingcontext.h
@@ -13,7 +13,8 @@
// Qt includes
#include <QDateTime>
-#include <QGLFramebufferObjectFormat>
+#include <QOpenGLFramebufferObjectFormat>
+#include <QOpenGLWidget>
#undef DVAPI
#undef DVVAR
@@ -30,8 +31,9 @@
// Forward declarations
class QObject;
-class QGLShaderProgram;
+class QOpenGLShaderProgram;
class QDateTime;
+class QOffScreenSurface;
//=========================================================
@@ -56,23 +58,23 @@ Resizes the output buffer to the specified size. Requires that
the contex is made current before invocation. In case lx or ly are 0,
the context's output buffer is destroyed.
*/
- void resize(int lx, int ly, const QGLFramebufferObjectFormat &fmt =
- QGLFramebufferObjectFormat());
+ void resize(int lx, int ly, const QOpenGLFramebufferObjectFormat &fmt =
+ QOpenGLFramebufferObjectFormat());
- QGLFramebufferObjectFormat format() const;
+ QOpenGLFramebufferObjectFormat format() const;
TDimension size() const;
//! Surrenders ownership of the supplied shader program to the shading
//! context.
- void addShaderProgram(const QString &shaderName, QGLShaderProgram *program);
- void addShaderProgram(const QString &shaderName, QGLShaderProgram *program,
+ void addShaderProgram(const QString &shaderName, QOpenGLShaderProgram *program);
+ void addShaderProgram(const QString &shaderName, QOpenGLShaderProgram *program,
const QDateTime &lastModified);
bool removeShaderProgram(const QString &shaderName);
- QGLShaderProgram *shaderProgram(const QString &shaderName) const;
+ QOpenGLShaderProgram *shaderProgram(const QString &shaderName) const;
QDateTime lastModified(const QString &shaderName) const;
- std::pair<QGLShaderProgram *, QDateTime> shaderData(
+ std::pair<QOpenGLShaderProgram *, QDateTime> shaderData(
const QString &shaderName) const;
GLuint loadTexture(const TRasterP &src, GLuint texUnit); //!< Loads a texture
@@ -99,4 +101,10 @@ private:
ShadingContext &operator=(const ShadingContext &);
};
+class TQOpenGLWidget : public QOpenGLWidget {
+public:
+ TQOpenGLWidget();
+ void initializeGL() override;
+};
+
#endif // SHADINGCONTEXT_H
diff --git a/toonz/sources/include/toonzqt/glwidget_for_highdpi.h b/toonz/sources/include/toonzqt/glwidget_for_highdpi.h
index 2bae136c7..4baa80a88 100644
--- a/toonz/sources/include/toonzqt/glwidget_for_highdpi.h
+++ b/toonz/sources/include/toonzqt/glwidget_for_highdpi.h
@@ -3,18 +3,18 @@
#ifndef GLWIDGET_FOR_HIGHDPI_H
#define GLWIDGET_FOR_HIGHDPI_H
-#include <QGLWidget>
+#include <QOpenGLWidget>
#include <QApplication>
#include <QDesktopWidget>
// use obsolete QGLWidget instead of QOpenGLWidget for now...
// TODO: replace with the "modern" OpenGL source and transfer to QOpenGLWidget
-class GLWidgetForHighDpi : public QGLWidget {
+class GLWidgetForHighDpi : public QOpenGLWidget {
public:
GLWidgetForHighDpi(QWidget *parent = Q_NULLPTR,
- const QGLWidget *shareWidget = Q_NULLPTR,
+ const QOpenGLWidget *shareWidget = Q_NULLPTR,
Qt::WindowFlags f = Qt::WindowFlags())
- : QGLWidget(parent, shareWidget, f) {}
+ : QOpenGLWidget(parent, f) {}
// returns device-pixel ratio. It is 1 for normal monitors and 2 (or higher
// ratio) for high DPI monitors. Setting "Display > Set custom text size(DPI)"
@@ -24,8 +24,8 @@ public:
return devPixRatio;
}
// modify sizes for high DPI monitors
- int width() const { return QGLWidget::width() * getDevPixRatio(); }
- int height() const { return QGLWidget::height() * getDevPixRatio(); }
+ int width() const { return QOpenGLWidget::width() * getDevPixRatio(); }
+ int height() const { return QOpenGLWidget::height() * getDevPixRatio(); }
QRect rect() const { return QRect(0, 0, width(), height()); }
};
diff --git a/toonz/sources/include/toonzqt/planeviewer.h b/toonz/sources/include/toonzqt/planeviewer.h
index a173cf27c..f8c27a2d4 100644
--- a/toonz/sources/include/toonzqt/planeviewer.h
+++ b/toonz/sources/include/toonzqt/planeviewer.h
@@ -12,7 +12,7 @@
#include "toonzqt/glwidget_for_highdpi.h"
// Qt includes
-#include <QGLWidget>
+#include <QOpenGLWidget>
#undef DVAPI
#undef DVVAR
diff --git a/toonz/sources/stdfx/shaderfx.cpp b/toonz/sources/stdfx/shaderfx.cpp
index bb3420396..3580ed549 100644
--- a/toonz/sources/stdfx/shaderfx.cpp
+++ b/toonz/sources/stdfx/shaderfx.cpp
@@ -22,7 +22,7 @@
// Qt includes
#include <QDir>
-#include <QGLShaderProgram>
+#include <QOpenGLShaderProgram>
#include <QCoreApplication>
// Glew include
@@ -81,10 +81,10 @@ public:
};
struct ProgramBinder {
- QGLShaderProgram *m_prog;
+ QOpenGLShaderProgram *m_prog;
public:
- ProgramBinder(QGLShaderProgram *prog) : m_prog(prog) { m_prog->bind(); }
+ ProgramBinder(QOpenGLShaderProgram *prog) : m_prog(prog) { m_prog->bind(); }
~ProgramBinder() { m_prog->release(); }
};
@@ -191,14 +191,14 @@ public:
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
private:
- QGLShaderProgram *touchShaderProgram(const ShaderInterface::ShaderData &sd,
+ QOpenGLShaderProgram *touchShaderProgram(const ShaderInterface::ShaderData &sd,
ShadingContext &context,
int varyingsCount = 0,
const GLchar **varyings = 0);
- void bindParameters(QGLShaderProgram *shaderProgram, double frame);
+ void bindParameters(QOpenGLShaderProgram *shaderProgram, double frame);
- void bindWorldTransform(QGLShaderProgram *shaderProgram,
+ void bindWorldTransform(QOpenGLShaderProgram *shaderProgram,
const TAffine &worldToDst);
void getInputData(const TRectD &rect, double frame, const TRenderSettings &ri,
@@ -251,7 +251,7 @@ Suggestions are welcome as this is a tad beyond ridiculous...
assert(thread() ==
mainScopeBoundObject
->thread()); // Parent object must be in the same thread,
- setParent(mainScopeBoundObject); // otherwise reparenting fails
+ //setParent(mainScopeBoundObject); // otherwise reparenting fails
}
static ShadingContextManager *instance() {
@@ -298,13 +298,13 @@ Suggestions are welcome as this is a tad beyond ridiculous...
if (!sentMsg) {
switch (sup) {
case ShadingContext::NO_PIXEL_BUFFER:
- DVGui::warning(QGLShaderProgram::tr(
+ DVGui::warning(QOpenGLShaderProgram::tr(
"This system configuration does not support OpenGL Pixel Buffers. "
"Shader Fxs will not be able to render."));
break;
case ShadingContext::NO_SHADERS:
- DVGui::warning(QGLShaderProgram::tr(
+ DVGui::warning(QOpenGLShaderProgram::tr(
"This system configuration does not support OpenGL Shader "
"Programs. Shader Fxs will not be able to render."));
break;
@@ -609,7 +609,7 @@ bool ShaderFx::doGetBBox(double frame, TRectD &bbox,
::ContextLocker cLocker(context);
// Build the varyings data
- QGLShaderProgram *prog = 0;
+ QOpenGLShaderProgram *prog = 0;
{
const GLchar *varyingNames[] = {"outputBBox"};
prog = touchShaderProgram(sd, context, 1, &varyingNames[0]);
@@ -672,13 +672,13 @@ bool ShaderFx::canHandle(const TRenderSettings &info, double frame) {
//-------------------------------------------------------------------
-QGLShaderProgram *ShaderFx::touchShaderProgram(
+QOpenGLShaderProgram *ShaderFx::touchShaderProgram(
const ShaderInterface::ShaderData &sd, ShadingContext &context,
int varyingsCount, const GLchar **varyings) {
- typedef std::pair<QGLShaderProgram *, QDateTime> CompiledShader;
+ typedef std::pair<QOpenGLShaderProgram *, QDateTime> CompiledShader;
struct locals {
- inline static void logCompilation(QGLShaderProgram *program) {
+ inline static void logCompilation(QOpenGLShaderProgram *program) {
// Log shaders - observe that we'll look into the program's *children*,
// not its
// shaders. This is necessary as uncompiled shaders are not added to the
@@ -687,7 +687,7 @@ QGLShaderProgram *ShaderFx::touchShaderProgram(
int c, cCount = children.size();
for (c = 0; c != cCount; ++c) {
- if (QGLShader *shader = dynamic_cast<QGLShader *>(children[c])) {
+ if (QOpenGLShader *shader = dynamic_cast<QOpenGLShader *>(children[c])) {
const QString &log = shader->log();
if (!log.isEmpty()) DVGui::info(log);
}
@@ -716,7 +716,7 @@ QGLShaderProgram *ShaderFx::touchShaderProgram(
//-------------------------------------------------------------------
-void ShaderFx::bindParameters(QGLShaderProgram *program, double frame) {
+void ShaderFx::bindParameters(QOpenGLShaderProgram *program, double frame) {
// Bind fx parameters
const std::vector<ShaderInterface::Parameter> &siParams =
m_shaderInterface->parameters();
@@ -780,7 +780,7 @@ void ShaderFx::bindParameters(QGLShaderProgram *program, double frame) {
//-------------------------------------------------------------------
-void ShaderFx::bindWorldTransform(QGLShaderProgram *program,
+void ShaderFx::bindWorldTransform(QOpenGLShaderProgram *program,
const TAffine &worldToDst) {
// Bind transformation affine
#if QT_VERSION >= 0x050500
@@ -857,7 +857,7 @@ void ShaderFx::getInputData(const TRectD &rect, double frame,
int pCount = getInputPortCount();
// Build the varyings data
- QGLShaderProgram *prog = 0;
+ QOpenGLShaderProgram *prog = 0;
{
// Unsubscripted varying arrays on transform feedback seems to be
// unsupported
@@ -957,18 +957,18 @@ void ShaderFx::doCompute(TTile &tile, double frame,
}
};
- inline static QGLFramebufferObjectFormat makeFormat(int bpp) {
- QGLFramebufferObjectFormat fmt;
+ inline static QOpenGLFramebufferObjectFormat makeFormat(int bpp) {
+ QOpenGLFramebufferObjectFormat fmt;
if (bpp == 64) fmt.setInternalTextureFormat(GL_RGBA16);
return fmt;
}
inline static void touchOutputSize(ShadingContext &context,
const TDimension &size, int bpp) {
- const QGLFramebufferObjectFormat &fmt = makeFormat(bpp);
+ const QOpenGLFramebufferObjectFormat &fmt = makeFormat(bpp);
const TDimension &currentSize = context.size();
- const QGLFramebufferObjectFormat &currentFmt = context.format();
+ const QOpenGLFramebufferObjectFormat &currentFmt = context.format();
if (currentSize.lx < size.lx || currentSize.ly < size.ly ||
currentFmt != fmt)
@@ -1054,7 +1054,7 @@ void ShaderFx::doCompute(TTile &tile, double frame,
{
locals::touchOutputSize(context, tile.getRaster()->getSize(), info.m_bpp);
- QGLShaderProgram *program =
+ QOpenGLShaderProgram *program =
touchShaderProgram(m_shaderInterface->mainShader(), context);
{
ProgramBinder binder(program);
diff --git a/toonz/sources/stdfx/shaderinterface.cpp b/toonz/sources/stdfx/shaderinterface.cpp
index 789b372be..db1bf9099 100644
--- a/toonz/sources/stdfx/shaderinterface.cpp
+++ b/toonz/sources/stdfx/shaderinterface.cpp
@@ -8,8 +8,8 @@
#include "tmsgcore.h"
// Qt includes
-#include <QGLShaderProgram>
-#include <QGLShader>
+#include <QOpenGLShaderProgram>
+#include <QOpenGLShader>
#include <QDir>
#include "stdfx/shaderinterface.h"
@@ -30,7 +30,7 @@ namespace {
// Filescope declarations
-typedef std::pair<QGLShaderProgram *, QDateTime> CompiledShader;
+typedef std::pair<QOpenGLShaderProgram *, QDateTime> CompiledShader;
struct CaselessCompare {
const QString &m_str;
@@ -79,9 +79,9 @@ const static std::string l_names[NAMESCOUNT] = {
// Filescope functions
-inline bool loadShader(QGLShader::ShaderType type, const TFilePath &fp,
+inline bool loadShader(QOpenGLShader::ShaderType type, const TFilePath &fp,
CompiledShader &cs) {
- QGLShader *shader = new QGLShader(type, cs.first);
+ QOpenGLShader *shader = new QOpenGLShader(type, cs.first);
const QString &qfp = QString::fromStdWString(fp.getWideString());
@@ -165,14 +165,14 @@ ShaderInterface::HandledWorldTransformsType ShaderInterface::hwtType() const {
//---------------------------------------------------------
-std::pair<QGLShaderProgram *, QDateTime> ShaderInterface::makeProgram(
+std::pair<QOpenGLShaderProgram *, QDateTime> ShaderInterface::makeProgram(
const ShaderData &sd, int varyingsCount,
const GLchar **varyingNames) const {
CompiledShader result;
if (!isValid()) return result;
- result.first = new QGLShaderProgram;
+ result.first = new QOpenGLShaderProgram;
::loadShader(sd.m_type, sd.m_path, result);
@@ -274,7 +274,7 @@ void ShaderInterface::loadData(TIStream &is) {
while (is.openChild(tagName)) {
if (tagName == l_names[MAIN_PROGRAM]) {
is >> m_mainShader;
- m_mainShader.m_type = QGLShader::Fragment;
+ m_mainShader.m_type = QOpenGLShader::Fragment;
is.closeChild();
} else if (tagName == l_names[INPUT_PORTS]) {
while (is.openChild(tagName)) {
@@ -287,7 +287,7 @@ void ShaderInterface::loadData(TIStream &is) {
is.closeChild();
} else if (tagName == l_names[PORTS_PROGRAM]) {
is >> m_portsShader;
- m_portsShader.m_type = QGLShader::Vertex;
+ m_portsShader.m_type = QOpenGLShader::Vertex;
is.closeChild();
} else
::skipTag(is, tagName);
@@ -296,7 +296,7 @@ void ShaderInterface::loadData(TIStream &is) {
is.closeChild();
} else if (tagName == l_names[BBOX_PROGRAM]) {
is >> m_bboxShader;
- m_bboxShader.m_type = QGLShader::Vertex;
+ m_bboxShader.m_type = QOpenGLShader::Vertex;
is.closeChild();
} else if (tagName == l_names[HANDLED_WORLD_TRANSFORMS]) {
QString hwtName;
diff --git a/toonz/sources/stdfx/shadingcontext.cpp b/toonz/sources/stdfx/shadingcontext.cpp
index 851c21461..81f45bd79 100644
--- a/toonz/sources/stdfx/shadingcontext.cpp
+++ b/toonz/sources/stdfx/shadingcontext.cpp
@@ -11,10 +11,12 @@
#include <QThread>
#include <QDateTime>
-#include <QGLPixelBuffer>
-#include <QGLFramebufferObject>
-#include <QGLShaderProgram>
+
+#include <QOpenGLFramebufferObject>
+#include <QOpenGLShaderProgram>
#include <QOpenGLContext>
+#include <QOffscreenSurface>
+#include <QOpenGLWidget>
// STD includes
#include <map>
@@ -28,12 +30,12 @@
namespace {
-typedef std::unique_ptr<QGLPixelBuffer> QGLPixelBufferP;
-typedef std::unique_ptr<QGLFramebufferObject> QGLFramebufferObjectP;
-typedef std::unique_ptr<QGLShaderProgram> QGLShaderProgramP;
+typedef std::unique_ptr<QOpenGLContext> QOpenGLContextP;
+typedef std::unique_ptr<QOpenGLFramebufferObject> QOpenGLFramebufferObjectP;
+typedef std::unique_ptr<QOpenGLShaderProgram> QOpenGLShaderProgramP;
struct CompiledShader {
- QGLShaderProgramP m_program;
+ QOpenGLShaderProgramP m_program;
QDateTime m_lastModified;
public:
@@ -43,13 +45,22 @@ public:
} // namespace
+TQOpenGLWidget::TQOpenGLWidget() {}
+
+void TQOpenGLWidget::initializeGL() {
+ QOffscreenSurface *surface = new QOffscreenSurface();
+ //context()->create();
+ //context()->makeCurrent(surface);
+}
+
//*****************************************************************
// ShadingContext::Imp definition
//*****************************************************************
struct ShadingContext::Imp {
- QGLPixelBufferP m_pixelBuffer; //!< OpenGL context.
- QGLFramebufferObjectP m_fbo; //!< Output buffer.
+ QOpenGLContextP m_context; //!< OpenGL context.
+ QOpenGLFramebufferObjectP m_fbo; //!< Output buffer.
+ QOffscreenSurface *m_surface;
std::map<QString,
CompiledShader>
@@ -58,7 +69,7 @@ struct ShadingContext::Imp {
public:
Imp();
- static QGLFormat format();
+ static QSurfaceFormat format();
void initMatrix(int lx, int ly);
@@ -71,12 +82,12 @@ private:
//--------------------------------------------------------
ShadingContext::Imp::Imp()
- : m_pixelBuffer(new QGLPixelBuffer(1, 1, format())) {}
+ : m_context(new QOpenGLContext()) {}
//--------------------------------------------------------
-QGLFormat ShadingContext::Imp::format() {
- QGLFormat fmt;
+QSurfaceFormat ShadingContext::Imp::format() {
+ QSurfaceFormat fmt;
#ifdef MACOSX
fmt.setVersion(3, 2);
@@ -102,6 +113,15 @@ void ShadingContext::Imp::initMatrix(int lx, int ly) {
//*****************************************************************
ShadingContext::ShadingContext() : m_imp(new Imp) {
+ m_imp->m_surface = new QOffscreenSurface();
+ m_imp->m_surface->create();
+ QSurfaceFormat format;
+ m_imp->m_context->setFormat(format);
+ m_imp->m_context->create();
+ m_imp->m_context->makeCurrent(m_imp->m_surface);
+
+ //m_imp->m_pixelBuffer->context()->create();
+ //m_imp->m_fbo(new QOpenGLFramebufferObject(1, 1));
makeCurrent();
glewExperimental = GL_TRUE;
glewInit();
@@ -125,14 +145,15 @@ ShadingContext::~ShadingContext() {
//--------------------------------------------------------
ShadingContext::Support ShadingContext::support() {
- return !QGLPixelBuffer::hasOpenGLPbuffers()
- ? NO_PIXEL_BUFFER
- : !QGLShaderProgram::hasOpenGLShaderPrograms() ? NO_SHADERS : OK;
+ //return !QGLPixelBuffer::hasOpenGLPbuffers()
+ // ? NO_PIXEL_BUFFER
+ // : !QOpenGLShaderProgram::hasOpenGLShaderPrograms() ? NO_SHADERS : OK;
+ return OK;
}
//--------------------------------------------------------
-bool ShadingContext::isValid() const { return m_imp->m_pixelBuffer->isValid(); }
+bool ShadingContext::isValid() const { return m_imp->m_context->isValid(); }
//--------------------------------------------------------
/*
@@ -166,11 +187,16 @@ USE HARDWARE ACCELERATION
//--------------------------------------------------------
void ShadingContext::makeCurrent() {
-#ifdef MACOSX
- m_imp->m_pixelBuffer->context()->contextHandle()->moveToThread(
+//#ifdef MACOSX
+ m_imp->m_context->moveToThread(
QThread::currentThread());
-#endif
- m_imp->m_pixelBuffer->makeCurrent();
+//#endif
+ //m_imp->m_context->makeCurrent();
+ m_imp->m_context.reset(new QOpenGLContext());
+ QSurfaceFormat format;
+ m_imp->m_context->setFormat(format);
+ m_imp->m_context->create();
+ m_imp->m_context->makeCurrent(m_imp->m_surface);
}
//--------------------------------------------------------
@@ -179,13 +205,13 @@ void ShadingContext::doneCurrent() {
#ifdef MACOSX
m_imp->m_pixelBuffer->context()->contextHandle()->moveToThread(0);
#endif
- m_imp->m_pixelBuffer->doneCurrent();
+ m_imp->m_context->doneCurrent();
}
//--------------------------------------------------------
void ShadingContext::resize(int lx, int ly,
- const QGLFramebufferObjectFormat &fmt) {
+ const QOpenGLFramebufferObjectFormat &fmt) {
if (m_imp->m_fbo.get() && m_imp->m_fbo->width() == lx &&
m_imp->m_fbo->height() == ly && m_imp->m_fbo->format() == fmt)
return;
@@ -193,7 +219,12 @@ void ShadingContext::resize(int lx, int ly,
if (lx == 0 || ly == 0) {
m_imp->m_fbo.reset(0);
} else {
- m_imp->m_fbo.reset(new QGLFramebufferObject(lx, ly, fmt));
+ bool get = m_imp->m_fbo.get();
+ QOpenGLContext *currContext = m_imp->m_context->currentContext();
+ bool yes = false;
+ if (currContext) bool yes = true;
+ while (!currContext) currContext = m_imp->m_context->currentContext();
+ m_imp->m_fbo.reset(new QOpenGLFramebufferObject(lx, ly, fmt));
assert(m_imp->m_fbo->isValid());
m_imp->m_fbo->bind();
@@ -202,22 +233,22 @@ void ShadingContext::resize(int lx, int ly,
//--------------------------------------------------------
-QGLFramebufferObjectFormat ShadingContext::format() const {
- QGLFramebufferObject *fbo = m_imp->m_fbo.get();
- return fbo ? m_imp->m_fbo->format() : QGLFramebufferObjectFormat();
+QOpenGLFramebufferObjectFormat ShadingContext::format() const {
+ QOpenGLFramebufferObject *fbo = m_imp->m_fbo.get();
+ return fbo ? m_imp->m_fbo->format() : QOpenGLFramebufferObjectFormat();
}
//--------------------------------------------------------
TDimension ShadingContext::size() const {
- QGLFramebufferObject *fbo = m_imp->m_fbo.get();
+ QOpenGLFramebufferObject *fbo = m_imp->m_fbo.get();
return fbo ? TDimension(fbo->width(), fbo->height()) : TDimension();
}
//--------------------------------------------------------
void ShadingContext::addShaderProgram(const QString &shaderName,
- QGLShaderProgram *program) {
+ QOpenGLShaderProgram *program) {
std::map<QString, CompiledShader>::iterator st =
m_imp->m_shaderPrograms
.insert(std::make_pair(shaderName, CompiledShader()))
@@ -229,7 +260,7 @@ void ShadingContext::addShaderProgram(const QString &shaderName,
//--------------------------------------------------------
void ShadingContext::addShaderProgram(const QString &shaderName,
- QGLShaderProgram *program,
+ QOpenGLShaderProgram *program,
const QDateTime &lastModified) {
std::map<QString, CompiledShader>::iterator st =
m_imp->m_shaderPrograms
@@ -248,7 +279,7 @@ bool ShadingContext::removeShaderProgram(const QString &shaderName) {
//--------------------------------------------------------
-QGLShaderProgram *ShadingContext::shaderProgram(
+QOpenGLShaderProgram *ShadingContext::shaderProgram(
const QString &shaderName) const {
std::map<QString, CompiledShader>::iterator st =
m_imp->m_shaderPrograms.find(shaderName);
@@ -268,7 +299,7 @@ QDateTime ShadingContext::lastModified(const QString &shaderName) const {
//--------------------------------------------------------
-std::pair<QGLShaderProgram *, QDateTime> ShadingContext::shaderData(
+std::pair<QOpenGLShaderProgram *, QDateTime> ShadingContext::shaderData(
const QString &shaderName) const {
std::map<QString, CompiledShader>::iterator st =
m_imp->m_shaderPrograms.find(shaderName);
@@ -276,7 +307,7 @@ std::pair<QGLShaderProgram *, QDateTime> ShadingContext::shaderData(
return (st != m_imp->m_shaderPrograms.end())
? std::make_pair(st->second.m_program.get(),
st->second.m_lastModified)
- : std::make_pair((QGLShaderProgram *)0, QDateTime());
+ : std::make_pair((QOpenGLShaderProgram *)0, QDateTime());
}
//--------------------------------------------------------
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index 797403228..c34b29c8c 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -93,13 +93,13 @@ namespace {
int l_displayListsSpaceId =
-1; //!< Display lists space id associated with SceneViewers
-QGLWidget *l_proxy = 0; //!< Proxy associated with the above
+QOpenGLWidget *l_proxy = 0; //!< Proxy associated with the above
std::set<TGlContext>
l_contexts; //!< Stores every SceneViewer context (see ~SceneViewer)
//-------------------------------------------------------------------------------
-QGLWidget *touchProxy() {
+QOpenGLWidget *touchProxy() {
struct GLWidgetProxy final : public TGLDisplayListsProxy {
~GLWidgetProxy() {
delete l_proxy;
@@ -112,7 +112,7 @@ QGLWidget *touchProxy() {
// If it does not exist, create the viewer's display lists proxy
if (!l_proxy) {
- l_proxy = new QGLWidget;
+ l_proxy = new QOpenGLWidget;
l_displayListsSpaceId =
TGLDisplayListsManager::instance()->storeProxy(new GLWidgetProxy);
}
@@ -572,7 +572,7 @@ SceneViewer::~SceneViewer() {
std::set<TGlContext>::iterator ct, cEnd(l_contexts.end());
for (ct = l_contexts.begin(); ct != cEnd; ++ct)
TGLDisplayListsManager::instance()->releaseContext(*ct);
- assert(!l_proxy);
+ //assert(!l_proxy);
}
makeCurrent();
@@ -628,7 +628,7 @@ void SceneViewer::onRenderCompleted(int frame) {
//-------------------------------------------------------------------------------
void SceneViewer::onPreviewUpdate() {
- updateGL();
+ update();
emit previewStatusChanged();
}
@@ -636,7 +636,8 @@ void SceneViewer::onPreviewUpdate() {
void SceneViewer::startForegroundDrawing() {
makeCurrent();
- setAutoBufferSwap(false);
+ //setAutoBufferSwap(false);
+ update(); // needed?
glPushMatrix();
tglMultMatrix(getViewMatrix());
@@ -668,7 +669,8 @@ void SceneViewer::endForegroundDrawing() {
assert(glGetError() == GL_NO_ERROR);
}
- setAutoBufferSwap(true);
+ //setAutoBufferSwap(true);
+ update(); // needed?
m_foregroundDrawing = false;
}
@@ -1542,7 +1544,7 @@ void SceneViewer::paintGL() {
// Il freezed e' attivo ed e' in stato "update": faccio il grab del viewer.
if (m_freezedStatus == UPDATE_FREEZED) {
- m_viewGrabImage = rasterFromQImage(grabFrameBuffer(false));
+ m_viewGrabImage = rasterFromQImage(grabFramebuffer());
m_freezedStatus = NORMAL_FREEZED;
}
@@ -1789,7 +1791,7 @@ void SceneViewer::navigatorPan(const QPoint &delta) {
void SceneViewer::GLInvalidateAll() {
m_clipRect.empty();
- updateGL();
+ update();
if (m_vRuler) m_vRuler->update();
if (m_hRuler) m_hRuler->update();
}
@@ -1798,7 +1800,7 @@ void SceneViewer::GLInvalidateAll() {
void SceneViewer::GLInvalidateRect(const TRectD &rect) {
m_clipRect = rect;
- updateGL();
+ update();
m_clipRect.empty();
if (m_vRuler) m_vRuler->update();
if (m_hRuler) m_hRuler->update();
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp
index 98767b5e6..a605d42c2 100644
--- a/toonz/sources/toonz/sceneviewerevents.cpp
+++ b/toonz/sources/toonz/sceneviewerevents.cpp
@@ -342,7 +342,7 @@ void SceneViewer::enterEvent(QEvent *) {
}
setFocus();
- updateGL();
+ update();
}
//-----------------------------------------------------------------------------
@@ -856,7 +856,7 @@ bool SceneViewer::event(QEvent *e) {
}
*/
- return QGLWidget::event(e);
+ return QOpenGLWidget::event(e);
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonz/viewerpane.cpp b/toonz/sources/toonz/viewerpane.cpp
index 43afba24c..e036c82a4 100644
--- a/toonz/sources/toonz/viewerpane.cpp
+++ b/toonz/sources/toonz/viewerpane.cpp
@@ -320,7 +320,7 @@ void SceneViewerPanel::hideEvent(QHideEvent *event) {
void SceneViewerPanel::resizeEvent(QResizeEvent *e) {
QWidget::resizeEvent(e);
repaint();
- m_sceneViewer->updateGL();
+ m_sceneViewer->update();
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonzqt/planeviewer.cpp b/toonz/sources/toonzqt/planeviewer.cpp
index a348e9a21..74c1d6a6e 100644
--- a/toonz/sources/toonzqt/planeviewer.cpp
+++ b/toonz/sources/toonzqt/planeviewer.cpp
@@ -189,7 +189,7 @@ void PlaneViewer::wheelEvent(QWheelEvent *event) {
void PlaneViewer::keyPressEvent(QKeyEvent *event) {
if (PlaneViewerZoomer(this).exec(event)) return;
- QGLWidget::keyPressEvent(event);
+ QOpenGLWidget::keyPressEvent(event);
}
//------------------------------------------------------