Commit 505b20c4 authored by WINTZ Julien's avatar WINTZ Julien

Final tweaks before a Vulkan specialization for MacOS. We're done with

GL.

TODO: Check whether works fine on Linux.
parent 94f11780
......@@ -62,16 +62,8 @@ dtkWidgetsWidget *dtkVisualizationViewerStack::create(const QString& type)
view = new dtkVisualizationView3D;
else if (type == "View3D")
view = new dtkVisualizationView3D;
else if (type == "ViewVideoPlayer") {
dtkVisualizationViewVideoGL *view = new dtkVisualizationViewVideoPlayer(0);
// view->setVersion(4, 1, false);
// view->resize(800, 500);
// view->show();
// view->raise();
return view;
}
else if (type == "ViewVideoPlayer")
view = new dtkVisualizationViewVideoPlayer;
return view;
}
......
......@@ -12,7 +12,7 @@
// Code:
#version 410
#version 150
uniform sampler2D tex;
......
......@@ -12,7 +12,7 @@
// Code:
#version 410
#version 150
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
......
......@@ -67,21 +67,26 @@ public:
public:
QString title;
public:
QOpenGLContext *context;
};
dtkVisualizationViewVideoGLPrivate::dtkVisualizationViewVideoGLPrivate(QWidget *parent) : QOpenGLWidget(parent),
vbo(QOpenGLBuffer::VertexBuffer),
ibo(QOpenGLBuffer::IndexBuffer)
{
}
void dtkVisualizationViewVideoGLPrivate::setVersion( int major, int minor, bool debug)
void dtkVisualizationViewVideoGLPrivate::setVersion(int major, int minor, bool debug)
{
QSurfaceFormat format;
format.setVersion(major, minor);
format.setDepthBufferSize(1);
format.setAlphaBufferSize(1);
format.setStencilBufferSize(1);
format.setSamples(1);
format.setProfile(QSurfaceFormat::CoreProfile);
#if !defined(Q_OS_MAC)
format.setOption(QSurfaceFormat::DeprecatedFunctions);
......@@ -97,9 +102,14 @@ void dtkVisualizationViewVideoGLPrivate::setVersion( int major, int minor, bool
else
q->version = dtkVisualizationViewVideoGL::GLSL120;
QOpenGLContext *context = new QOpenGLContext(this);
context->setFormat(format);
context->create();
this->context = new QOpenGLContext(this);
this->context->setFormat(format);
this->context->create();
qDebug() << Q_FUNC_INFO << this->context << this->context->shareContext() << QOpenGLContext::globalShareContext();
qDebug() << Q_FUNC_INFO << this->context->format();
qDebug() << Q_FUNC_INFO << this->context->surface();
qDebug() << "--------------------------------------------";
}
void dtkVisualizationViewVideoGLPrivate::createShaderProgram(void)
......@@ -187,6 +197,10 @@ void dtkVisualizationViewVideoGLPrivate::createTexture(void)
void dtkVisualizationViewVideoGLPrivate::initializeGL(void)
{
qDebug() << Q_FUNC_INFO << 1 << this->context << this->context->shareContext() << QOpenGLContext::globalShareContext();
qDebug() << Q_FUNC_INFO << 1 << this->context->format();
qDebug() << "--------------------------------------------";
QOpenGLFunctions::initializeOpenGLFunctions();
createShaderProgram();
......@@ -207,6 +221,12 @@ void dtkVisualizationViewVideoGLPrivate::initializeGL(void)
vao.create();
glClearColor(::bg.redF(), ::bg.greenF(), ::bg.blueF(), 1.f);
createGeometry();
qDebug() << Q_FUNC_INFO << 2 << this->context << this->context->shareContext() << QOpenGLContext::globalShareContext();
qDebug() << Q_FUNC_INFO << 2 << this->context->format();
qDebug() << "--------------------------------------------";
}
void dtkVisualizationViewVideoGLPrivate::resizeGL(int w, int h)
......@@ -228,15 +248,24 @@ void dtkVisualizationViewVideoGLPrivate::resizeGL(int w, int h)
void dtkVisualizationViewVideoGLPrivate::paintGL(void)
{
// this->context->makeCurrent();
qDebug() << Q_FUNC_INFO;
qDebug() << "Current context:" << QOpenGLWidget::context();
qDebug() << "Current context:" << QOpenGLWidget::context()->format();
qDebug() << " THIS context:" << this->context << this->context->shareContext() << QOpenGLContext::globalShareContext();
qDebug() << " THIS context:" << this->context->format();
qDebug() << "------------------------------------------";
if(this->buffer.isNull())
return;
createGeometry();
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
QOpenGLContext *context = QOpenGLContext::currentContext();
bool enable = context->hasExtension(QByteArrayLiteral("GL_KHR_debug"));
static QOpenGLDebugLogger *logger = new QOpenGLDebugLogger(this);
......@@ -247,11 +276,11 @@ void dtkVisualizationViewVideoGLPrivate::paintGL(void)
this->glBindTexture (GL_TEXTURE_2D, tex);
this->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
// #if defined(Q_OS_MAC)
// this->glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, this->buffer.width(), this->buffer.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, this->buffer.bits());
// #else
#if defined(Q_OS_MAC)
this->glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, this->buffer.width(), this->buffer.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, this->buffer.bits());
#else
this->glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, this->buffer.width(), this->buffer.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, this->buffer.bits());
// #endif
#endif
this->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
this->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
this->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
......@@ -301,8 +330,8 @@ dtkVisualizationViewVideoGL::dtkVisualizationViewVideoGL(QWidget *parent) : dtkW
{
d = new dtkVisualizationViewVideoGLPrivate(this);
d->q = this;
d->setVersion(4, 1, true);
d->setVersion(4, 3, true);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
......@@ -320,8 +349,9 @@ void dtkVisualizationViewVideoGL::setVersion( int major, int minor, bool debug)
QWidget *dtkVisualizationViewVideoGL::widget(void)
{
qDebug() << d->context();
qDebug() << d->format();
qDebug() << Q_FUNC_INFO << d->context << d->context->shareContext() << QOpenGLContext::globalShareContext();
qDebug() << Q_FUNC_INFO << d->format();
qDebug() << "--------------------------------------------";
return d;
}
......@@ -339,6 +369,7 @@ void dtkVisualizationViewVideoGL::setTitle(const QString& title)
void dtkVisualizationViewVideoGL::setImage(const QImage& image)
{
d->buffer = image.mirrored(false, true);
d->resizeGL(d->width(), d->height());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment