mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-19 08:18:05 +02:00
Merge remote-tracking branch 'upstream/master' into plugins
This commit is contained in:
commit
901dd77f05
16 changed files with 47 additions and 257 deletions
|
@ -318,11 +318,15 @@ var toolBar = (function () {
|
|||
print("Resize failed: timed out waiting for model (" + url + ") to load");
|
||||
}
|
||||
} else {
|
||||
entityProperties.dimensions = naturalDimensions;
|
||||
Entities.editEntity(entityId, entityProperties);
|
||||
Entities.editEntity(entityId, { dimensions: naturalDimensions });
|
||||
|
||||
// Reset selection so that the selection overlays will be updated
|
||||
selectionManager.setSelections([entityId]);
|
||||
}
|
||||
}
|
||||
|
||||
selectionManager.setSelections([entityId]);
|
||||
|
||||
Script.setTimeout(resize, RESIZE_INTERVAL);
|
||||
} else {
|
||||
print("Can't add model: Model would be out of bounds.");
|
||||
|
|
|
@ -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<GeometryCache>()->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?
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -376,13 +376,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<GeometryCache>();
|
||||
|
||||
if (!_jointOrientationLines.contains(jointIndex)) {
|
||||
|
@ -399,13 +401,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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -146,7 +146,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;
|
||||
|
|
|
@ -531,7 +531,7 @@ void ApplicationCompositor::renderControllerPointers(gpu::Batch& batch) {
|
|||
glm::vec2 texCoordTopLeft(0.0f, 0.0f);
|
||||
glm::vec2 texCoordBottomRight(1.0f, 1.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
||||
glm::vec4(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f));
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<FramebufferCache>();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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<glm::vec3>& 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) {
|
||||
|
||||
|
|
|
@ -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<glm::vec3>& points, const glm::vec4& color);
|
||||
void updateVertices(int id, const QVector<glm::vec3>& points, const QVector<glm::vec2>& 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
|
||||
|
|
|
@ -946,7 +946,7 @@ void Model::removeFromScene(std::shared_ptr<render::Scene> scene, render::Pendin
|
|||
_readyWhenAdded = false;
|
||||
}
|
||||
|
||||
void Model::renderDebugMeshBoxes() {
|
||||
void Model::renderDebugMeshBoxes(gpu::Batch& batch) {
|
||||
int colorNdx = 0;
|
||||
_mutex.lock();
|
||||
foreach(AABox box, _calculatedMeshBoxes) {
|
||||
|
@ -995,7 +995,7 @@ void Model::renderDebugMeshBoxes() {
|
|||
{ 0.0f, 0.5f, 0.5f, 1.0f } };
|
||||
|
||||
DependencyManager::get<GeometryCache>()->updateVertices(_debugMeshBoxesID, points, color[colorNdx]);
|
||||
DependencyManager::get<GeometryCache>()->renderVertices(gpu::LINES, _debugMeshBoxesID);
|
||||
DependencyManager::get<GeometryCache>()->renderVertices(batch, gpu::LINES, _debugMeshBoxesID);
|
||||
colorNdx++;
|
||||
}
|
||||
_mutex.unlock();
|
||||
|
|
|
@ -399,7 +399,7 @@ private:
|
|||
|
||||
|
||||
// debug rendering support
|
||||
void renderDebugMeshBoxes();
|
||||
void renderDebugMeshBoxes(gpu::Batch& batch);
|
||||
int _debugMeshBoxesID = GeometryCache::UNKNOWN_ID;
|
||||
|
||||
// helper functions used by render() or renderInScene()
|
||||
|
|
|
@ -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 <DependencyManager.h>
|
||||
#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<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, color);
|
||||
}
|
|
@ -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
|
|
@ -325,19 +325,6 @@ void ImageReader::run() {
|
|||
auto ntex = dynamic_cast<NetworkTexture*>(&*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<int>(std::floor(scaleRatio * static_cast<float>(image.width())));
|
||||
int resizeHeight = static_cast<int>(std::floor(scaleRatio * static_cast<float>(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;
|
||||
|
|
Loading…
Reference in a new issue