Move GL utilities out to their own library

This commit is contained in:
Brad Davis 2015-10-27 11:04:50 -07:00
parent bc07de3892
commit 5cbb2562cd
38 changed files with 66 additions and 62 deletions

View file

@ -96,7 +96,8 @@ else()
endif()
# link required hifi libraries
link_hifi_libraries(shared octree environment gpu procedural model render fbx networking model-networking entities avatars
link_hifi_libraries(shared octree environment gpu gl procedural model render
fbx networking model-networking entities avatars
audio audio-client animation script-engine physics
render-utils entities-renderer ui auto-updater
plugins display-plugins input-plugins)

View file

@ -70,7 +70,7 @@
#include <ObjectMotionState.h>
#include <OctalCode.h>
#include <OctreeSceneStats.h>
#include <OffscreenGlCanvas.h>
#include <gl/OffscreenGlCanvas.h>
#include <PathUtils.h>
#include <PerfStat.h>
#include <PhysicsEngine.h>

View file

@ -27,7 +27,7 @@
#include <RegisteredMetaTypes.h>
#include <AbstractViewStateInterface.h>
#include <OffscreenQmlSurface.h>
#include <gl/OffscreenQmlSurface.h>
static const float DPI = 30.47f;
static const float INCHES_TO_METERS = 1.0f / 39.3701f;

View file

@ -1,6 +1,6 @@
set(TARGET_NAME display-plugins)
setup_hifi_library(OpenGL)
link_hifi_libraries(shared plugins gpu render-utils)
link_hifi_libraries(shared plugins gpu gl)
target_opengl()

View file

@ -12,8 +12,8 @@
#include <QPoint>
#include <functional>
#include "gpu/GPUConfig.h"
#include "GLMHelpers.h"
#include <gl/Config.h>
#include <GLMHelpers.h>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>

View file

@ -9,7 +9,7 @@
#include <QOpenGLContext>
#include <QCoreApplication>
#include <GlWindow.h>
#include <gl/GlWindow.h>
#include <GLMHelpers.h>

View file

@ -7,10 +7,10 @@
//
#pragma once
#include <QTimer>
#include "DisplayPlugin.h"
#include "OglplusHelpers.h"
#include <QTimer>
#include <gl/OglplusHelpers.h>
class GlWindow;
class QOpenGLContext;

View file

@ -12,7 +12,7 @@
#include <QMainWindow>
#include <QGLWidget>
#include <GLMHelpers.h>
#include <GlWindow.h>
#include <gl/GlWindow.h>
#include <QEvent>
#include <QResizeEvent>
#include <QOpenGLContext>
@ -20,7 +20,7 @@
#include <QScreen>
#include <PerfStat.h>
#include <OglplusHelpers.h>
#include <gl/OglplusHelpers.h>
#include <ViewFrustum.h>
#include "plugins/PluginContainer.h"

View file

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

View file

@ -11,7 +11,7 @@
#include <QApplication>
#include <QDesktopWidget>
#include <GlWindow.h>
#include <gl/GlWindow.h>
#include <ViewFrustum.h>
#include <MatrixStack.h>

View file

@ -12,7 +12,7 @@
#include <QDesktopWidget>
#include <QScreen>
#include <GlWindow.h>
#include <gl/GlWindow.h>
#include <ViewFrustum.h>
#include <MatrixStack.h>

View file

@ -1,7 +1,7 @@
set(TARGET_NAME entities-renderer)
AUTOSCRIBE_SHADER_LIB(gpu model render render-utils)
setup_hifi_library(Widgets Network Script)
link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils)
link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils gl)
target_bullet()

View file

@ -37,7 +37,7 @@ PolyLineEntityItem(entityItemID, properties) {
gpu::PipelinePointer RenderablePolyLineEntityItem::_pipeline;
gpu::Stream::FormatPointer RenderablePolyLineEntityItem::_format;
gpu::TexturePointer RenderablePolyLineEntityItem::_texture;
GLint RenderablePolyLineEntityItem::PAINTSTROKE_GPU_SLOT;
int32_t RenderablePolyLineEntityItem::PAINTSTROKE_GPU_SLOT;
void RenderablePolyLineEntityItem::createPipeline() {
static const int NORMAL_OFFSET = 12;

View file

@ -18,7 +18,6 @@
#include "RenderableEntityItem.h"
#include <GeometryCache.h>
#include <QReadWriteLock>
#include <gpu/GPUConfig.h>
class RenderablePolyLineEntityItem : public PolyLineEntityItem {
@ -34,7 +33,7 @@ public:
static gpu::PipelinePointer _pipeline;
static gpu::Stream::FormatPointer _format;
static gpu::TexturePointer _texture;
static GLint PAINTSTROKE_GPU_SLOT;
static int32_t PAINTSTROKE_GPU_SLOT;
protected:
void updateGeometry();

View file

@ -18,7 +18,7 @@
#include <DeferredLightingEffect.h>
#include <GeometryCache.h>
#include <PerfStat.h>
#include <OffscreenQmlSurface.h>
#include <gl/OffscreenQmlSurface.h>
#include <AbstractViewStateInterface.h>
#include <GLMHelpers.h>
#include <PathUtils.h>

View file

@ -0,0 +1,7 @@
set(TARGET_NAME gl)
setup_hifi_library(OpenGL Qml Quick)
link_hifi_libraries(shared)
target_glew()
target_opengl()
target_oglplus()

View file

@ -8,9 +8,10 @@
#include "GlWindow.h"
#include <QOpenGLContext>
#include <QOpenGLDebugLogger>
#include <GLHelpers.h>
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLDebugLogger>
#include "GLHelpers.h"
GlWindow::GlWindow(QOpenGLContext* shareContext) : GlWindow(getDefaultOpenGlSurfaceFormat(), shareContext) {
}

View file

@ -12,10 +12,11 @@
#include "OffscreenGlCanvas.h"
#include <GLHelpers.h>
#include <QOpenGLDebugLogger>
#include <QOpenGLContext>
#include <QOffscreenSurface>
#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLDebugLogger>
#include <QtGui/QOpenGLContext>
#include "GLHelpers.h"
OffscreenGlCanvas::OffscreenGlCanvas() : _context(new QOpenGLContext), _offscreenSurface(new QOffscreenSurface){
}

View file

@ -23,7 +23,6 @@
#include "GLEscrow.h"
#include "OffscreenGlCanvas.h"
#include "AbstractViewStateInterface.h"
// FIXME move to threaded rendering with Qt 5.5
// #define QML_THREADED
@ -207,9 +206,7 @@ private:
qreal pixelRatio = 1.0;
if (_renderControl && _renderControl->_renderWindow) {
pixelRatio = _renderControl->_renderWindow->devicePixelRatio();
} else {
pixelRatio = AbstractViewStateInterface::instance()->getDevicePixelRatio();
}
}
uvec2 newOffscreenSize = toGlm(newSize * pixelRatio);
_textures.setSize(newOffscreenSize);

View file

@ -1,7 +1,7 @@
set(TARGET_NAME gpu)
AUTOSCRIBE_SHADER_LIB(gpu)
setup_hifi_library()
link_hifi_libraries(shared)
link_hifi_libraries(shared gl)
target_glew()
target_opengl()

View file

@ -18,7 +18,7 @@
#include <utility>
#include <list>
#include "GPUConfig.h"
#include <gl/Config.h>
#include "Context.h"

View file

@ -19,8 +19,6 @@
#include <FSTReader.h>
#include <NumericalConstants.h>
#include <gpu/GLBackend.h>
#include "TextureCache.h"
#include "RenderUtilsLogging.h"
@ -573,8 +571,8 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions
if (!_gridBuffers.contains(key)) {
auto verticesBuffer = std::make_shared<gpu::Buffer>();
GLfloat* vertexData = new GLfloat[vertices * 2];
GLfloat* vertex = vertexData;
float* vertexData = new float[vertices * 2];
float* vertex = vertexData;
for (int i = 0; i <= xDivisions; i++) {
float x = (float)i / xDivisions;
@ -595,7 +593,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions
*(vertex++) = y;
}
verticesBuffer->append(sizeof(GLfloat) * vertices * 2, (gpu::Byte*) vertexData);
verticesBuffer->append(sizeof(float) * vertices * 2, (gpu::Byte*) vertexData);
delete[] vertexData;
_gridBuffers[key] = verticesBuffer;
@ -674,8 +672,8 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h
_alternateGridBuffers[key] = verticesBuffer;
}
GLfloat* vertexData = new GLfloat[vertices * 2];
GLfloat* vertex = vertexData;
float* vertexData = new float[vertices * 2];
float* vertex = vertexData;
int dx = width / cols;
int dy = height / rows;
@ -702,7 +700,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h
tx += dx;
}
verticesBuffer->append(sizeof(GLfloat) * vertices * 2, (gpu::Byte*) vertexData);
verticesBuffer->append(sizeof(float) * vertices * 2, (gpu::Byte*) vertexData);
delete[] vertexData;
}
@ -785,8 +783,8 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con
((int(color.z * 255.0f) & 0xFF) << 16) |
((int(color.w * 255.0f) & 0xFF) << 24);
GLfloat* vertexData = new GLfloat[details.vertices * FLOATS_PER_VERTEX];
GLfloat* vertex = vertexData;
float* vertexData = new float[details.vertices * FLOATS_PER_VERTEX];
float* vertex = vertexData;
int* colorData = new int[details.vertices];
int* colorDataAt = colorData;
@ -798,7 +796,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con
*(colorDataAt++) = compactColor;
}
details.verticesBuffer->append(sizeof(GLfloat) * FLOATS_PER_VERTEX * details.vertices, (gpu::Byte*) vertexData);
details.verticesBuffer->append(sizeof(float) * FLOATS_PER_VERTEX * details.vertices, (gpu::Byte*) vertexData);
details.colorBuffer->append(sizeof(int) * details.vertices, (gpu::Byte*) colorData);
delete[] vertexData;
delete[] colorData;
@ -846,8 +844,8 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
((int(color.z * 255.0f) & 0xFF) << 16) |
((int(color.w * 255.0f) & 0xFF) << 24);
GLfloat* vertexData = new GLfloat[details.vertices * FLOATS_PER_VERTEX];
GLfloat* vertex = vertexData;
float* vertexData = new float[details.vertices * FLOATS_PER_VERTEX];
float* vertex = vertexData;
int* colorData = new int[details.vertices];
int* colorDataAt = colorData;
@ -860,7 +858,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
*(colorDataAt++) = compactColor;
}
details.verticesBuffer->append(sizeof(GLfloat) * FLOATS_PER_VERTEX * details.vertices, (gpu::Byte*) vertexData);
details.verticesBuffer->append(sizeof(float) * FLOATS_PER_VERTEX * details.vertices, (gpu::Byte*) vertexData);
details.colorBuffer->append(sizeof(int) * details.vertices, (gpu::Byte*) colorData);
delete[] vertexData;
delete[] colorData;
@ -912,8 +910,8 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
((int(color.z * 255.0f) & 0xFF) << 16) |
((int(color.w * 255.0f) & 0xFF) << 24);
GLfloat* vertexData = new GLfloat[details.vertices * FLOATS_PER_VERTEX];
GLfloat* vertex = vertexData;
float* vertexData = new float[details.vertices * FLOATS_PER_VERTEX];
float* vertex = vertexData;
int* colorData = new int[details.vertices];
int* colorDataAt = colorData;
@ -930,7 +928,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
*(colorDataAt++) = compactColor;
}
details.verticesBuffer->append(sizeof(GLfloat) * FLOATS_PER_VERTEX * details.vertices, (gpu::Byte*) vertexData);
details.verticesBuffer->append(sizeof(float) * FLOATS_PER_VERTEX * details.vertices, (gpu::Byte*) vertexData);
details.colorBuffer->append(sizeof(int) * details.vertices, (gpu::Byte*) colorData);
delete[] vertexData;
delete[] colorData;
@ -997,7 +995,7 @@ void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
GLfloat vertexBuffer[NUM_FLOATS]; // only vertices, no normals because we're a 2D quad
float vertexBuffer[NUM_FLOATS]; // only vertices, no normals because we're a 2D quad
int vertexPoint = 0;
// Triangle strip points
@ -1438,8 +1436,8 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start,
int* colorData = new int[details.vertices];
int* colorDataAt = colorData;
GLfloat* vertexData = new GLfloat[details.vertices * FLOATS_PER_VERTEX];
GLfloat* vertex = vertexData;
float* vertexData = new float[details.vertices * FLOATS_PER_VERTEX];
float* vertex = vertexData;
glm::vec3 point = start;
*(vertex++) = point.x;
@ -1465,7 +1463,7 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start,
*(vertex++) = end.z;
*(colorDataAt++) = compactColor;
details.verticesBuffer->append(sizeof(GLfloat) * FLOATS_PER_VERTEX * details.vertices, (gpu::Byte*) vertexData);
details.verticesBuffer->append(sizeof(float) * FLOATS_PER_VERTEX * details.vertices, (gpu::Byte*) vertexData);
details.colorBuffer->append(sizeof(int) * details.vertices, (gpu::Byte*) colorData);
delete[] vertexData;
delete[] colorData;

View file

@ -1,3 +1,3 @@
set(TARGET_NAME ui)
setup_hifi_library(OpenGL Network Qml Quick Script XmlPatterns)
link_hifi_libraries(render-utils shared)
link_hifi_libraries(shared networking gl)

View file

@ -12,7 +12,7 @@
#ifndef hifi_OffscreenUi_h
#define hifi_OffscreenUi_h
#include "OffscreenQmlSurface.h"
#include <gl/OffscreenQmlSurface.h>
#include <QMessageBox>
#include <DependencyManager.h>

View file

@ -3,5 +3,5 @@ AUTOSCRIBE_SHADER_LIB(gpu model render-utils)
# This is not a testcase -- just set it up as a regular hifi project
setup_hifi_project(Quick Gui OpenGL Script Widgets)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
link_hifi_libraries(networking gpu procedural shared fbx model model-networking animation script-engine render-utils )
link_hifi_libraries(networking gl gpu procedural shared fbx model model-networking animation script-engine render-utils )
copy_dlls_beside_windows_executable()

View file

@ -6,6 +6,6 @@ setup_hifi_project(Quick Gui OpenGL)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
# link in the shared libraries
link_hifi_libraries(render-utils gpu shared)
link_hifi_libraries(render-utils gl gpu shared)
copy_dlls_beside_windows_executable()

View file

@ -8,8 +8,8 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
#include_oglplus()
# link in the shared libraries
link_hifi_libraries(shared octree environment gpu model render fbx networking entities
script-engine physics
link_hifi_libraries(shared octree environment gl gpu model render fbx networking entities
script-engine physics
render-utils entities-renderer)
include_directories("${PROJECT_BINARY_DIR}/../../libraries/gpu/")

View file

@ -20,7 +20,7 @@
#include <QDir>
#include <QGuiApplication>
#include <GLHelpers.h>
#include <gl/GLHelpers.h>
#include "../model/Skybox_vert.h"
#include "../model/Skybox_frag.h"

View file

@ -11,6 +11,6 @@ if (WIN32)
endif()
# link in the shared libraries
link_hifi_libraries(ui render-utils gpu shared)
link_hifi_libraries(shared networking gl gpu ui)
copy_dlls_beside_windows_executable()