diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index cb3865d336..3a01367fc7 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -77,13 +77,6 @@ const glm::vec3 randVector() { return glm::vec3(randFloat() - 0.5f, randFloat() - 0.5f, randFloat() - 0.5f) * 2.0f; } -void renderCollisionOverlay(int width, int height, float magnitude, float red, float blue, float green) { - const float MIN_VISIBLE_COLLISION = 0.01f; - if (magnitude > MIN_VISIBLE_COLLISION) { - DependencyManager::get()->renderQuad(0, 0, width, height, glm::vec4(red, blue, green, magnitude)); - } -} - // Do some basic timing tests and report the results void runTimingTests() { // How long does it take to make a call to get the time? diff --git a/interface/src/Util.h b/interface/src/Util.h index 2599847f7e..e3938502d2 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -23,8 +23,6 @@ const glm::vec3 randVector(); void renderWorldBox(gpu::Batch& batch); -void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0); - void runTimingTests(); void runUnitTests(); diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 2d9db1abb7..875c7671e9 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -382,13 +382,15 @@ void SkeletonModel::renderJointConstraints(gpu::Batch& batch, int jointIndex) { } - renderOrientationDirections(jointIndex, position, _rotation * jointState.getRotation(), directionSize); + renderOrientationDirections(batch, jointIndex, position, _rotation * jointState.getRotation(), directionSize); jointIndex = joint.parentIndex; } while (jointIndex != -1 && geometry.joints.at(jointIndex).isFree); } -void SkeletonModel::renderOrientationDirections(int jointIndex, glm::vec3 position, const glm::quat& orientation, float size) { +void SkeletonModel::renderOrientationDirections(gpu::Batch& batch, int jointIndex, + glm::vec3 position, const glm::quat& orientation, float size) { + auto geometryCache = DependencyManager::get(); if (!_jointOrientationLines.contains(jointIndex)) { @@ -405,13 +407,13 @@ void SkeletonModel::renderOrientationDirections(int jointIndex, glm::vec3 positi glm::vec3 pFront = position + orientation * IDENTITY_FRONT * size; glm::vec3 red(1.0f, 0.0f, 0.0f); - geometryCache->renderLine(position, pRight, red, jointLineIDs._right); + geometryCache->renderLine(batch, position, pRight, red, jointLineIDs._right); glm::vec3 green(0.0f, 1.0f, 0.0f); - geometryCache->renderLine(position, pUp, green, jointLineIDs._up); + geometryCache->renderLine(batch, position, pUp, green, jointLineIDs._up); glm::vec3 blue(0.0f, 0.0f, 1.0f); - geometryCache->renderLine(position, pFront, blue, jointLineIDs._front); + geometryCache->renderLine(batch, position, pFront, blue, jointLineIDs._front); } diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index c4cd43b4df..ae52fb60e5 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -145,7 +145,8 @@ protected: private: void renderJointConstraints(gpu::Batch& batch, int jointIndex); - void renderOrientationDirections(int jointIndex, glm::vec3 position, const glm::quat& orientation, float size); + void renderOrientationDirections(gpu::Batch& batch, int jointIndex, + glm::vec3 position, const glm::quat& orientation, float size); struct OrientationLineIDs { int _up; diff --git a/interface/src/ui/ApplicationCompositor.cpp b/interface/src/ui/ApplicationCompositor.cpp index afdeb7b94e..2cae51de3e 100644 --- a/interface/src/ui/ApplicationCompositor.cpp +++ b/interface/src/ui/ApplicationCompositor.cpp @@ -529,7 +529,7 @@ void ApplicationCompositor::renderControllerPointers(gpu::Batch& batch) { glm::vec2 texCoordTopLeft(0.0f, 0.0f); glm::vec2 texCoordBottomRight(1.0f, 1.0f); - DependencyManager::get()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, + DependencyManager::get()->renderQuad(batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, glm::vec4(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f)); } diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index 721be0f402..7fd0f9be76 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -92,9 +92,12 @@ GLBackend::GLBackend() : { static std::once_flag once; std::call_once(once, [] { - qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); - qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); - qCDebug(gpulogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); + qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); + + qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); + + qCDebug(gpulogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); + qCDebug(gpulogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER)); #ifdef WIN32 @@ -143,15 +146,6 @@ void GLBackend::render(Batch& batch) { } } -void GLBackend::renderBatch(Batch& batch, bool syncCache) { - qCDebug(gpulogging) << "GLBackend::renderBatch : Deprecated call, don;t do it!!!"; - GLBackend backend; - if (syncCache) { - backend.syncCache(); - } - backend.render(batch); -} - bool GLBackend::checkGLError(const char* name) { GLenum error = glGetError(); if (!error) { diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index b3e905bf21..0e6f181028 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -38,15 +38,6 @@ public: // Let's try to avoid to do that as much as possible! virtual void syncCache(); - // Render Batch create a local Context and execute the batch with it - // WARNING: - // if syncCache is true, then the gpu::GLBackend will synchornize - // its cache with the current gl state and it's BAD - // If you know you don't rely on any state changed by naked gl calls then - // leave to false where it belongs - // if true, the needed resync IS EXPENSIVE - static void renderBatch(Batch& batch, bool syncCache = false); - static bool checkGLError(const char* name = nullptr); // Only checks in debug builds diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index e6f2b520c7..7da314cdf2 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -21,7 +21,6 @@ #include "AbstractViewStateInterface.h" #include "GeometryCache.h" -#include "RenderUtil.h" #include "TextureCache.h" #include "FramebufferCache.h" @@ -542,30 +541,34 @@ void DeferredLightingEffect::copyBack(RenderArgs* args) { auto framebufferCache = DependencyManager::get(); QSize framebufferSize = framebufferCache->getFrameBufferSize(); - batch.setFramebuffer(framebufferCache->getPrimaryFramebuffer()); - batch.setPipeline(_blitLightBuffer); - - batch.setResourceTexture(0, _copyFBO->getRenderBuffer(0)); - + // TODO why doesn't this blit work? It only seems to affect a small area below the rear view mirror. + auto destFbo = framebufferCache->getPrimaryFramebuffer(); +// gpu::Vec4i vp = args->_viewport; +// batch.blit(_copyFBO, vp, framebufferCache->getPrimaryFramebuffer(), vp); + batch.setFramebuffer(destFbo); + batch.setViewportTransform(args->_viewport); batch.setProjectionTransform(glm::mat4()); batch.setViewTransform(Transform()); - - float sMin = args->_viewport.x / (float)framebufferSize.width(); - float sWidth = args->_viewport.z / (float)framebufferSize.width(); - float tMin = args->_viewport.y / (float)framebufferSize.height(); - float tHeight = args->_viewport.w / (float)framebufferSize.height(); + { + float sMin = args->_viewport.x / (float)framebufferSize.width(); + float sWidth = args->_viewport.z / (float)framebufferSize.width(); + float tMin = args->_viewport.y / (float)framebufferSize.height(); + float tHeight = args->_viewport.w / (float)framebufferSize.height(); + Transform model; + batch.setPipeline(_blitLightBuffer); + model.setTranslation(glm::vec3(sMin, tMin, 0.0)); + model.setScale(glm::vec3(sWidth, tHeight, 1.0)); + batch.setModelTransform(model); + } - batch.setViewportTransform(args->_viewport); - - Transform model; - model.setTranslation(glm::vec3(sMin, tMin, 0.0)); - model.setScale(glm::vec3(sWidth, tHeight, 1.0)); - batch.setModelTransform(model); + GLenum buffers[3]; + int bufferCount = 0; + buffers[bufferCount++] = GL_COLOR_ATTACHMENT0; + batch._glDrawBuffers(bufferCount, buffers); + batch.setResourceTexture(0, _copyFBO->getRenderBuffer(0)); batch.draw(gpu::TRIANGLE_STRIP, 4); - - args->_context->syncCache(); args->_context->render(batch); framebufferCache->releaseFramebuffer(_copyFBO); } diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 6c03d57de3..c43cddff6e 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -54,12 +54,6 @@ const int NUM_TRIANGLES_PER_QUAD = 2; const int NUM_VERTICES_PER_TRIANGULATED_QUAD = NUM_VERTICES_PER_TRIANGLE * NUM_TRIANGLES_PER_QUAD; const int NUM_COORDS_PER_VERTEX = 3; -void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) { - gpu::Batch batch; - renderSphere(batch, radius, slices, stacks, color, solid, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) { bool registered = (id != UNKNOWN_ID); @@ -304,12 +298,6 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in } } -void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& color) { - gpu::Batch batch; - renderGrid(batch, xDivisions, yDivisions, color); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color) { IntPair key(xDivisions, yDivisions); Vec3Pair colorKey(glm::vec3(color.x, color.y, yDivisions), glm::vec3(color.z, color.y, xDivisions)); @@ -384,12 +372,6 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions batch.draw(gpu::LINES, vertices, 0); } -void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { - gpu::Batch batch; - renderGrid(batch, x, y, width, height, rows, cols, color, id); - gpu::GLBackend::renderBatch(batch); -} - // TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that?? void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { #ifdef WANT_DEBUG @@ -691,12 +673,6 @@ void GeometryCache::updateVertices(int id, const QVector& points, con #endif } -void GeometryCache::renderVertices(gpu::Primitive primitiveType, int id) { - gpu::Batch batch; - renderVertices(batch, primitiveType, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id) { BatchItemDetails& details = _registeredVertices[id]; if (details.isCreated) { @@ -706,12 +682,6 @@ void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveTy } } -void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { - gpu::Batch batch; - renderSolidCube(batch, size, color); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) { Vec2Pair colorKey(glm::vec2(color.x, color.y), glm::vec2(color.z, color.y)); const int FLOATS_PER_VERTEX = 3; @@ -833,12 +803,6 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve batch.drawIndexed(gpu::TRIANGLES, indices); } -void GeometryCache::renderWireCube(float size, const glm::vec4& color) { - gpu::Batch batch; - renderWireCube(batch, size, color); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) { Vec2Pair colorKey(glm::vec2(color.x, color.y),glm::vec2(color.z, color.y)); const int FLOATS_PER_VERTEX = 3; @@ -922,12 +886,6 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec batch.drawIndexed(gpu::LINES, indices); } -void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) { - gpu::Batch batch; - renderBevelCornersRect(batch, x, y, width, height, bevelDistance, color, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) { bool registered = (id != UNKNOWN_ID); Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance)); @@ -1029,12 +987,6 @@ void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int batch.draw(gpu::TRIANGLE_STRIP, details.vertices, 0); } -void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { - gpu::Batch batch; - renderQuad(batch, minCorner, maxCorner, color, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { bool registered = (id != UNKNOWN_ID); Vec4Pair key(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), color); @@ -1111,12 +1063,6 @@ void GeometryCache::renderUnitCube(gpu::Batch& batch) { renderSolidCube(batch, 1, color); } -void GeometryCache::renderUnitQuad(const glm::vec4& color, int id) { - gpu::Batch batch; - renderUnitQuad(batch, color, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderUnitQuad(gpu::Batch& batch, const glm::vec4& color, int id) { static const glm::vec2 topLeft(-1, 1); static const glm::vec2 bottomRight(1, -1); @@ -1126,14 +1072,6 @@ void GeometryCache::renderUnitQuad(gpu::Batch& batch, const glm::vec4& color, in } -void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, - const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, - const glm::vec4& color, int id) { - gpu::Batch batch; - renderQuad(batch, minCorner, maxCorner, texCoordMinCorner, texCoordMaxCorner, color, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, const glm::vec4& color, int id) { @@ -1214,12 +1152,6 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co batch.draw(gpu::QUADS, 4, 0); } -void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { - gpu::Batch batch; - renderQuad(batch, minCorner, maxCorner, color, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { bool registered = (id != UNKNOWN_ID); Vec3PairVec4 key(Vec3Pair(minCorner, maxCorner), color); @@ -1291,17 +1223,6 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co batch.draw(gpu::QUADS, 4, 0); } -void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft, - const glm::vec3& bottomRight, const glm::vec3& topRight, - const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, - const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight, - const glm::vec4& color, int id) { - gpu::Batch batch; - renderQuad(batch, topLeft, bottomLeft, bottomRight, topRight, texCoordTopLeft, texCoordBottomLeft, - texCoordBottomRight, texCoordTopRight, color, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft, const glm::vec3& bottomRight, const glm::vec3& topRight, const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, @@ -1395,12 +1316,6 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons batch.draw(gpu::QUADS, 4, 0); } -void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) { - gpu::Batch batch; - renderDashedLine(batch, start, end, color, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) { bool registered = (id != UNKNOWN_ID); Vec3PairVec2Pair key(Vec3Pair(start, end), Vec2Pair(glm::vec2(color.x, color.y), glm::vec2(color.z, color.w))); @@ -1555,13 +1470,6 @@ void GeometryCache::BatchItemDetails::clear() { stream.reset(); } -void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, - const glm::vec4& color1, const glm::vec4& color2, int id) { - gpu::Batch batch; - renderLine(batch, p1, p2, color1, color2, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, const glm::vec4& color1, const glm::vec4& color2, int id) { @@ -1646,12 +1554,6 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm batch.draw(gpu::LINES, 2, 0); } -void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color1, const glm::vec4& color2, int id) { - gpu::Batch batch; - renderLine(batch, p1, p2, color1, color2, id); - gpu::GLBackend::renderBatch(batch); -} - void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color1, const glm::vec4& color2, int id) { diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 147b4f8093..2f90c33adf 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -129,56 +129,35 @@ public: int allocateID() { return _nextID++; } static const int UNKNOWN_ID; - void renderSphere(float radius, int slices, int stacks, const glm::vec3& color, bool solid = true, int id = UNKNOWN_ID) - { renderSphere(radius, slices, stacks, glm::vec4(color, 1.0f), solid, id); } void renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec3& color, bool solid = true, int id = UNKNOWN_ID) { renderSphere(batch, radius, slices, stacks, glm::vec4(color, 1.0f), solid, id); } - void renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid = true, int id = UNKNOWN_ID); void renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid = true, int id = UNKNOWN_ID); - void renderGrid(int xDivisions, int yDivisions, const glm::vec4& color); void renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color); - void renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id = UNKNOWN_ID); void renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id = UNKNOWN_ID); - void renderSolidCube(float size, const glm::vec4& color); void renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color); - void renderWireCube(float size, const glm::vec4& color); void renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color); - void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id = UNKNOWN_ID); void renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id = UNKNOWN_ID); void renderUnitCube(gpu::Batch& batch); - void renderUnitQuad(const glm::vec4& color = glm::vec4(1), int id = UNKNOWN_ID); void renderUnitQuad(gpu::Batch& batch, const glm::vec4& color = glm::vec4(1), int id = UNKNOWN_ID); - void renderQuad(int x, int y, int width, int height, const glm::vec4& color, int id = UNKNOWN_ID) - { renderQuad(glm::vec2(x,y), glm::vec2(x + width, y + height), color, id); } void renderQuad(gpu::Batch& batch, int x, int y, int width, int height, const glm::vec4& color, int id = UNKNOWN_ID) { renderQuad(batch, glm::vec2(x,y), glm::vec2(x + width, y + height), color, id); } // TODO: I think there's a bug in this version of the renderQuad() that's not correctly rebuilding the vbos // if the color changes by the corners are the same, as evidenced by the audio meter which should turn white // when it's clipping - void renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID); void renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID); - void renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, - const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, - const glm::vec4& color, int id = UNKNOWN_ID); void renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, const glm::vec4& color, int id = UNKNOWN_ID); - void renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID); void renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id = UNKNOWN_ID); - void renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft, - const glm::vec3& bottomRight, const glm::vec3& topRight, - const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, - const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight, - const glm::vec4& color, int id = UNKNOWN_ID); void renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft, const glm::vec3& bottomRight, const glm::vec3& topRight, const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, @@ -186,53 +165,33 @@ public: const glm::vec4& color, int id = UNKNOWN_ID); - void renderLine(const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& color, int id = UNKNOWN_ID) - { renderLine(p1, p2, color, color, id); } void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& color, int id = UNKNOWN_ID) { renderLine(batch, p1, p2, color, color, id); } - void renderLine(const glm::vec3& p1, const glm::vec3& p2, - const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID) - { renderLine(p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); } void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID) { renderLine(batch, p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); } - void renderLine(const glm::vec3& p1, const glm::vec3& p2, - const glm::vec4& color, int id = UNKNOWN_ID) - { renderLine(p1, p2, color, color, id); } void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, const glm::vec4& color, int id = UNKNOWN_ID) { renderLine(batch, p1, p2, color, color, id); } - void renderLine(const glm::vec3& p1, const glm::vec3& p2, - const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID); void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID); - void renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id = UNKNOWN_ID); void renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id = UNKNOWN_ID); - void renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec3& color, int id = UNKNOWN_ID) - { renderLine(p1, p2, glm::vec4(color, 1.0f), id); } void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, const glm::vec3& color, int id = UNKNOWN_ID) { renderLine(batch, p1, p2, glm::vec4(color, 1.0f), id); } - void renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color, int id = UNKNOWN_ID) - { renderLine(p1, p2, color, color, id); } void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color, int id = UNKNOWN_ID) { renderLine(batch, p1, p2, color, color, id); } - void renderLine(const glm::vec2& p1, const glm::vec2& p2, - const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID) - { renderLine(p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); } void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID) { renderLine(batch, p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); } - void renderLine(const glm::vec2& p1, const glm::vec2& p2, - const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID); void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID); @@ -240,7 +199,6 @@ public: void updateVertices(int id, const QVector& points, const glm::vec4& color); void updateVertices(int id, const QVector& points, const QVector& texCoords, const glm::vec4& color); void renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id); - void renderVertices(gpu::Primitive primitiveType, int id); /// Loads geometry from the specified URL. /// \param fallback a fallback URL to load if the desired one is unavailable diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index bd33e75207..266cc46a07 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -916,7 +916,7 @@ void Model::removeFromScene(std::shared_ptr scene, render::Pendin _readyWhenAdded = false; } -void Model::renderDebugMeshBoxes() { +void Model::renderDebugMeshBoxes(gpu::Batch& batch) { int colorNdx = 0; _mutex.lock(); foreach(AABox box, _calculatedMeshBoxes) { @@ -965,7 +965,7 @@ void Model::renderDebugMeshBoxes() { { 0.0f, 0.5f, 0.5f, 1.0f } }; DependencyManager::get()->updateVertices(_debugMeshBoxesID, points, color[colorNdx]); - DependencyManager::get()->renderVertices(gpu::LINES, _debugMeshBoxesID); + DependencyManager::get()->renderVertices(batch, gpu::LINES, _debugMeshBoxesID); colorNdx++; } _mutex.unlock(); diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 30c5211990..3fb13c7089 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -386,7 +386,7 @@ private: // debug rendering support - void renderDebugMeshBoxes(); + void renderDebugMeshBoxes(gpu::Batch& batch); int _debugMeshBoxesID = GeometryCache::UNKNOWN_ID; // helper functions used by render() or renderInScene() diff --git a/libraries/render-utils/src/RenderUtil.cpp b/libraries/render-utils/src/RenderUtil.cpp deleted file mode 100644 index 44733418ff..0000000000 --- a/libraries/render-utils/src/RenderUtil.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -// RenderUtil.cpp -// interface/src/renderer -// -// Created by Andrzej Kapolka on 8/15/13. -// Copyright 2013 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 -#include "GeometryCache.h" - -#include "RenderUtil.h" - -void renderFullscreenQuad(float sMin, float sMax, float tMin, float tMax) { - glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f); - glm::vec2 topLeft(-1.0f, -1.0f); - glm::vec2 bottomRight(1.0f, 1.0f); - glm::vec2 texCoordTopLeft(sMin, tMin); - glm::vec2 texCoordBottomRight(sMax, tMax); - - DependencyManager::get()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, color); -} diff --git a/libraries/render-utils/src/RenderUtil.h b/libraries/render-utils/src/RenderUtil.h deleted file mode 100644 index b2f244733a..0000000000 --- a/libraries/render-utils/src/RenderUtil.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RenderUtil.h -// interface/src/renderer -// -// Created by Andrzej Kapolka on 8/15/13. -// Copyright 2013 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_RenderUtil_h -#define hifi_RenderUtil_h - -/// Renders a quad from (-1, -1, 0) to (1, 1, 0) with texture coordinates from (sMin, tMin) to (sMax, tMax). -void renderFullscreenQuad(float sMin = 0.0f, float sMax = 1.0f, float tMin = 0.0f, float tMax = 1.0f); - -#endif // hifi_RenderUtil_h diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index f86d15079d..1a6ea97b64 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -325,19 +325,6 @@ void ImageReader::run() { auto ntex = dynamic_cast(&*texture); if (ntex && (ntex->getType() == CUBE_TEXTURE)) { qCDebug(renderutils) << "Cube map size:" << _url << image.width() << image.height(); - } else { - - // enforce a fixed maximum area (1024 * 2048) - const int MAXIMUM_AREA_SIZE = 2097152; - if (imageArea > MAXIMUM_AREA_SIZE) { - float scaleRatio = sqrtf((float)MAXIMUM_AREA_SIZE) / sqrtf((float)imageArea); - int resizeWidth = static_cast(std::floor(scaleRatio * static_cast(image.width()))); - int resizeHeight = static_cast(std::floor(scaleRatio * static_cast(image.height()))); - qCDebug(renderutils) << "Image greater than maximum size:" << _url << image.width() << image.height() << - " scaled to:" << resizeWidth << resizeHeight; - image = image.scaled(resizeWidth, resizeHeight, Qt::IgnoreAspectRatio); - imageArea = image.width() * image.height(); - } } int opaquePixels = 0;