mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-09 05:32:46 +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/GLBackend.h>
|
||||
|
||||
// Must come after GL headers
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtGui/QOpenGLDebugLogger>
|
||||
#include <QOpenGLContextWrapper.h>
|
||||
#include <QOpenGLDebugLoggerWrapper.h>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PathUtils.h>
|
||||
|
@ -118,7 +117,7 @@ gpu::Stream::FormatPointer& getInstancedSolidStreamFormat();
|
|||
class QTestWindow : public QWindow {
|
||||
Q_OBJECT
|
||||
|
||||
QOpenGLContext* _qGlContext{ nullptr };
|
||||
QOpenGLContextWrapper _qGlContext;
|
||||
QSize _size;
|
||||
|
||||
gpu::ContextPointer _context;
|
||||
|
@ -151,19 +150,12 @@ public:
|
|||
|
||||
setFormat(format);
|
||||
|
||||
_qGlContext = new QOpenGLContext;
|
||||
_qGlContext->setFormat(format);
|
||||
_qGlContext->create();
|
||||
_qGlContext.setFormat(format);
|
||||
_qGlContext.create();
|
||||
|
||||
show();
|
||||
makeCurrent();
|
||||
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
||||
logger->initialize(); // initializes in the current context, i.e. ctx
|
||||
connect(logger, &QOpenGLDebugLogger::messageLogged, [](const QOpenGLDebugMessage& message){
|
||||
qDebug() << message;
|
||||
});
|
||||
logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
|
||||
|
||||
setupDebugLogger(this);
|
||||
|
||||
gpu::Context::init<gpu::GLBackend>();
|
||||
_context = std::make_shared<gpu::Context>();
|
||||
|
@ -371,7 +363,7 @@ public:
|
|||
geometryCache->renderWireCube(batch);
|
||||
|
||||
_context->render(batch);
|
||||
_qGlContext->swapBuffers(this);
|
||||
_qGlContext.swapBuffers(this);
|
||||
|
||||
fps.increment();
|
||||
if (fps.elapsed() >= 0.5f) {
|
||||
|
@ -381,7 +373,7 @@ public:
|
|||
}
|
||||
|
||||
void makeCurrent() {
|
||||
_qGlContext->makeCurrent(this);
|
||||
_qGlContext.makeCurrent(this);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
#include <gpu/GLBackend.h>
|
||||
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLDebugLogger>
|
||||
#include <QOpenGLContextWrapper.h>
|
||||
#include <QOpenGLDebugLoggerWrapper.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QElapsedTimer>
|
||||
|
@ -77,7 +77,7 @@ const QString& getQmlDir() {
|
|||
class QTestWindow : public QWindow {
|
||||
Q_OBJECT
|
||||
|
||||
QOpenGLContext* _context{ nullptr };
|
||||
QOpenGLContextWrapper _context;
|
||||
QSize _size;
|
||||
//TextRenderer* _textRenderer[4];
|
||||
RateCounter fps;
|
||||
|
@ -104,9 +104,8 @@ public:
|
|||
|
||||
setFormat(format);
|
||||
|
||||
_context = new QOpenGLContext;
|
||||
_context->setFormat(format);
|
||||
_context->create();
|
||||
_context.setFormat(format);
|
||||
_context.create();
|
||||
|
||||
show();
|
||||
makeCurrent();
|
||||
|
@ -114,15 +113,7 @@ public:
|
|||
gpu::Context::init<gpu::GLBackend>();
|
||||
|
||||
|
||||
{
|
||||
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);
|
||||
}
|
||||
setupDebugLogger(this);
|
||||
qDebug() << (const char*)glGetString(GL_VERSION);
|
||||
|
||||
//_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
|
||||
|
@ -147,7 +138,7 @@ public:
|
|||
|
||||
void draw();
|
||||
void makeCurrent() {
|
||||
_context->makeCurrent(this);
|
||||
_context.makeCurrent(this);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -185,7 +176,7 @@ void QTestWindow::draw() {
|
|||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
|
||||
|
||||
_context->swapBuffers(this);
|
||||
_context.swapBuffers(this);
|
||||
glFinish();
|
||||
|
||||
fps.increment();
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
#include <gpu/GLBackend.h>
|
||||
|
||||
#include <QOpenGLDebugLogger>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QResizeEvent>
|
||||
#include <QTimer>
|
||||
|
@ -22,6 +20,9 @@
|
|||
|
||||
#include <gl/GLHelpers.h>
|
||||
|
||||
#include <QOpenGLDebugLoggerWrapper.h>
|
||||
#include <QOpenGLContextWrapper.h>
|
||||
|
||||
#include "../model/Skybox_vert.h"
|
||||
#include "../model/Skybox_frag.h"
|
||||
|
||||
|
@ -120,7 +121,7 @@
|
|||
// Create a simple OpenGL window that renders text in various ways
|
||||
class QTestWindow : public QWindow {
|
||||
Q_OBJECT
|
||||
QOpenGLContext* _context{ nullptr };
|
||||
QOpenGLContextWrapper _context;
|
||||
|
||||
protected:
|
||||
void renderText();
|
||||
|
@ -130,22 +131,14 @@ public:
|
|||
setSurfaceType(QSurface::OpenGLSurface);
|
||||
QSurfaceFormat format = getDefaultOpenGLSurfaceFormat();
|
||||
setFormat(format);
|
||||
_context = new QOpenGLContext;
|
||||
_context->setFormat(format);
|
||||
_context->create();
|
||||
_context.setFormat(format);
|
||||
_context.create();
|
||||
|
||||
show();
|
||||
makeCurrent();
|
||||
|
||||
gpu::Context::init<gpu::GLBackend>();
|
||||
{
|
||||
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;
|
||||
});
|
||||
}
|
||||
setupDebugLogger(this);
|
||||
makeCurrent();
|
||||
resize(QSize(800, 600));
|
||||
}
|
||||
|
@ -155,7 +148,7 @@ public:
|
|||
|
||||
void draw();
|
||||
void makeCurrent() {
|
||||
_context->makeCurrent(this);
|
||||
_context.makeCurrent(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -248,7 +241,7 @@ void QTestWindow::draw() {
|
|||
testShaderBuild(polyvox_vert, polyvox_frag);
|
||||
|
||||
});
|
||||
_context->swapBuffers(this);
|
||||
_context.swapBuffers(this);
|
||||
}
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||
|
|
Loading…
Reference in a new issue