Skip to content

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

C

Changes needed to build OpenGL files with Linu

Campbell Barton301bdb149a5f
diff --git a/toonz/sources/common/tvrender/qtofflinegl.cpp b/toonz/sources/common/tvrender/qtofflinegl.cpp
index 6d46512dd..f9581f061 100644
--- a/toonz/sources/common/tvrender/qtofflinegl.cpp
+++ b/toonz/sources/common/tvrender/qtofflinegl.cpp
@@ -153,6 +153,10 @@ void QtOfflineGL::createContext(TDimension rasterSize,
fmt.setPlane(0);
fmt.setDirectRendering(false);
#endif
+#elif LINUX
+ fmt = QGLFormat::defaultFormat();
+ // printf("GL Version: %s\n",glGetString(GL_VERSION));
+ fmt.setVersion(2, 1); /* XXX? */
#endif
QSurfaceFormat format;
@@ -295,6 +299,16 @@ SPECIFICHE MAC = depth_size 24, stencil_size 8, alpha_size 1
fmt.setStencil(true);
fmt.setAccum(false);
fmt.setPlane(0);
+#elif LINUX
+ fmt.setAlphaBufferSize(1);
+ fmt.setAlpha(false);
+ fmt.setRgba(true);
+ fmt.setDepthBufferSize(24);
+ fmt.setDepth(true);
+ fmt.setStencilBufferSize(8);
+ fmt.setStencil(true);
+ fmt.setAccum(false);
+ fmt.setPlane(0);
#endif
// Il PixelBuffer deve essere con width ed height potenze di 2
diff --git a/toonz/sources/common/tvrender/tofflinegl.cpp b/toonz/sources/common/tvrender/tofflinegl.cpp
index 20e5f6278..4b2d740d0 100644
--- a/toonz/sources/common/tvrender/tofflinegl.cpp
+++ b/toonz/sources/common/tvrender/tofflinegl.cpp
@@ -13,10 +13,10 @@
// Platform-specific includes
#if defined(LINUX)
+#include "qtofflinegl.h"
#include <X11/Xlib.h>
#include <GL/glx.h>
-#include "xscopedlock.h"
#include "tthread.h"
#elif MACOSX
@@ -308,6 +308,11 @@ std::shared_ptr<TOfflineGL::Imp> defaultOfflineGLGenerator(
//-----------------------------------------------------------------------------
#elif defined(LINUX)
+namespace {
+// The XScopedLock stuff doesn't seem finished,
+// why not just do the same as with win32 and use a Qt lock??
+static QMutex linuxImpMutex;
+}
class XImplementation : public TOfflineGL::Imp {
public:
@@ -315,10 +320,12 @@ public:
GLXContext m_context;
GLXPixmap m_pixmap;
Pixmap m_xpixmap;
+ TRaster32P m_raster;
//-----------------------------------------------------------------------------
- XImplementation(TDimension rasterSize) {
+ XImplementation(TDimension rasterSize)
+ : TOfflineGL::Imp(rasterSize.lx, rasterSize.ly) {
createContext(rasterSize);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -359,7 +366,7 @@ public:
//-----------------------------------------------------------------------------
void makeCurrent() {
- XScopedLock xsl;
+ QMutexLocker locker(&linuxImpMutex);
// Bool ret = glXMakeCurrent(m_dpy,m_pixmap,m_context);
@@ -480,7 +487,7 @@ Bool ret = glXMakeCurrent(m_dpy,
std::shared_ptr<TOfflineGL::Imp> defaultOfflineGLGenerator(
const TDimension &dim, std::shared_ptr<TOfflineGL::Imp> shared) {
- return std::make_shared<XImplementation>(dim);
+ return std::make_shared<QtOfflineGL>(dim, shared);
}
#elif MACOSX
@@ -516,8 +523,8 @@ class MessageCreateContext : public TThread::Message {
public:
MessageCreateContext(TOfflineGL *ogl, const TDimension &size,
- std::shared_ptr<TOfflineGL::Imp> shared)
- : m_ogl(ogl), m_size(size), m_shared(std::move(shared)) {}
+ TOfflineGL::Imp *shared)
+ : m_ogl(ogl), m_size(size), m_shared(shared) {}
void onDeliver() override {
m_ogl->m_imp = currentImpGenerator(m_size, m_shared);
@@ -532,20 +539,18 @@ public:
//--------------------------------------------------
-TOfflineGL::TOfflineGL(TDimension dim, const TOfflineGL *shared) {
+TOfflineGL::TOfflineGL(TDimension dim, const TOfflineGL *shared) : m_imp(0) {
#if defined(LINUX)
- XScopedLock xsl;
+ QMutexLocker locker(&linuxImpMutex);
#endif
- std::shared_ptr<Imp> sharedImp = shared ? shared->m_imp : 0;
-
/*
元のコードは(別スレッドから呼び出すための) offline renderer を作って main
thread に dispatch するという訳のわからないことをしていたが Q*GLContext は
thread context を超えられないので直接生成してこのコンテキストで閉じる.
別スレッドには dispatch しない.
*/
- m_imp = currentImpGenerator(dim, std::move(sharedImp));
+ m_imp = currentImpGenerator(dim, shared ? shared->m_imp : 0);
initMatrix();
}
@@ -554,9 +559,11 @@ TOfflineGL::TOfflineGL(TDimension dim, const TOfflineGL *shared) {
TOfflineGL::TOfflineGL(const TRaster32P &raster, const TOfflineGL *shared) {
#if defined(LINUX)
- XScopedLock xsl;
+ QMutexLocker locker(&linuxImpMutex);
#endif
+ // m_imp = new Imp(raster->getSize());
+
m_imp = currentImpGenerator(raster->getSize(), shared->m_imp);
initMatrix();
@@ -570,7 +577,9 @@ TOfflineGL::TOfflineGL(const TRaster32P &raster, const TOfflineGL *shared) {
//-----------------------------------------------------------------------------
-TOfflineGL::~TOfflineGL() {}
+TOfflineGL::~TOfflineGL() {
+ // delete m_imp;
+}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index 7e0b9e9ab..33debd95a 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -1,4 +1,7 @@
+#ifdef LINUX
+#define GL_GLEXT_PROTOTYPES
+#endif
// Toonz includes
#include "tapp.h"