Fixing naming of GL classes

This commit is contained in:
Brad Davis 2015-11-29 00:42:46 -08:00
parent a94b6667b1
commit 0023c034c4
15 changed files with 65 additions and 62 deletions

View file

@ -78,7 +78,7 @@
#include <ObjectMotionState.h> #include <ObjectMotionState.h>
#include <OctalCode.h> #include <OctalCode.h>
#include <OctreeSceneStats.h> #include <OctreeSceneStats.h>
#include <gl/OffscreenGlCanvas.h> #include <gl/OffscreenGLCanvas.h>
#include <PathUtils.h> #include <PathUtils.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <PhysicsEngine.h> #include <PhysicsEngine.h>
@ -616,7 +616,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
// enable mouse tracking; otherwise, we only get drag events // enable mouse tracking; otherwise, we only get drag events
_glWidget->setMouseTracking(true); _glWidget->setMouseTracking(true);
_offscreenContext = new OffscreenGlCanvas(); _offscreenContext = new OffscreenGLCanvas();
_offscreenContext->create(_glWidget->context()->contextHandle()); _offscreenContext->create(_glWidget->context()->contextHandle());
_offscreenContext->makeCurrent(); _offscreenContext->makeCurrent();
initializeGL(); initializeGL();

View file

@ -65,7 +65,7 @@
#include "ui/ToolWindow.h" #include "ui/ToolWindow.h"
#include "UndoStackScriptingInterface.h" #include "UndoStackScriptingInterface.h"
class OffscreenGlCanvas; class OffscreenGLCanvas;
class GLCanvas; class GLCanvas;
class FaceTracker; class FaceTracker;
class MainWindow; class MainWindow;
@ -421,7 +421,7 @@ private:
bool _dependencyManagerIsSetup; bool _dependencyManagerIsSetup;
OffscreenGlCanvas* _offscreenContext { nullptr }; OffscreenGLCanvas* _offscreenContext { nullptr };
DisplayPluginPointer _displayPlugin; DisplayPluginPointer _displayPlugin;
InputPluginList _activeInputPlugins; InputPluginList _activeInputPlugins;

View file

@ -10,7 +10,6 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <gl/Config.h> #include <gl/Config.h>
#include <gl/GlWindow.h>
#include <GLMHelpers.h> #include <GLMHelpers.h>

View file

@ -14,7 +14,6 @@
#include <QMainWindow> #include <QMainWindow>
#include <QGLWidget> #include <QGLWidget>
#include <GLMHelpers.h> #include <GLMHelpers.h>
#include <gl/GlWindow.h>
#include <QEvent> #include <QEvent>
#include <QResizeEvent> #include <QResizeEvent>

View file

@ -8,15 +8,6 @@
#include "InterleavedStereoDisplayPlugin.h" #include "InterleavedStereoDisplayPlugin.h"
#include <QApplication>
#include <QDesktopWidget>
#include <gl/GlWindow.h>
#include <ViewFrustum.h>
#include <MatrixStack.h>
#include <gpu/GLBackend.h>
static const char * INTERLEAVED_TEXTURED_VS = R"VS(#version 410 core static const char * INTERLEAVED_TEXTURED_VS = R"VS(#version 410 core
#pragma line __LINE__ #pragma line __LINE__
@ -81,4 +72,4 @@ void InterleavedStereoDisplayPlugin::display(
_program->Bind(); _program->Bind();
Uniform<ivec2>(*_program, "textureSize").SetValue(sceneSize); Uniform<ivec2>(*_program, "textureSize").SetValue(sceneSize);
WindowOpenGLDisplayPlugin::display(finalTexture, sceneSize); WindowOpenGLDisplayPlugin::display(finalTexture, sceneSize);
} }

View file

@ -7,17 +7,7 @@
// //
#include "SideBySideStereoDisplayPlugin.h" #include "SideBySideStereoDisplayPlugin.h"
#include <GLMHelpers.h>
#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>
#include <gl/GlWindow.h>
#include <ViewFrustum.h>
#include <MatrixStack.h>
#include <gpu/GLBackend.h>
#include <plugins/PluginContainer.h>
const QString SideBySideStereoDisplayPlugin::NAME("3D TV - Side by Side Stereo"); const QString SideBySideStereoDisplayPlugin::NAME("3D TV - Side by Side Stereo");

View file

@ -87,6 +87,11 @@ public:
_recycler = recycler; _recycler = recycler;
} }
size_t depth() {
Lock lock(_mutex);
return _submits.size();
}
// Submit a new resource from the producer context // Submit a new resource from the producer context
// returns the number of prior submissions that were // returns the number of prior submissions that were
// never consumed before becoming available. // never consumed before becoming available.
@ -124,7 +129,7 @@ public:
} }
return result; return result;
} }
// If fetch returns a non-zero value, it's the responsibility of the // If fetch returns a non-zero value, it's the responsibility of the
// client to release it at some point // client to release it at some point
void release(T t, GLsync readSync = 0) { void release(T t, GLsync readSync = 0) {
@ -175,6 +180,7 @@ private:
// May be called on any thread, but must be inside a locked section // May be called on any thread, but must be inside a locked section
void pop(Deque& deque) { void pop(Deque& deque) {
Lock lock(_mutex);
auto& item = deque.front(); auto& item = deque.front();
_trash.push_front(item); _trash.push_front(item);
deque.pop_front(); deque.pop_front();

View file

@ -45,6 +45,14 @@ void GLWidget::initializeGL() {
setAutoBufferSwap(false); setAutoBufferSwap(false);
} }
void GLWidget::paintEvent(QPaintEvent* event) {
QWidget::paintEvent(event);
}
void GLWidget::resizeEvent(QResizeEvent* event) {
QWidget::resizeEvent(event);
}
bool GLWidget::event(QEvent* event) { bool GLWidget::event(QEvent* event) {
switch (event->type()) { switch (event->type()) {
case QEvent::MouseMove: case QEvent::MouseMove:

View file

@ -27,6 +27,8 @@ public:
protected: protected:
virtual void initializeGL() override; virtual void initializeGL() override;
virtual bool event(QEvent* event) override; virtual bool event(QEvent* event) override;
virtual void paintEvent(QPaintEvent* event) override;
virtual void resizeEvent(QResizeEvent* event) override;
private slots: private slots:
virtual bool eventFilter(QObject*, QEvent* event) override; virtual bool eventFilter(QObject*, QEvent* event) override;

View file

@ -6,17 +6,18 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "GlWindow.h" #include "GLWindow.h"
#include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLDebugLogger> #include <QtGui/QOpenGLDebugLogger>
#include "GLHelpers.h" #include "GLHelpers.h"
GlWindow::GlWindow(QOpenGLContext* shareContext) : GlWindow(getDefaultOpenGlSurfaceFormat(), shareContext) { void GLWindow::createContext(QOpenGLContext* shareContext) {
createContext(getDefaultOpenGlSurfaceFormat(), shareContext);
} }
GlWindow::GlWindow(const QSurfaceFormat& format, QOpenGLContext* shareContext) { void GLWindow::createContext(const QSurfaceFormat& format, QOpenGLContext* shareContext) {
setSurfaceType(QSurface::OpenGLSurface); setSurfaceType(QSurface::OpenGLSurface);
setFormat(format); setFormat(format);
_context = new QOpenGLContext; _context = new QOpenGLContext;
@ -27,13 +28,15 @@ GlWindow::GlWindow(const QSurfaceFormat& format, QOpenGLContext* shareContext) {
_context->create(); _context->create();
} }
GlWindow::~GlWindow() { GLWindow::~GLWindow() {
_context->doneCurrent(); if (_context) {
_context->deleteLater(); _context->doneCurrent();
_context = nullptr; _context->deleteLater();
_context = nullptr;
}
} }
bool GlWindow::makeCurrent() { bool GLWindow::makeCurrent() {
bool makeCurrentResult = _context->makeCurrent(this); bool makeCurrentResult = _context->makeCurrent(this);
Q_ASSERT(makeCurrentResult); Q_ASSERT(makeCurrentResult);
@ -49,11 +52,16 @@ bool GlWindow::makeCurrent() {
return makeCurrentResult; return makeCurrentResult;
} }
void GlWindow::doneCurrent() { void GLWindow::doneCurrent() {
_context->doneCurrent(); _context->doneCurrent();
} }
void GlWindow::swapBuffers() { void GLWindow::swapBuffers() {
_context->swapBuffers(this); _context->swapBuffers(this);
} }
QOpenGLContext* GLWindow::context() const {
return _context;
}

View file

@ -7,8 +7,8 @@
// //
#pragma once #pragma once
#ifndef hifi_GlWindow_h #ifndef hifi_GLWindow_h
#define hifi_GlWindow_h #define hifi_GLWindow_h
#include <mutex> #include <mutex>
#include <QtGui/QWindow> #include <QtGui/QWindow>
@ -16,14 +16,15 @@
class QOpenGLContext; class QOpenGLContext;
class QOpenGLDebugLogger; class QOpenGLDebugLogger;
class GlWindow : public QWindow { class GLWindow : public QWindow {
public: public:
GlWindow(QOpenGLContext* shareContext = nullptr); virtual ~GLWindow();
GlWindow(const QSurfaceFormat& format, QOpenGLContext* shareContext = nullptr); void createContext(QOpenGLContext* shareContext = nullptr);
virtual ~GlWindow(); void createContext(const QSurfaceFormat& format, QOpenGLContext* shareContext = nullptr);
bool makeCurrent(); bool makeCurrent();
void doneCurrent(); void doneCurrent();
void swapBuffers(); void swapBuffers();
QOpenGLContext* context() const;
private: private:
std::once_flag _reportOnce; std::once_flag _reportOnce;
QOpenGLContext* _context{ nullptr }; QOpenGLContext* _context{ nullptr };

View file

@ -1,5 +1,5 @@
// //
// OffscreenGlCanvas.cpp // OffscreenGLCanvas.cpp
// interface/src/renderer // interface/src/renderer
// //
// Created by Bradley Austin Davis on 2014/04/09. // Created by Bradley Austin Davis on 2014/04/09.
@ -10,7 +10,7 @@
// //
#include "OffscreenGlCanvas.h" #include "OffscreenGLCanvas.h"
#include <QtGui/QOffscreenSurface> #include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLDebugLogger> #include <QtGui/QOpenGLDebugLogger>
@ -18,10 +18,10 @@
#include "GLHelpers.h" #include "GLHelpers.h"
OffscreenGlCanvas::OffscreenGlCanvas() : _context(new QOpenGLContext), _offscreenSurface(new QOffscreenSurface){ OffscreenGLCanvas::OffscreenGLCanvas() : _context(new QOpenGLContext), _offscreenSurface(new QOffscreenSurface){
} }
OffscreenGlCanvas::~OffscreenGlCanvas() { OffscreenGLCanvas::~OffscreenGLCanvas() {
#ifdef DEBUG #ifdef DEBUG
if (_logger) { if (_logger) {
makeCurrent(); makeCurrent();
@ -32,7 +32,7 @@ OffscreenGlCanvas::~OffscreenGlCanvas() {
_context->doneCurrent(); _context->doneCurrent();
} }
void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) { void OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
if (nullptr != sharedContext) { if (nullptr != sharedContext) {
sharedContext->doneCurrent(); sharedContext->doneCurrent();
_context->setShareContext(sharedContext); _context->setShareContext(sharedContext);
@ -45,7 +45,7 @@ void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) {
} }
bool OffscreenGlCanvas::makeCurrent() { bool OffscreenGLCanvas::makeCurrent() {
bool result = _context->makeCurrent(_offscreenSurface); bool result = _context->makeCurrent(_offscreenSurface);
Q_ASSERT(result); Q_ASSERT(result);
@ -72,7 +72,7 @@ bool OffscreenGlCanvas::makeCurrent() {
return result; return result;
} }
void OffscreenGlCanvas::doneCurrent() { void OffscreenGLCanvas::doneCurrent() {
_context->doneCurrent(); _context->doneCurrent();
} }

View file

@ -1,5 +1,5 @@
// //
// OffscreenGlCanvas.h // OffscreenGLCanvas.h
// interface/src/renderer // interface/src/renderer
// //
// Created by Bradley Austin Davis on 2014/04/09. // Created by Bradley Austin Davis on 2014/04/09.
@ -9,8 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#pragma once #pragma once
#ifndef hifi_OffscreenGlCanvas_h #ifndef hifi_OffscreenGLCanvas_h
#define hifi_OffscreenGlCanvas_h #define hifi_OffscreenGLCanvas_h
#include <mutex> #include <mutex>
#include <QObject> #include <QObject>
@ -19,10 +19,10 @@ class QOpenGLContext;
class QOffscreenSurface; class QOffscreenSurface;
class QOpenGLDebugLogger; class QOpenGLDebugLogger;
class OffscreenGlCanvas : public QObject { class OffscreenGLCanvas : public QObject {
public: public:
OffscreenGlCanvas(); OffscreenGLCanvas();
~OffscreenGlCanvas(); ~OffscreenGLCanvas();
void create(QOpenGLContext* sharedContext = nullptr); void create(QOpenGLContext* sharedContext = nullptr);
bool makeCurrent(); bool makeCurrent();
void doneCurrent(); void doneCurrent();
@ -40,4 +40,4 @@ protected:
}; };
#endif // hifi_OffscreenGlCanvas_h #endif // hifi_OffscreenGLCanvas_h

View file

@ -23,7 +23,7 @@
#include <NumericalConstants.h> #include <NumericalConstants.h>
#include "GLEscrow.h" #include "GLEscrow.h"
#include "OffscreenGlCanvas.h" #include "OffscreenGLCanvas.h"
// FIXME move to threaded rendering with Qt 5.5 // FIXME move to threaded rendering with Qt 5.5
//#define QML_THREADED //#define QML_THREADED
@ -64,12 +64,12 @@ static const QEvent::Type STOP = QEvent::Type(QEvent::User + 4);
static const QEvent::Type UPDATE = QEvent::Type(QEvent::User + 5); static const QEvent::Type UPDATE = QEvent::Type(QEvent::User + 5);
#endif #endif
class OffscreenQmlRenderer : public OffscreenGlCanvas { class OffscreenQmlRenderer : public OffscreenGLCanvas {
friend class OffscreenQmlSurface; friend class OffscreenQmlSurface;
public: public:
OffscreenQmlRenderer(OffscreenQmlSurface* surface, QOpenGLContext* shareContext) : _surface(surface) { OffscreenQmlRenderer(OffscreenQmlSurface* surface, QOpenGLContext* shareContext) : _surface(surface) {
OffscreenGlCanvas::create(shareContext); OffscreenGLCanvas::create(shareContext);
#ifdef QML_THREADED #ifdef QML_THREADED
// Qt 5.5 // Qt 5.5
_renderControl->prepareThread(_renderThread); _renderControl->prepareThread(_renderThread);

View file

@ -12,7 +12,6 @@
#include <QtWidgets/QMainWindow> #include <QtWidgets/QMainWindow>
#include <QtOpenGL/QGLWidget> #include <QtOpenGL/QGLWidget>
#include <GLMHelpers.h> #include <GLMHelpers.h>
#include <gl/GlWindow.h>
#include <QEvent> #include <QEvent>
#include <QtGui/QResizeEvent> #include <QtGui/QResizeEvent>
#include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLContext>