Merge pull request #525 from ideasman42/linux-opengl-pr

Changes needed to build OpenGL files with Linux
This commit is contained in:
Campbell Barton 2016-06-30 08:25:57 +10:00 committed by GitHub
commit 1c6681c983
3 changed files with 39 additions and 13 deletions

View file

@ -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

View file

@ -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 final : 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 final : 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;
}
//-----------------------------------------------------------------------------

View file

@ -1,4 +1,7 @@
#ifdef LINUX
#define GL_GLEXT_PROTOTYPES
#endif
// Toonz includes
#include "tapp.h"