mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:08:51 +02:00
Merge pull request #6554 from Atlante45/warnings
Last of the OpenGL warnings on OS X
This commit is contained in:
commit
15c4dbfb11
7 changed files with 141 additions and 49 deletions
40
libraries/render-utils/src/QOpenGLContextWrapper.cpp
Normal file
40
libraries/render-utils/src/QOpenGLContextWrapper.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// QOpenGLContextWrapper.cpp
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Clement on 12/4/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "QOpenGLContextWrapper.h"
|
||||||
|
|
||||||
|
#include <QOpenGLContext>
|
||||||
|
|
||||||
|
|
||||||
|
QOpenGLContextWrapper::QOpenGLContextWrapper() :
|
||||||
|
_context(new QOpenGLContext)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QOpenGLContextWrapper::setFormat(const QSurfaceFormat& format) {
|
||||||
|
_context->setFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QOpenGLContextWrapper::create() {
|
||||||
|
return _context->create();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QOpenGLContextWrapper::swapBuffers(QSurface* surface) {
|
||||||
|
_context->swapBuffers(surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QOpenGLContextWrapper::makeCurrent(QSurface* surface) {
|
||||||
|
return _context->makeCurrent(surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QOpenGLContextWrapper::doneCurrent() {
|
||||||
|
_context->doneCurrent();
|
||||||
|
}
|
33
libraries/render-utils/src/QOpenGLContextWrapper.h
Normal file
33
libraries/render-utils/src/QOpenGLContextWrapper.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
//
|
||||||
|
// QOpenGLContextWrapper.h
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Clement on 12/4/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_QOpenGLContextWrapper_h
|
||||||
|
#define hifi_QOpenGLContextWrapper_h
|
||||||
|
|
||||||
|
class QOpenGLContext;
|
||||||
|
class QSurface;
|
||||||
|
class QSurfaceFormat;
|
||||||
|
|
||||||
|
class QOpenGLContextWrapper {
|
||||||
|
public:
|
||||||
|
QOpenGLContextWrapper();
|
||||||
|
|
||||||
|
void setFormat(const QSurfaceFormat& format);
|
||||||
|
bool create();
|
||||||
|
void swapBuffers(QSurface* surface);
|
||||||
|
bool makeCurrent(QSurface* surface);
|
||||||
|
void doneCurrent();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QOpenGLContext* _context { nullptr };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_QOpenGLContextWrapper_h
|
24
libraries/render-utils/src/QOpenGLDebugLoggerWrapper.cpp
Normal file
24
libraries/render-utils/src/QOpenGLDebugLoggerWrapper.cpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// QOpenGLDebugLoggerWrapper.cpp
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Clement on 12/4/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "QOpenGLDebugLoggerWrapper.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QOpenGLDebugLogger>
|
||||||
|
|
||||||
|
void setupDebugLogger(QObject* window) {
|
||||||
|
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(window);
|
||||||
|
logger->initialize(); // initializes in the current context, i.e. ctx
|
||||||
|
logger->enableMessages();
|
||||||
|
QObject::connect(logger, &QOpenGLDebugLogger::messageLogged, window, [&](const QOpenGLDebugMessage & debugMessage) {
|
||||||
|
qDebug() << debugMessage;
|
||||||
|
});
|
||||||
|
}
|
19
libraries/render-utils/src/QOpenGLDebugLoggerWrapper.h
Normal file
19
libraries/render-utils/src/QOpenGLDebugLoggerWrapper.h
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
//
|
||||||
|
// QOpenGLDebugLoggerWrapper.h
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Clement on 12/4/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_QOpenGLDebugLoggerWrapper_h
|
||||||
|
#define hifi_QOpenGLDebugLoggerWrapper_h
|
||||||
|
|
||||||
|
class QObject;
|
||||||
|
|
||||||
|
void setupDebugLogger(QObject* window);
|
||||||
|
|
||||||
|
#endif // hifi_QOpenGLDebugLoggerWrapper_h
|
|
@ -33,9 +33,8 @@
|
||||||
#include <gpu/StandardShaderLib.h>
|
#include <gpu/StandardShaderLib.h>
|
||||||
#include <gpu/GLBackend.h>
|
#include <gpu/GLBackend.h>
|
||||||
|
|
||||||
// Must come after GL headers
|
#include <QOpenGLContextWrapper.h>
|
||||||
#include <QtGui/QOpenGLContext>
|
#include <QOpenGLDebugLoggerWrapper.h>
|
||||||
#include <QtGui/QOpenGLDebugLogger>
|
|
||||||
|
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
@ -118,7 +117,7 @@ gpu::Stream::FormatPointer& getInstancedSolidStreamFormat();
|
||||||
class QTestWindow : public QWindow {
|
class QTestWindow : public QWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QOpenGLContext* _qGlContext{ nullptr };
|
QOpenGLContextWrapper _qGlContext;
|
||||||
QSize _size;
|
QSize _size;
|
||||||
|
|
||||||
gpu::ContextPointer _context;
|
gpu::ContextPointer _context;
|
||||||
|
@ -151,19 +150,12 @@ public:
|
||||||
|
|
||||||
setFormat(format);
|
setFormat(format);
|
||||||
|
|
||||||
_qGlContext = new QOpenGLContext;
|
_qGlContext.setFormat(format);
|
||||||
_qGlContext->setFormat(format);
|
_qGlContext.create();
|
||||||
_qGlContext->create();
|
|
||||||
|
|
||||||
show();
|
show();
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
setupDebugLogger(this);
|
||||||
logger->initialize(); // initializes in the current context, i.e. ctx
|
|
||||||
connect(logger, &QOpenGLDebugLogger::messageLogged, [](const QOpenGLDebugMessage& message){
|
|
||||||
qDebug() << message;
|
|
||||||
});
|
|
||||||
logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
|
|
||||||
|
|
||||||
|
|
||||||
gpu::Context::init<gpu::GLBackend>();
|
gpu::Context::init<gpu::GLBackend>();
|
||||||
_context = std::make_shared<gpu::Context>();
|
_context = std::make_shared<gpu::Context>();
|
||||||
|
@ -371,7 +363,7 @@ public:
|
||||||
geometryCache->renderWireCube(batch);
|
geometryCache->renderWireCube(batch);
|
||||||
|
|
||||||
_context->render(batch);
|
_context->render(batch);
|
||||||
_qGlContext->swapBuffers(this);
|
_qGlContext.swapBuffers(this);
|
||||||
|
|
||||||
fps.increment();
|
fps.increment();
|
||||||
if (fps.elapsed() >= 0.5f) {
|
if (fps.elapsed() >= 0.5f) {
|
||||||
|
@ -381,7 +373,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeCurrent() {
|
void makeCurrent() {
|
||||||
_qGlContext->makeCurrent(this);
|
_qGlContext.makeCurrent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include <gpu/GLBackend.h>
|
#include <gpu/GLBackend.h>
|
||||||
|
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContextWrapper.h>
|
||||||
#include <QOpenGLDebugLogger>
|
#include <QOpenGLDebugLoggerWrapper.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
@ -77,7 +77,7 @@ const QString& getQmlDir() {
|
||||||
class QTestWindow : public QWindow {
|
class QTestWindow : public QWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QOpenGLContext* _context{ nullptr };
|
QOpenGLContextWrapper _context;
|
||||||
QSize _size;
|
QSize _size;
|
||||||
//TextRenderer* _textRenderer[4];
|
//TextRenderer* _textRenderer[4];
|
||||||
RateCounter fps;
|
RateCounter fps;
|
||||||
|
@ -104,9 +104,8 @@ public:
|
||||||
|
|
||||||
setFormat(format);
|
setFormat(format);
|
||||||
|
|
||||||
_context = new QOpenGLContext;
|
_context.setFormat(format);
|
||||||
_context->setFormat(format);
|
_context.create();
|
||||||
_context->create();
|
|
||||||
|
|
||||||
show();
|
show();
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
@ -114,15 +113,7 @@ public:
|
||||||
gpu::Context::init<gpu::GLBackend>();
|
gpu::Context::init<gpu::GLBackend>();
|
||||||
|
|
||||||
|
|
||||||
{
|
setupDebugLogger(this);
|
||||||
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
|
||||||
logger->initialize(); // initializes in the current context, i.e. ctx
|
|
||||||
logger->enableMessages();
|
|
||||||
connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
|
|
||||||
qDebug() << debugMessage;
|
|
||||||
});
|
|
||||||
// logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
|
|
||||||
}
|
|
||||||
qDebug() << (const char*)glGetString(GL_VERSION);
|
qDebug() << (const char*)glGetString(GL_VERSION);
|
||||||
|
|
||||||
//_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
|
//_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
|
||||||
|
@ -147,7 +138,7 @@ public:
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void makeCurrent() {
|
void makeCurrent() {
|
||||||
_context->makeCurrent(this);
|
_context.makeCurrent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -185,7 +176,7 @@ void QTestWindow::draw() {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
|
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
|
||||||
|
|
||||||
_context->swapBuffers(this);
|
_context.swapBuffers(this);
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
fps.increment();
|
fps.increment();
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
#include <gpu/GLBackend.h>
|
#include <gpu/GLBackend.h>
|
||||||
|
|
||||||
#include <QOpenGLDebugLogger>
|
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
@ -22,6 +20,9 @@
|
||||||
|
|
||||||
#include <gl/GLHelpers.h>
|
#include <gl/GLHelpers.h>
|
||||||
|
|
||||||
|
#include <QOpenGLDebugLoggerWrapper.h>
|
||||||
|
#include <QOpenGLContextWrapper.h>
|
||||||
|
|
||||||
#include "../model/Skybox_vert.h"
|
#include "../model/Skybox_vert.h"
|
||||||
#include "../model/Skybox_frag.h"
|
#include "../model/Skybox_frag.h"
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@
|
||||||
// Create a simple OpenGL window that renders text in various ways
|
// Create a simple OpenGL window that renders text in various ways
|
||||||
class QTestWindow : public QWindow {
|
class QTestWindow : public QWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QOpenGLContext* _context{ nullptr };
|
QOpenGLContextWrapper _context;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void renderText();
|
void renderText();
|
||||||
|
@ -130,22 +131,14 @@ public:
|
||||||
setSurfaceType(QSurface::OpenGLSurface);
|
setSurfaceType(QSurface::OpenGLSurface);
|
||||||
QSurfaceFormat format = getDefaultOpenGLSurfaceFormat();
|
QSurfaceFormat format = getDefaultOpenGLSurfaceFormat();
|
||||||
setFormat(format);
|
setFormat(format);
|
||||||
_context = new QOpenGLContext;
|
_context.setFormat(format);
|
||||||
_context->setFormat(format);
|
_context.create();
|
||||||
_context->create();
|
|
||||||
|
|
||||||
show();
|
show();
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
|
||||||
gpu::Context::init<gpu::GLBackend>();
|
gpu::Context::init<gpu::GLBackend>();
|
||||||
{
|
setupDebugLogger(this);
|
||||||
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
|
||||||
logger->initialize(); // initializes in the current context, i.e. ctx
|
|
||||||
logger->enableMessages();
|
|
||||||
connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
|
|
||||||
qDebug() << debugMessage;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
resize(QSize(800, 600));
|
resize(QSize(800, 600));
|
||||||
}
|
}
|
||||||
|
@ -155,7 +148,7 @@ public:
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void makeCurrent() {
|
void makeCurrent() {
|
||||||
_context->makeCurrent(this);
|
_context.makeCurrent(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,7 +241,7 @@ void QTestWindow::draw() {
|
||||||
testShaderBuild(polyvox_vert, polyvox_frag);
|
testShaderBuild(polyvox_vert, polyvox_frag);
|
||||||
|
|
||||||
});
|
});
|
||||||
_context->swapBuffers(this);
|
_context.swapBuffers(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||||
|
|
Loading…
Reference in a new issue