rough pass at adding color to geometry cache

This commit is contained in:
ZappoMan 2015-01-13 20:53:05 -08:00
parent 1b0a5c881b
commit e6388a65b9
42 changed files with 321 additions and 335 deletions

View file

@ -2769,7 +2769,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
// draw a red sphere
float originSphereRadius = 0.05f;
glColor3f(1,0,0);
DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
// also, metavoxels
if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) {

View file

@ -263,7 +263,7 @@ void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data)
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, 100, 50, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); //Draw a unit sphere
glDepthMask(GL_TRUE);
program->release();

View file

@ -1973,7 +1973,6 @@ SphereRenderer::SphereRenderer() {
void SphereRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor) {
Sphere* sphere = static_cast<Sphere*>(_spanner);
const QColor& color = sphere->getColor();
glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF());
glPushMatrix();
const glm::vec3& translation = sphere->getTranslation();
@ -1982,7 +1981,8 @@ void SphereRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor
glm::vec3 axis = glm::axis(rotation);
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(sphere->getScale(), 32, 32);
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(sphere->getScale(), 32, 32,
glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()));
glPopMatrix();
}
@ -1993,7 +1993,6 @@ CuboidRenderer::CuboidRenderer() {
void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor) {
Cuboid* cuboid = static_cast<Cuboid*>(_spanner);
const QColor& color = cuboid->getColor();
glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF());
glPushMatrix();
const glm::vec3& translation = cuboid->getTranslation();
@ -2003,7 +2002,8 @@ void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
glScalef(1.0f, cuboid->getAspectY(), cuboid->getAspectZ());
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(cuboid->getScale() * 2.0f);
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(cuboid->getScale() * 2.0f,
glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()));
glPopMatrix();
}

View file

@ -56,23 +56,19 @@ void renderWorldBox() {
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(MARKER_DISTANCE, 0, 0);
glColor3f(red.x, red.y, red.z);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, red);
glPopMatrix();
glPushMatrix();
glTranslatef(0, MARKER_DISTANCE, 0);
glColor3f(green.x, green.y, green.z);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, green);
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0, MARKER_DISTANCE);
glColor3f(blue.x, blue.y, blue.z);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, blue);
glPopMatrix();
glPushMatrix();
glColor3f(grey.x, grey.y, grey.z);
glTranslatef(MARKER_DISTANCE, 0, MARKER_DISTANCE);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, grey);
glPopMatrix();
}
@ -120,15 +116,10 @@ void drawText(int x, int y, float scale, float radians, int mono,
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) {
glColor4f(red, blue, green, magnitude);
DependencyManager::get<GeometryCache>()->renderQuad(0, 0, width, height);
DependencyManager::get<GeometryCache>()->renderQuad(0, 0, width, height, glm::vec4(red, blue, green, magnitude));
}
}
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance) {
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(x, y, width, height, bevelDistance);
}
// Do some basic timing tests and report the results
void runTimingTests() {
// How long does it take to make a call to get the time?

View file

@ -27,8 +27,6 @@ void drawText(int x, int y, float scale, float radians, int mono,
void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0);
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance);
void runTimingTests();
float loadSetting(QSettings* settings, const char* name, float defaultValue);

View file

@ -50,13 +50,12 @@ void AudioIOStatsRenderer::render(const float* color, int width, int height) {
int statsHeight = STATS_HEIGHT_PER_LINE * lines;
static const float backgroundColor[4] = { 0.2f, 0.2f, 0.2f, 0.6f };
static const glm::vec4 backgroundColor = { 0.2f, 0.2f, 0.2f, 0.6f };
int x = std::max((width - (int)STATS_WIDTH) / 2, 0);
int y = std::max((height - CENTERED_BACKGROUND_HEIGHT) / 2, 0);
int w = STATS_WIDTH;
int h = statsHeight;
glColor4fv(backgroundColor);
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h);
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h, backgroundColor);
glColor4f(1, 1, 1, 1);
int horizontalOffset = x + 5;

View file

@ -111,11 +111,11 @@ void AudioScope::render(int width, int height) {
return;
}
static const float backgroundColor[4] = { 0.4f, 0.4f, 0.4f, 0.6f };
static const float gridColor[4] = { 0.7f, 0.7f, 0.7f, 1.0f };
static const float inputColor[4] = { 0.3f, 1.0f, 0.3f, 1.0f };
static const float outputLeftColor[4] = { 1.0f, 0.3f, 0.3f, 1.0f };
static const float outputRightColor[4] = { 0.3f, 0.3f, 1.0f, 1.0f };
static const glm::vec4 backgroundColor = { 0.4f, 0.4f, 0.4f, 0.6f };
static const glm::vec4 gridColor = { 0.7f, 0.7f, 0.7f, 1.0f };
static const glm::vec4 inputColor = { 0.3f, 1.0f, 0.3f, 1.0f };
static const glm::vec4 outputLeftColor = { 1.0f, 0.3f, 0.3f, 1.0f };
static const glm::vec4 outputRightColor = { 0.3f, 0.3f, 1.0f, 1.0f };
static const int gridRows = 2;
int gridCols = _framesPerScope;
@ -132,21 +132,15 @@ void AudioScope::render(int width, int height) {
renderLineStrip(_outputRightD, outputRightColor, x, y, _samplesPerScope, _scopeOutputOffset, _scopeOutputRight);
}
void AudioScope::renderBackground(const float* color, int x, int y, int width, int height) {
glColor4fv(color);
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height);
glColor4f(1, 1, 1, 1);
void AudioScope::renderBackground(const glm::vec4& color, int x, int y, int width, int height) {
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height, color);
}
void AudioScope::renderGrid(const float* color, int x, int y, int width, int height, int rows, int cols) {
glColor4fv(color);
DependencyManager::get<GeometryCache>()->renderGrid(x, y, width, height, rows, cols, _audioScopeGrid);
glColor4f(1, 1, 1, 1);
void AudioScope::renderGrid(const glm::vec4& color, int x, int y, int width, int height, int rows, int cols) {
DependencyManager::get<GeometryCache>()->renderGrid(x, y, width, height, rows, cols, color, _audioScopeGrid);
}
void AudioScope::renderLineStrip(int id, const float* color, int x, int y, int n, int offset, const QByteArray* byteArray) {
glColor4fv(color);
void AudioScope::renderLineStrip(int id, const glm::vec4& color, int x, int y, int n, int offset, const QByteArray* byteArray) {
int16_t sample;
int16_t* samples = ((int16_t*) byteArray->data()) + offset;
@ -200,7 +194,7 @@ void AudioScope::renderLineStrip(int id, const float* color, int x, int y, int n
}
geometryCache->updateVertices(id, points);
geometryCache->updateVertices(id, points, color);
geometryCache->renderVertices(GL_LINE_STRIP, id);
glColor4f(1, 1, 1, 1);

View file

@ -12,6 +12,8 @@
#ifndef hifi_AudioScope_h
#define hifi_AudioScope_h
#include <glm/glm.hpp>
#include <DependencyManager.h>
#include <QByteArray>
@ -46,9 +48,9 @@ private slots:
private:
// Audio scope methods for rendering
static void renderBackground(const float* color, int x, int y, int width, int height);
void renderGrid(const float* color, int x, int y, int width, int height, int rows, int cols);
void renderLineStrip(int id, const float* color, int x, int y, int n, int offset, const QByteArray* byteArray);
static void renderBackground(const glm::vec4& color, int x, int y, int width, int height);
void renderGrid(const glm::vec4& color, int x, int y, int width, int height, int rows, int cols);
void renderLineStrip(int id, const glm::vec4& color, int x, int y, int n, int offset, const QByteArray* byteArray);
// Audio scope methods for data acquisition
int addBufferToScope(QByteArray* byteArray, int frameOffset, const int16_t* source, int sourceSamples,

View file

@ -56,17 +56,19 @@ void AudioToolBox::render(int x, int y, bool boxed) {
glBindTexture(GL_TEXTURE_2D, _boxTextureId);
glm::vec4 quadColor;
if (isClipping) {
glColor3f(1.0f, 0.0f, 0.0f);
quadColor = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
} else {
glColor3f(0.41f, 0.41f, 0.41f);
quadColor = glm::vec4(0.41f, 0.41f, 0.41f, 1.0f);
}
glm::vec2 topLeft(boxBounds.left(), boxBounds.top());
glm::vec2 bottomRight(boxBounds.right(), boxBounds.bottom());
glm::vec2 texCoordTopLeft(1,1);
glm::vec2 texCoordBottomRight(0,0);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
}
float iconColor = 1.0f;
@ -92,14 +94,14 @@ void AudioToolBox::render(int x, int y, bool boxed) {
iconColor = PULSE_MIN + (PULSE_MAX - PULSE_MIN) * pulseFactor;
}
glColor3f(iconColor, iconColor, iconColor);
glm::vec4 quadColor(iconColor, iconColor, iconColor, 1.0f);
glm::vec2 topLeft(_iconBounds.left(), _iconBounds.top());
glm::vec2 bottomRight(_iconBounds.right(), _iconBounds.bottom());
glm::vec2 texCoordTopLeft(1,1);
glm::vec2 texCoordBottomRight(0,0);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
glDisable(GL_TEXTURE_2D);
}

View file

@ -402,15 +402,14 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
if (_isLookAtTarget && Menu::getInstance()->isOptionChecked(MenuOption::RenderFocusIndicator)) {
const float LOOK_AT_INDICATOR_RADIUS = 0.03f;
const float LOOK_AT_INDICATOR_OFFSET = 0.22f;
const float LOOK_AT_INDICATOR_COLOR[] = { 0.8f, 0.0f, 0.0f, 0.75f };
const glm::vec4 LOOK_AT_INDICATOR_COLOR = { 0.8f, 0.0f, 0.0f, 0.75f };
glPushMatrix();
glColor4fv(LOOK_AT_INDICATOR_COLOR);
if (_displayName.isEmpty() || _displayNameAlpha == 0.0f) {
glTranslatef(_position.x, getDisplayNamePosition().y, _position.z);
} else {
glTranslatef(_position.x, getDisplayNamePosition().y + LOOK_AT_INDICATOR_OFFSET, _position.z);
}
DependencyManager::get<GeometryCache>()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15, LOOK_AT_INDICATOR_COLOR);
glPopMatrix();
}
}
@ -434,11 +433,11 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
if (renderMode == NORMAL_RENDER_MODE && (sphereRadius > MIN_SPHERE_SIZE) &&
(angle < MAX_SPHERE_ANGLE) && (angle > MIN_SPHERE_ANGLE)) {
glColor4f(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.0f - angle / MAX_SPHERE_ANGLE);
glPushMatrix();
glTranslatef(_position.x, _position.y, _position.z);
glScalef(height, height, height);
DependencyManager::get<GeometryCache>()->renderSphere(sphereRadius, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(sphereRadius, 15, 15,
glm::vec4(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.0f - angle / MAX_SPHERE_ANGLE));
glPopMatrix();
}
@ -569,14 +568,12 @@ void Avatar::renderBillboard() {
float size = getBillboardSize();
glScalef(size, size, size);
glColor3f(1.0f, 1.0f, 1.0f);
glm::vec2 topLeft(-1.0f, -1.0f);
glm::vec2 bottomRight(1.0f, 1.0f);
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(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
glPopMatrix();
@ -703,8 +700,8 @@ void Avatar::renderDisplayName() {
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
glColor4f(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA);
renderBevelCornersRect(left, bottom, right - left, top - bottom, 3);
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(left, bottom, right - left, top - bottom, 3,
glm::vec4(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA));
glColor4f(0.93f, 0.93f, 0.93f, _displayNameAlpha);
QByteArray ba = _displayName.toLocal8Bit();
@ -946,7 +943,8 @@ int Avatar::parseDataAtOffset(const QByteArray& packet, int offset) {
int Avatar::_jointConesID = GeometryCache::UNKNOWN_ID;
// render a makeshift cone section that serves as a body part connecting joint spheres
void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2) {
void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
float radius1, float radius2, const glm::vec4& color) {
GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>();
@ -991,7 +989,7 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
// TODO: this is really inefficient constantly recreating these vertices buffers. It would be
// better if the avatars cached these buffers for each of the joints they are rendering
geometryCache->updateVertices(_jointConesID, points);
geometryCache->updateVertices(_jointConesID, points, color);
geometryCache->renderVertices(GL_TRIANGLES, _jointConesID);
}
}

View file

@ -133,7 +133,8 @@ public:
virtual int parseDataAtOffset(const QByteArray& packet, int offset);
static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2);
static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
float radius1, float radius2, const glm::vec4& color);
virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) { }

View file

@ -115,8 +115,7 @@ void Hand::render(bool isMine, Model::RenderMode renderMode) {
glm::vec3 position = palm.getPosition();
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glColor3f(0.0f, 1.0f, 0.0f);
DependencyManager::get<GeometryCache>()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10);
DependencyManager::get<GeometryCache>()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10, glm::vec3(0.0f, 1.0f, 0.0f));
glPopMatrix();
}
}
@ -152,8 +151,7 @@ void Hand::renderHandTargets(bool isMine) {
glTranslatef(targetPosition.x, targetPosition.y, targetPosition.z);
const float collisionRadius = 0.05f;
glColor4f(0.5f,0.5f,0.5f, alpha);
DependencyManager::get<GeometryCache>()->renderSphere(collisionRadius, 10, 10, false);
DependencyManager::get<GeometryCache>()->renderSphere(collisionRadius, 10, 10, glm::vec4(0.5f,0.5f,0.5f, alpha), false);
glPopMatrix();
}
}
@ -167,7 +165,6 @@ void Hand::renderHandTargets(bool isMine) {
for (size_t i = 0; i < getNumPalms(); ++i) {
PalmData& palm = getPalms()[i];
if (palm.isActive()) {
glColor4f(handColor.r, handColor.g, handColor.b, alpha);
glm::vec3 tip = palm.getTipPosition();
glm::vec3 root = palm.getPosition();
@ -175,13 +172,13 @@ void Hand::renderHandTargets(bool isMine) {
myAvatar->scaleVectorRelativeToPosition(tip);
myAvatar->scaleVectorRelativeToPosition(root);
Avatar::renderJointConnectingCone(root, tip, PALM_FINGER_ROD_RADIUS, PALM_FINGER_ROD_RADIUS);
Avatar::renderJointConnectingCone(root, tip, PALM_FINGER_ROD_RADIUS, PALM_FINGER_ROD_RADIUS, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
// Render sphere at palm/finger root
glm::vec3 offsetFromPalm = root + palm.getNormal() * PALM_DISK_THICKNESS;
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f);
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
glPushMatrix();
glTranslatef(root.x, root.y, root.z);
DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f);
DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f, glm::vec4(handColor.r, handColor.g, handColor.b, alpha));
glPopMatrix();
}
}

View file

@ -381,17 +381,15 @@ void MyAvatar::renderDebugBodyPoints() {
// Torso Sphere
position = torsoPosition;
glPushMatrix();
glColor4f(0, 1, 0, .5f);
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<GeometryCache>()->renderSphere(0.2f, 10.0f, 10.0f);
DependencyManager::get<GeometryCache>()->renderSphere(0.2f, 10.0f, 10.0f, glm::vec4(0, 1, 0, .5f));
glPopMatrix();
// Head Sphere
position = headPosition;
glPushMatrix();
glColor4f(0, 1, 0, .5f);
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<GeometryCache>()->renderSphere(0.15f, 10.0f, 10.0f);
DependencyManager::get<GeometryCache>()->renderSphere(0.15f, 10.0f, 10.0f, glm::vec4(0, 1, 0, .5f));
glPopMatrix();
}
@ -1940,14 +1938,13 @@ void MyAvatar::renderLaserPointers() {
for (size_t i = 0; i < getHand()->getNumPalms(); ++i) {
PalmData& palm = getHand()->getPalms()[i];
if (palm.isActive()) {
glColor4f(0, 1, 1, 1);
glm::vec3 tip = getLaserPointerTipPosition(&palm);
glm::vec3 root = palm.getPosition();
//Scale the root vector with the avatar scale
scaleVectorRelativeToPosition(root);
Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS);
Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS, glm::vec4(0, 1, 1, 1));
}
}
}

View file

@ -354,7 +354,7 @@ void SkeletonModel::renderJointConstraints(int jointIndex) {
} else {
otherAxis.x = 1.0f;
}
glColor4f(otherAxis.r, otherAxis.g, otherAxis.b, 0.75f);
glm::vec4 color(otherAxis.r, otherAxis.g, otherAxis.b, 0.75f);
QVector<glm::vec3> points;
points << glm::vec3(0.0f, 0.0f, 0.0f);
@ -366,7 +366,7 @@ void SkeletonModel::renderJointConstraints(int jointIndex) {
}
// TODO: this is really inefficient constantly recreating these vertices buffers. It would be
// better if the skeleton model cached these buffers for each of the joints they are rendering
geometryCache->updateVertices(_triangleFanID, points);
geometryCache->updateVertices(_triangleFanID, points, color);
geometryCache->renderVertices(GL_TRIANGLE_FAN, _triangleFanID);
}
@ -601,10 +601,8 @@ void SkeletonModel::renderRagdoll() {
glm::vec3 position = points[i]._position - simulationTranslation;
glTranslatef(position.x, position.y, position.z);
// draw each point as a yellow hexagon with black border
glColor4f(0.0f, 0.0f, 0.0f, alpha);
geometryCache->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
glColor4f(1.0f, 1.0f, 0.0f, alpha);
geometryCache->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.0f, 0.0f, 0.0f, alpha));
geometryCache->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(1.0f, 1.0f, 0.0f, alpha));
glPopMatrix();
}
glPopMatrix();
@ -953,9 +951,8 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
_boundingShape.getEndPoint(endPoint);
endPoint = endPoint - _translation;
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
glColor4f(0.6f, 0.6f, 0.8f, alpha);
GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>();
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.6f, 0.6f, 0.8f, alpha));
// draw a yellow sphere at the capsule startpoint
glm::vec3 startPoint;
@ -963,13 +960,11 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
startPoint = startPoint - _translation;
glm::vec3 axis = endPoint - startPoint;
glTranslatef(-axis.x, -axis.y, -axis.z);
glColor4f(0.8f, 0.8f, 0.6f, alpha);
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.8f, 0.8f, 0.6f, alpha));
// draw a green cylinder between the two points
glm::vec3 origin(0.0f);
glColor4f(0.6f, 0.8f, 0.6f, alpha);
Avatar::renderJointConnectingCone( origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius());
Avatar::renderJointConnectingCone( origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha));
glPopMatrix();
}
@ -998,8 +993,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
glm::vec3 position = shape->getTranslation() - simulationTranslation;
glTranslatef(position.x, position.y, position.z);
// draw a grey sphere at shape position
glColor4f(0.75f, 0.75f, 0.75f, alpha);
geometryCache->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.75f, 0.75f, 0.75f, alpha));
} else if (shape->getType() == CAPSULE_SHAPE) {
CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
@ -1008,8 +1002,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
capsule->getEndPoint(endPoint);
endPoint = endPoint - simulationTranslation;
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
glColor4f(0.6f, 0.6f, 0.8f, alpha);
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.6f, 0.6f, 0.8f, alpha));
// draw a yellow sphere at the capsule startpoint
glm::vec3 startPoint;
@ -1017,13 +1010,11 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
startPoint = startPoint - simulationTranslation;
glm::vec3 axis = endPoint - startPoint;
glTranslatef(-axis.x, -axis.y, -axis.z);
glColor4f(0.8f, 0.8f, 0.6f, alpha);
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
geometryCache->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.8f, 0.8f, 0.6f, alpha));
// draw a green cylinder between the two points
glm::vec3 origin(0.0f);
glColor4f(0.6f, 0.8f, 0.6f, alpha);
Avatar::renderJointConnectingCone( origin, axis, capsule->getRadius(), capsule->getRadius());
Avatar::renderJointConnectingCone( origin, axis, capsule->getRadius(), capsule->getRadius(), glm::vec4(0.6f, 0.8f, 0.6f, alpha));
}
glPopMatrix();
}

View file

@ -43,12 +43,11 @@ void OctreeFade::render() {
glDisable(GL_LIGHTING);
glPushMatrix();
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
glColor4f(red, green, blue, opacity);
glTranslatef(voxelDetails.x + voxelDetails.s * 0.5f,
voxelDetails.y + voxelDetails.s * 0.5f,
voxelDetails.z + voxelDetails.s * 0.5f);
glLineWidth(1.0f);
DependencyManager::get<GeometryCache>()->renderSolidCube(voxelDetails.s);
DependencyManager::get<GeometryCache>()->renderSolidCube(voxelDetails.s, glm::vec4(red, green, blue, opacity));
glLineWidth(1.0f);
glPopMatrix();
glEnable(GL_LIGHTING);

View file

@ -245,13 +245,12 @@ void ApplicationOverlay::displayOverlayTexture() {
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
glm::vec2 topLeft(0.0f, 0.0f);
glm::vec2 bottomRight(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
glm::vec2 texCoordTopLeft(0.0f, 1.0f);
glm::vec2 texCoordBottomRight(1.0f, 0.0f);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, glm::vec4(1.0f, 1.0f, 1.0f, _alpha));
} glPopMatrix();
@ -673,14 +672,13 @@ void ApplicationOverlay::renderControllerPointers() {
mouseY += reticleSize / 2.0f;
glColor3f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2]);
glm::vec2 topLeft(mouseX, mouseY);
glm::vec2 bottomRight(mouseX + reticleSize, mouseY - reticleSize);
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(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
glm::vec4(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f));
}
}
@ -756,7 +754,7 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool
border << bottomRight;
border << topRight;
border << topLeft;
geometryCache->updateVertices(_magnifierBorder, border);
geometryCache->updateVertices(_magnifierBorder, border, glm::vec4(1.0f, 0.0f, 0.0f, _alpha));
_previousMagnifierBottomLeft = bottomLeft;
_previousMagnifierBottomRight = bottomRight;
@ -769,7 +767,6 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool
glDisable(GL_TEXTURE_2D);
glLineWidth(1.0f);
//Outer Line
glColor4f(1.0f, 0.0f, 0.0f, _alpha);
geometryCache->renderVertices(GL_LINE_STRIP, _magnifierBorder);
glEnable(GL_TEXTURE_2D);
}
@ -810,9 +807,9 @@ void ApplicationOverlay::renderAudioMeter() {
audioMeterY = AUDIO_METER_GAP + MUTE_ICON_PADDING;
}
const float AUDIO_METER_BLUE[] = { 0.0, 0.0, 1.0 };
const float AUDIO_METER_GREEN[] = { 0.0, 1.0, 0.0 };
const float AUDIO_METER_RED[] = { 1.0, 0.0, 0.0 };
const glm::vec4 AUDIO_METER_BLUE = { 0.0, 0.0, 1.0, 1.0 };
const glm::vec4 AUDIO_METER_GREEN = { 0.0, 1.0, 0.0, 1.0 };
const glm::vec4 AUDIO_METER_RED = { 1.0, 0.0, 0.0, 1.0 };
const float AUDIO_GREEN_START = 0.25 * AUDIO_METER_SCALE_WIDTH;
const float AUDIO_RED_START = 0.80 * AUDIO_METER_SCALE_WIDTH;
const float CLIPPING_INDICATOR_TIME = 1.0f;
@ -855,51 +852,53 @@ void ApplicationOverlay::renderAudioMeter() {
audioMeterY += AUDIO_METER_HEIGHT;
glColor3f(0, 0, 0);
// Draw audio meter background Quad
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X, audioMeterY, AUDIO_METER_WIDTH, AUDIO_METER_HEIGHT);
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X, audioMeterY, AUDIO_METER_WIDTH, AUDIO_METER_HEIGHT, glm::vec4(0, 0, 0, 1));
if (audioLevel > AUDIO_RED_START) {
glm::vec4 quadColor;
if (!isClipping) {
glColor3fv(AUDIO_METER_RED);
quadColor = AUDIO_METER_RED;
} else {
glColor3f(1, 1, 1);
quadColor = glm::vec4(1, 1, 1, 1);
}
// Draw Red Quad
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_RED_START,
audioMeterY + AUDIO_METER_INSET,
audioLevel - AUDIO_RED_START,
AUDIO_METER_HEIGHT - AUDIO_METER_INSET,
AUDIO_METER_HEIGHT - AUDIO_METER_INSET, quadColor,
_audioRedQuad);
audioLevel = AUDIO_RED_START;
}
if (audioLevel > AUDIO_GREEN_START) {
glm::vec4 quadColor;
if (!isClipping) {
glColor3fv(AUDIO_METER_GREEN);
quadColor = AUDIO_METER_GREEN;
} else {
glColor3f(1, 1, 1);
quadColor = glm::vec4(1, 1, 1, 1);
}
// Draw Green Quad
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X + AUDIO_METER_INSET + AUDIO_GREEN_START,
audioMeterY + AUDIO_METER_INSET,
audioLevel - AUDIO_GREEN_START,
AUDIO_METER_HEIGHT - AUDIO_METER_INSET,
AUDIO_METER_HEIGHT - AUDIO_METER_INSET, quadColor,
_audioGreenQuad);
audioLevel = AUDIO_GREEN_START;
}
// Draw Blue Quad
glm::vec4 quadColor;
if (!isClipping) {
glColor3fv(AUDIO_METER_BLUE);
quadColor = AUDIO_METER_BLUE;
} else {
glColor3f(1, 1, 1);
quadColor = glm::vec4(1, 1, 1, 1);
}
// Draw Blue (low level) quad
DependencyManager::get<GeometryCache>()->renderQuad(AUDIO_METER_X + AUDIO_METER_INSET,
audioMeterY + AUDIO_METER_INSET,
audioLevel, AUDIO_METER_HEIGHT - AUDIO_METER_INSET,
audioLevel, AUDIO_METER_HEIGHT - AUDIO_METER_INSET, quadColor,
_audioBlueQuad);
}
@ -955,20 +954,21 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() {
int height = glCanvas->height();
if (width != _previousBorderWidth || height != _previousBorderHeight) {
glm::vec4 color(CONNECTION_STATUS_BORDER_COLOR[0],
CONNECTION_STATUS_BORDER_COLOR[1],
CONNECTION_STATUS_BORDER_COLOR[2], 1.0f);
QVector<glm::vec2> border;
border << glm::vec2(0, 0);
border << glm::vec2(0, height);
border << glm::vec2(width, height);
border << glm::vec2(width, 0);
border << glm::vec2(0, 0);
geometryCache->updateVertices(_domainStatusBorder, border);
geometryCache->updateVertices(_domainStatusBorder, border, color);
_previousBorderWidth = width;
_previousBorderHeight = height;
}
glColor3f(CONNECTION_STATUS_BORDER_COLOR[0],
CONNECTION_STATUS_BORDER_COLOR[1],
CONNECTION_STATUS_BORDER_COLOR[2]);
glLineWidth(CONNECTION_STATUS_BORDER_LINE_WIDTH);
geometryCache->renderVertices(GL_LINE_STRIP, _domainStatusBorder);

View file

@ -94,12 +94,21 @@ void BandwidthMeter::setColorRGBA(unsigned c) {
GLubyte( c & 0xff));
}
void BandwidthMeter::renderBox(int x, int y, int w, int h) {
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h);
glm::vec4 BandwidthMeter::getColorRGBA(unsigned c) {
float r = (c >> 24) / 255.0f;
float g = ((c >> 16) & 0xff) / 255.0f;
float b = ((c >> 8) & 0xff) / 255.0f;
float a = (c & 0xff) / 255.0f;
return glm::vec4(r,g,b,a);
}
void BandwidthMeter::renderVerticalLine(int x, int y, int h) {
DependencyManager::get<GeometryCache>()->renderLine(glm::vec2(x, y), glm::vec2(x, y + h));
void BandwidthMeter::renderBox(int x, int y, int w, int h, unsigned c) {
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h, getColorRGBA(c));
}
void BandwidthMeter::renderVerticalLine(int x, int y, int h, unsigned c) {
DependencyManager::get<GeometryCache>()->renderLine(glm::vec2(x, y), glm::vec2(x, y + h), getColorRGBA(c));
}
inline int BandwidthMeter::centered(int subject, int object) {
@ -161,9 +170,9 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT);
// Render vertical lines for the frame
setColorRGBA(COLOR_FRAME);
renderVerticalLine(0, 0, h);
renderVerticalLine(barWidth, 0, h);
//setColorRGBA(COLOR_FRAME);
renderVerticalLine(0, 0, h, COLOR_FRAME);
renderVerticalLine(barWidth, 0, h, COLOR_FRAME);
// Adjust scale
int steps;
@ -192,9 +201,8 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
}
// Render scale indicators
setColorRGBA(COLOR_INDICATOR);
for (int j = NUMBER_OF_MARKERS; --j > 0;) {
renderVerticalLine((barWidth * j) / NUMBER_OF_MARKERS, 0, h);
renderVerticalLine((barWidth * j) / NUMBER_OF_MARKERS, 0, h, COLOR_INDICATOR);
}
// Render bars
@ -205,15 +213,13 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
int wIn = (int)(barWidth * inputStream(chIdx).getValue() * UNIT_SCALE / scaleMax);
int wOut = (int)(barWidth * outputStream(chIdx).getValue() * UNIT_SCALE / scaleMax);
setColorRGBA(channelInfo(chIdx).colorRGBA);
if (wIn > 0) {
renderBox(xIn, 0, wIn, barHeight);
renderBox(xIn, 0, wIn, barHeight, channelInfo(chIdx).colorRGBA);
}
xIn += wIn;
if (wOut > 0) {
renderBox(xOut, h - barHeight, wOut, barHeight);
renderBox(xOut, h - barHeight, wOut, barHeight, channelInfo(chIdx).colorRGBA);
}
xOut += wOut;
}

View file

@ -70,8 +70,9 @@ public:
private:
static void setColorRGBA(unsigned c);
static void renderBox(int x, int y, int w, int h);
static void renderVerticalLine(int x, int y, int h);
static glm::vec4 getColorRGBA(unsigned c);
static void renderBox(int x, int y, int w, int h, unsigned c);
static void renderVerticalLine(int x, int y, int h, unsigned c);
static inline int centered(int subject, int object);

View file

@ -353,11 +353,9 @@ void MetavoxelEditor::render() {
float scale = GRID_DIVISIONS * spacing;
glScalef(scale, scale, scale);
glColor3f(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS);
_gridProgram.bind();
DependencyManager::get<GeometryCache>()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS, glm::vec4(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS, 1.0f));
_gridProgram.release();
@ -488,17 +486,17 @@ void BoxTool::render() {
if (_state != HOVERING_STATE) {
const float BOX_ALPHA = 0.25f;
QColor color = getColor();
glm::vec4 cubeColor;
if (color.isValid()) {
glColor4f(color.redF(), color.greenF(), color.blueF(), BOX_ALPHA);
cubeColor = glm::vec4(color.redF(), color.greenF(), color.blueF(), BOX_ALPHA);
} else {
glColor4f(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS, BOX_ALPHA);
cubeColor = glm::vec4(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS, BOX_ALPHA);
}
glEnable(GL_CULL_FACE);
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f, cubeColor);
glDisable(GL_CULL_FACE);
}
glColor3f(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS);
DependencyManager::get<GeometryCache>()->renderWireCube(1.0f);
DependencyManager::get<GeometryCache>()->renderWireCube(1.0f, glm::vec4(GRID_BRIGHTNESS, GRID_BRIGHTNESS, GRID_BRIGHTNESS, 1.0f));
glPopMatrix();
}

View file

@ -127,8 +127,7 @@ void NodeBounds::draw() {
float red, green, blue;
getColorForNodeType(selectedNode->getType(), red, green, blue);
glColor4f(red, green, blue, 0.2f);
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f, glm::vec4(red, green, blue, 0.2f));
glPopMatrix();
@ -152,8 +151,7 @@ void NodeBounds::drawNodeBorder(const glm::vec3& center, float scale, float red,
glTranslatef(center.x, center.y, center.z);
glScalef(scale, scale, scale);
glLineWidth(2.5);
glColor3f(red, green, blue);
DependencyManager::get<GeometryCache>()->renderWireCube(1.0f);
DependencyManager::get<GeometryCache>()->renderWireCube(1.0f, glm::vec4(red, green, blue, 1.0f));
glPopMatrix();
}
@ -179,9 +177,10 @@ void NodeBounds::drawOverlay() {
int mouseX = application->getTrueMouseX(),
mouseY = application->getTrueMouseY(),
textWidth = widthText(TEXT_SCALE, 0, _overlayText);
glColor4f(0.4f, 0.4f, 0.4f, 0.6f);
renderBevelCornersRect(mouseX + MOUSE_OFFSET, mouseY - TEXT_HEIGHT - PADDING,
textWidth + (2 * PADDING), TEXT_HEIGHT + (2 * PADDING), BACKGROUND_BEVEL);
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(
mouseX + MOUSE_OFFSET, mouseY - TEXT_HEIGHT - PADDING,
textWidth + (2 * PADDING), TEXT_HEIGHT + (2 * PADDING), BACKGROUND_BEVEL,
glm::vec4(0.4f, 0.4f, 0.4f, 0.6f));
drawText(mouseX + MOUSE_OFFSET + PADDING, mouseY, TEXT_SCALE, ROTATION, FONT, _overlayText, TEXT_COLOR);
}
}

View file

@ -133,10 +133,11 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glm::vec4 quadColor;
if (selected) {
glColor3f(.5f, .5f, .5f);
quadColor = glm::vec4(.5f, .5f, .5f, 1.0f);
} else {
glColor3f(1, 1, 1);
quadColor = glm::vec4(1, 1, 1, 1);
}
glBindTexture(GL_TEXTURE_2D, textureId);
@ -146,7 +147,7 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture
glm::vec2 texCoordTopLeft(0.0f, 1.0f);
glm::vec2 texCoordBottomRight(1.0f, 0.0f);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
glPopMatrix();

View file

@ -154,14 +154,12 @@ void Stats::resetWidth(int width, int horizontalOffset) {
// translucent background box that makes stats more readable
void Stats::drawBackground(unsigned int rgba, int x, int y, int width, int height) {
glColor4f(((rgba >> 24) & 0xff) / 255.0f,
((rgba >> 16) & 0xff) / 255.0f,
((rgba >> 8) & 0xff) / 255.0f,
(rgba & 0xff) / 255.0f);
glm::vec4 color(((rgba >> 24) & 0xff) / 255.0f,
((rgba >> 16) & 0xff) / 255.0f,
((rgba >> 8) & 0xff) / 255.0f,
(rgba & 0xff) / 255.0f);
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height);
glColor4f(1, 1, 1, 1);
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height, color);
}
bool Stats::includeTimingRecord(const QString& name) {

View file

@ -95,7 +95,6 @@ void BillboardOverlay::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f;
xColor color = getColor();
float alpha = getAlpha();
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec2 topLeft(-x, -y);
glm::vec2 bottomRight(x, y);
@ -104,7 +103,8 @@ void BillboardOverlay::render(RenderArgs* args) {
glm::vec2 texCoordBottomRight(((float)_fromImage.x() + (float)_fromImage.width()) / (float)_size.width(),
((float)_fromImage.y() + (float)_fromImage.height()) / _size.height());
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
glm::vec4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha));
}
} glPopMatrix();

View file

@ -95,10 +95,9 @@ void Circle3DOverlay::render(RenderArgs* args) {
const float SLICE_ANGLE = FULL_CIRCLE / SLICES;
//const int slices = 15;
xColor color = getColor();
xColor colorX = getColor();
const float MAX_COLOR = 255.0f;
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec4 color(colorX.red / MAX_COLOR, colorX.green / MAX_COLOR, colorX.blue / MAX_COLOR, alpha);
glDisable(GL_LIGHTING);
@ -162,7 +161,7 @@ void Circle3DOverlay::render(RenderArgs* args) {
points << lastOuterPoint << lastInnerPoint;
geometryCache->updateVertices(_quadVerticesID, points);
geometryCache->updateVertices(_quadVerticesID, points, color);
}
geometryCache->renderVertices(GL_QUAD_STRIP, _quadVerticesID);
@ -200,7 +199,7 @@ void Circle3DOverlay::render(RenderArgs* args) {
glm::vec2 lastPoint(cos(angleInRadians) * outerRadius, sin(angleInRadians) * outerRadius);
points << lastPoint;
geometryCache->updateVertices(_lineVerticesID, points);
geometryCache->updateVertices(_lineVerticesID, points, color);
}
if (getIsDashedLine()) {
@ -270,16 +269,19 @@ void Circle3DOverlay::render(RenderArgs* args) {
}
}
geometryCache->updateVertices(_majorTicksVerticesID, majorPoints);
geometryCache->updateVertices(_minorTicksVerticesID, minorPoints);
xColor majorColorX = getMajorTickMarksColor();
glm::vec4 majorColor(majorColorX.red / MAX_COLOR, majorColorX.green / MAX_COLOR, majorColorX.blue / MAX_COLOR, alpha);
geometryCache->updateVertices(_majorTicksVerticesID, majorPoints, majorColor);
xColor minorColorX = getMinorTickMarksColor();
glm::vec4 minorColor(minorColorX.red / MAX_COLOR, minorColorX.green / MAX_COLOR, minorColorX.blue / MAX_COLOR, alpha);
geometryCache->updateVertices(_minorTicksVerticesID, minorPoints, minorColor);
}
xColor majorColor = getMajorTickMarksColor();
glColor4f(majorColor.red / MAX_COLOR, majorColor.green / MAX_COLOR, majorColor.blue / MAX_COLOR, alpha);
geometryCache->renderVertices(GL_LINES, _majorTicksVerticesID);
xColor minorColor = getMinorTickMarksColor();
glColor4f(minorColor.red / MAX_COLOR, minorColor.green / MAX_COLOR, minorColor.blue / MAX_COLOR, alpha);
geometryCache->renderVertices(GL_LINES, _minorTicksVerticesID);
}

View file

@ -47,7 +47,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
float alpha = getAlpha();
xColor color = getColor();
const float MAX_COLOR = 255.0f;
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec4 cubeColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
//glDisable(GL_LIGHTING);
@ -74,13 +74,12 @@ void Cube3DOverlay::render(RenderArgs* args) {
// enough for the use-case.
glDepthMask(GL_FALSE);
glPushMatrix();
glColor4f(1.0f, 1.0f, 1.0f, alpha);
glScalef(dimensions.x * _borderSize, dimensions.y * _borderSize, dimensions.z * _borderSize);
if (_drawOnHUD) {
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f, glm::vec4(1.0f, 1.0f, 1.0f, alpha));
} else {
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, glm::vec4(1.0f, 1.0f, 1.0f, alpha));
}
glPopMatrix();
@ -88,12 +87,11 @@ void Cube3DOverlay::render(RenderArgs* args) {
}
glPushMatrix();
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glScalef(dimensions.x, dimensions.y, dimensions.z);
if (_drawOnHUD) {
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f, cubeColor);
} else {
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
}
glPopMatrix();
} else {
@ -130,7 +128,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
} else {
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, cubeColor);
}
}
glPopMatrix();

View file

@ -79,7 +79,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f;
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec4 gridColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
_gridProgram.bind();
@ -92,7 +92,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
float scale = MINOR_GRID_DIVISIONS * spacing;
glScalef(scale, scale, scale);
DependencyManager::get<GeometryCache>()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS, gridColor);
}
glPopMatrix();
@ -107,7 +107,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
float scale = MAJOR_GRID_DIVISIONS * spacing;
glScalef(scale, scale, scale);
DependencyManager::get<GeometryCache>()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS, gridColor);
}
glPopMatrix();

View file

@ -85,7 +85,7 @@ void ImageOverlay::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f;
xColor color = getColor();
float alpha = getAlpha();
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec4 quadColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
float imageWidth = _textureImage.width();
float imageHeight = _textureImage.height();
@ -115,9 +115,9 @@ void ImageOverlay::render(RenderArgs* args) {
glm::vec2 texCoordBottomRight(x + w, 1.0f - (y + h));
if (_renderImage) {
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
} else {
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor);
}
if (_renderImage) {

View file

@ -39,7 +39,7 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
float alpha = getAlpha();
xColor color = getColor();
const float MAX_COLOR = 255.0f;
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec4 rectangleColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glDisable(GL_LIGHTING);
@ -72,7 +72,7 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
if (getIsSolid()) {
glm::vec3 topLeft(-halfDimensions.x, 0.0f, -halfDimensions.y);
glm::vec3 bottomRight(halfDimensions.x, 0.0f, halfDimensions.y);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, rectangleColor);
} else {
if (getIsDashedLine()) {
@ -95,7 +95,7 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
border << glm::vec3(halfDimensions.x, 0.0f, halfDimensions.y);
border << glm::vec3(-halfDimensions.x, 0.0f, halfDimensions.y);
border << glm::vec3(-halfDimensions.x, 0.0f, -halfDimensions.y);
geometryCache->updateVertices(_geometryCacheID, border);
geometryCache->updateVertices(_geometryCacheID, border, rectangleColor);
_previousHalfDimensions = halfDimensions;

View file

@ -39,7 +39,7 @@ void Sphere3DOverlay::render(RenderArgs* args) {
float alpha = getAlpha();
xColor color = getColor();
const float MAX_COLOR = 255.0f;
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec4 sphereColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glDisable(GL_LIGHTING);
@ -62,7 +62,7 @@ void Sphere3DOverlay::render(RenderArgs* args) {
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES, _isSolid);
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES, sphereColor, _isSolid);
glPopMatrix();
glPopMatrix();

View file

@ -92,7 +92,7 @@ void Text3DOverlay::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f;
xColor backgroundColor = getBackgroundColor();
glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
glm::vec4 quadColor(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
getBackgroundAlpha());
glm::vec2 dimensions = getDimensions();
@ -102,7 +102,7 @@ void Text3DOverlay::render(RenderArgs* args) {
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor);
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 40.0f; // this is a ratio determined through experimentation

View file

@ -70,7 +70,7 @@ void TextOverlay::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f;
xColor backgroundColor = getBackgroundColor();
glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
glm::vec4 quadColor(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
getBackgroundAlpha());
int left = _bounds.left();
@ -80,7 +80,7 @@ void TextOverlay::render(RenderArgs* args) {
glm::vec2 topLeft(left, top);
glm::vec2 bottomRight(right, bottom);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, quadColor);
// Same font properties as textSize()
TextRenderer* textRenderer = TextRenderer::getInstance(SANS_FONT_FAMILY, _fontSize, DEFAULT_FONT_WEIGHT);

View file

@ -394,62 +394,53 @@ const Model* EntityTreeRenderer::getModelForEntityItem(const EntityItem* entityI
void EntityTreeRenderer::renderElementProxy(EntityTreeElement* entityTreeElement) {
glm::vec3 elementCenter = entityTreeElement->getAACube().calcCenter() * (float) TREE_SCALE;
float elementSize = entityTreeElement->getScale() * (float) TREE_SCALE;
glColor3f(1.0f, 0.0f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x, elementCenter.y, elementCenter.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(elementSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(elementSize, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
glPopMatrix();
if (_displayElementChildProxies) {
// draw the children
float halfSize = elementSize / 2.0f;
float quarterSize = elementSize / 4.0f;
glColor3f(1.0f, 1.0f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x - quarterSize, elementCenter.y - quarterSize, elementCenter.z - quarterSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
glPopMatrix();
glColor3f(1.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(elementCenter.x + quarterSize, elementCenter.y - quarterSize, elementCenter.z - quarterSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
glPopMatrix();
glColor3f(0.0f, 1.0f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x - quarterSize, elementCenter.y + quarterSize, elementCenter.z - quarterSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
glPopMatrix();
glColor3f(0.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(elementCenter.x - quarterSize, elementCenter.y - quarterSize, elementCenter.z + quarterSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
glPopMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
glPushMatrix();
glTranslatef(elementCenter.x + quarterSize, elementCenter.y + quarterSize, elementCenter.z + quarterSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
glPopMatrix();
glColor3f(0.0f, 0.5f, 0.5f);
glPushMatrix();
glTranslatef(elementCenter.x - quarterSize, elementCenter.y + quarterSize, elementCenter.z + quarterSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.5f, 0.5f, 1.0f));
glPopMatrix();
glColor3f(0.5f, 0.0f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x + quarterSize, elementCenter.y - quarterSize, elementCenter.z + quarterSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.5f, 0.0f, 0.0f, 1.0f));
glPopMatrix();
glColor3f(0.0f, 0.5f, 0.0f);
glPushMatrix();
glTranslatef(elementCenter.x + quarterSize, elementCenter.y + quarterSize, elementCenter.z - quarterSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(halfSize, glm::vec4(0.0f, 0.5f, 0.0f, 1.0f));
glPopMatrix();
}
}
@ -473,25 +464,22 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
glm::vec3 entityBoxScale = entityBox.getScale();
// draw the max bounding cube
glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(maxCenter.x, maxCenter.y, maxCenter.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(maxCube.getScale());
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(maxCube.getScale(), glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
glPopMatrix();
// draw the min bounding cube
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glPushMatrix();
glTranslatef(minCenter.x, minCenter.y, minCenter.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(minCube.getScale());
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(minCube.getScale(), glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
glPopMatrix();
// draw the entityBox bounding box
glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
glPushMatrix();
glTranslatef(entityBoxCenter.x, entityBoxCenter.y, entityBoxCenter.z);
glScalef(entityBoxScale.x, entityBoxScale.y, entityBoxScale.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
glPopMatrix();
@ -500,7 +488,6 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
glm::vec3 dimensions = entity->getDimensions() * (float) TREE_SCALE;
glm::quat rotation = entity->getRotation();
glColor4f(1.0f, 0.0f, 1.0f, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
@ -509,7 +496,7 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(1.0f, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
glPopMatrix();
glPopMatrix();
}

View file

@ -32,7 +32,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f;
glColor4f(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
glm::vec4 cubeColor(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
glPushMatrix();
@ -43,7 +43,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
glm::vec3 positionToCenter = center - position;
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f, cubeColor);
glPopMatrix();
glPopMatrix();

View file

@ -176,27 +176,27 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
}
} else {
// if we couldn't get a model, then just draw a cube
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
}
} else {
// if we couldn't get a model, then just draw a cube
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
}
}
glPopMatrix();
} else {
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
glm::vec4 color(getColor()[RED_INDEX]/255, getColor()[GREEN_INDEX]/255, getColor()[BLUE_INDEX]/255, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size);
DependencyManager::get<DeferredLightingEffect>()->renderWireCube(size, color);
glPopMatrix();
}
}

View file

@ -32,7 +32,7 @@ void RenderableSphereEntityItem::render(RenderArgs* args) {
glm::quat rotation = getRotation();
const float MAX_COLOR = 255.0f;
glColor4f(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
glm::vec4 sphereColor(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR,
getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha());
glPushMatrix();
@ -46,7 +46,7 @@ void RenderableSphereEntityItem::render(RenderArgs* args) {
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, 15, 15);
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, 15, 15, sphereColor);
glPopMatrix();
glPopMatrix();
};

View file

@ -49,13 +49,13 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
const float MAX_COLOR = 255.0f;
xColor backgroundColor = getBackgroundColorX();
float alpha = 1.0f; //getBackgroundAlpha();
glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR, alpha);
glm::vec4 color(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR, alpha);
const float SLIGHTLY_BEHIND = -0.005f;
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, SLIGHTLY_BEHIND);
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, SLIGHTLY_BEHIND);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, color);
const int FIXED_FONT_SCALING_RATIO = FIXED_FONT_POINT_SIZE * 40.0f; // this is a ratio determined through experimentation

View file

@ -71,27 +71,27 @@ void DeferredLightingEffect::releaseSimpleProgram() {
DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false, false);
}
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks) {
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks, const glm::vec4& color) {
bindSimpleProgram();
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks);
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, color);
releaseSimpleProgram();
}
void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks) {
void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks, const glm::vec4& color) {
bindSimpleProgram();
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, false);
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, color, false);
releaseSimpleProgram();
}
void DeferredLightingEffect::renderSolidCube(float size) {
void DeferredLightingEffect::renderSolidCube(float size, const glm::vec4& color) {
bindSimpleProgram();
DependencyManager::get<GeometryCache>()->renderSolidCube(size);
DependencyManager::get<GeometryCache>()->renderSolidCube(size, color);
releaseSimpleProgram();
}
void DeferredLightingEffect::renderWireCube(float size) {
void DeferredLightingEffect::renderWireCube(float size, const glm::vec4& color) {
bindSimpleProgram();
DependencyManager::get<GeometryCache>()->renderWireCube(size);
DependencyManager::get<GeometryCache>()->renderWireCube(size, color);
releaseSimpleProgram();
}
@ -153,8 +153,6 @@ void DeferredLightingEffect::prepare() {
void DeferredLightingEffect::render() {
// perform deferred lighting, rendering to free fbo
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
@ -295,7 +293,7 @@ void DeferredLightingEffect::render() {
} else {
glTranslatef(light.position.x, light.position.y, light.position.z);
geometryCache->renderSphere(expandedRadius, 32, 32);
geometryCache->renderSphere(expandedRadius, 32, 32, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
}
glPopMatrix();

View file

@ -40,16 +40,16 @@ public:
void releaseSimpleProgram();
//// Renders a solid sphere with the simple program.
void renderSolidSphere(float radius, int slices, int stacks);
void renderSolidSphere(float radius, int slices, int stacks, const glm::vec4& color);
//// Renders a wireframe sphere with the simple program.
void renderWireSphere(float radius, int slices, int stacks);
void renderWireSphere(float radius, int slices, int stacks, const glm::vec4& color);
//// Renders a solid cube with the simple program.
void renderSolidCube(float size);
void renderSolidCube(float size, const glm::vec4& color);
//// Renders a wireframe cube with the simple program.
void renderWireCube(float size);
void renderWireCube(float size, const glm::vec4& color);
//// Renders a solid cone with the simple program.
void renderSolidCone(float base, float height, int slices, int stacks);

View file

@ -134,7 +134,7 @@ const int NUM_COORDS_PER_VERTEX = 3;
const int NUM_BYTES_PER_VERTEX = NUM_COORDS_PER_VERTEX * sizeof(GLfloat);
const int NUM_BYTES_PER_INDEX = sizeof(GLushort);
void GeometryCache::renderSphere(float radius, int slices, int stacks, bool solid) {
void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid) {
VerticesIndices& vbo = _sphereVBOs[IntPair(slices, stacks)];
int vertices = slices * (stacks - 1) + 2;
int indices = slices * stacks * NUM_VERTICES_PER_TRIANGULATED_QUAD;
@ -478,7 +478,7 @@ void GeometryCache::renderCone(float base, float height, int slices, int stacks)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void GeometryCache::renderGrid(int xDivisions, int yDivisions) {
void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& color) {
QOpenGLBuffer& buffer = _gridBuffers[IntPair(xDivisions, yDivisions)];
int vertices = (xDivisions + 1 + yDivisions + 1) * 2;
if (!buffer.isCreated()) {
@ -522,7 +522,7 @@ void GeometryCache::renderGrid(int xDivisions, int yDivisions) {
buffer.release();
}
void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, int id) {
void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) {
bool registered = (id != UNKNOWN_ID);
Vec3Pair key(glm::vec3(x, y, width), glm::vec3(height, rows, cols));
QOpenGLBuffer& buffer = registered ? _registeredAlternateGridBuffers[id] : _alternateGridBuffers[key];
@ -606,7 +606,7 @@ void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, in
buffer.release();
}
void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points) {
void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, const glm::vec4& color) {
BufferDetails& details = _registeredVertices[id];
if (details.buffer.isCreated()) {
@ -639,7 +639,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points) {
#endif
}
void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points) {
void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, const glm::vec4& color) {
BufferDetails& details = _registeredVertices[id];
if (details.buffer.isCreated()) {
@ -685,7 +685,7 @@ void GeometryCache::renderVertices(GLenum mode, int id) {
}
}
void GeometryCache::renderSolidCube(float size) {
void GeometryCache::renderSolidCube(float size, const glm::vec4& color) {
VerticesIndices& vbo = _solidCubeVBOs[size];
const int FLOATS_PER_VERTEX = 3;
const int VERTICES_PER_FACE = 4;
@ -779,7 +779,7 @@ void GeometryCache::renderSolidCube(float size) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void GeometryCache::renderWireCube(float size) {
void GeometryCache::renderWireCube(float size, const glm::vec4& color) {
VerticesIndices& vbo = _wireCubeVBOs[size];
const int FLOATS_PER_VERTEX = 3;
const int VERTICES_PER_EDGE = 2;
@ -839,7 +839,7 @@ void GeometryCache::renderWireCube(float size) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, int id) {
void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) {
bool registeredRect = (id != UNKNOWN_ID);
Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance));
VerticesIndices& vbo = registeredRect ? _registeredRectVBOs[id] : _rectVBOs[key];
@ -939,7 +939,7 @@ void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height,
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, int id) {
void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) {
bool registeredQuad = (id != UNKNOWN_ID);
Vec2Pair key(minCorner, maxCorner);
@ -1022,7 +1022,8 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC
void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner,
const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, int id) {
const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner,
const glm::vec4& color, int id) {
bool registeredQuad = (id != UNKNOWN_ID);
Vec2PairPair key(Vec2Pair(minCorner, maxCorner), Vec2Pair(texCoordMinCorner, texCoordMaxCorner));
@ -1120,7 +1121,7 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, int id) {
void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
bool registeredQuad = (id != UNKNOWN_ID);
Vec3Pair key(minCorner, maxCorner);
@ -1537,87 +1538,96 @@ void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2,
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, int id) {
bool registeredLine = (id != UNKNOWN_ID);
void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2,
const glm::vec4& color1, const glm::vec4& color2, int id) {
bool registered = (id != UNKNOWN_ID);
Vec2Pair key(p1, p2);
VerticesIndices& vbo = registeredLine ? _registeredLine2DVBOs[id] : _line2DVBOs[key];
BatchItemDetails& details = registered ? _registeredLine2DVBOs[id] : _line2DVBOs[key];
int compactColor1 = ((int(color1.x * 255.0f) & 0xFF)) |
((int(color1.y * 255.0f) & 0xFF) << 8) |
((int(color1.z * 255.0f) & 0xFF) << 16) |
((int(color1.w * 255.0f) & 0xFF) << 24);
int compactColor2 = ((int(color2.x * 255.0f) & 0xFF)) |
((int(color2.y * 255.0f) & 0xFF) << 8) |
((int(color2.z * 255.0f) & 0xFF) << 16) |
((int(color2.w * 255.0f) & 0xFF) << 24);
// if this is a registered quad, and we have buffers, then check to see if the geometry changed and rebuild if needed
if (registeredLine && vbo.first != 0) {
if (registered && details.isCreated) {
Vec2Pair& lastKey = _lastRegisteredLine2D[id];
if (lastKey != key) {
glDeleteBuffers(1, &vbo.first);
glDeleteBuffers(1, &vbo.second);
vbo.first = vbo.second = 0;
details.clear();
_lastRegisteredLine2D[id] = key;
#ifdef WANT_DEBUG
qDebug() << "renderLine() 2D... RELEASING REGISTERED line";
qDebug() << "renderLine() 2D ... RELEASING REGISTERED line";
#endif // def WANT_DEBUG
}
#ifdef WANT_DEBUG
else {
qDebug() << "renderLine() 2D... REUSING PREVIOUSLY REGISTERED line";
qDebug() << "renderLine() 2D ... REUSING PREVIOUSLY REGISTERED line";
}
#endif // def WANT_DEBUG
}
const int FLOATS_PER_VERTEX = 2;
const int NUM_BYTES_PER_VERTEX = FLOATS_PER_VERTEX * sizeof(GLfloat);
const int vertices = 2;
const int indices = 2;
if (vbo.first == 0) {
_lastRegisteredLine2D[id] = key;
if (!details.isCreated) {
int vertexPoints = vertices * FLOATS_PER_VERTEX;
GLfloat* vertexData = new GLfloat[vertexPoints]; // only vertices, no normals because we're a 2D quad
GLfloat* vertex = vertexData;
static GLubyte cannonicalIndices[indices] = {0, 1};
int vertexPoint = 0;
details.isCreated = true;
details.vertices = vertices;
details.vertexSize = FLOATS_PER_VERTEX;
// p1
vertex[vertexPoint++] = p1.x;
vertex[vertexPoint++] = p1.y;
gpu::BufferPointer verticesBuffer(new gpu::Buffer());
gpu::BufferPointer colorBuffer(new gpu::Buffer());
gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format());
gpu::BufferStreamPointer stream(new gpu::BufferStream());
// p2
vertex[vertexPoint++] = p2.x;
vertex[vertexPoint++] = p2.y;
details.verticesBuffer = verticesBuffer;
details.colorBuffer = colorBuffer;
details.streamFormat = streamFormat;
details.stream = stream;
details.streamFormat->setAttribute(gpu::Stream::POSITION, 0, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::POS_XYZ), 0);
details.streamFormat->setAttribute(gpu::Stream::COLOR, 1, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA));
details.stream->addBuffer(details.verticesBuffer, 0, details.streamFormat->getChannels().at(0)._stride);
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
float vertexBuffer[vertices * FLOATS_PER_VERTEX] = { p1.x, p1.y, p2.x, p2.y };
const int NUM_COLOR_SCALARS = 2;
int colors[NUM_COLOR_SCALARS] = { compactColor1, compactColor2 };
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Buffer::Byte*) vertexBuffer);
details.colorBuffer->append(sizeof(colors), (gpu::Buffer::Byte*) colors);
glGenBuffers(1, &vbo.first);
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
glBufferData(GL_ARRAY_BUFFER, vertices * NUM_BYTES_PER_VERTEX, vertexData, GL_STATIC_DRAW);
delete[] vertexData;
GLushort* indexData = new GLushort[indices];
GLushort* index = indexData;
for (int i = 0; i < indices; i++) {
index[i] = cannonicalIndices[i];
}
glGenBuffers(1, &vbo.second);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
delete[] indexData;
#ifdef WANT_DEBUG
if (id == UNKNOWN_ID) {
qDebug() << "new renderLine() 2D VBO made -- _line2DVBOs.size():" << _line2DVBOs.size();
qDebug() << "new renderLine() 2D VBO made -- _line3DVBOs.size():" << _line2DVBOs.size();
} else {
qDebug() << "new registered renderLine() 2D VBO made -- _registeredLine2DVBOs.size():" << _registeredLine2DVBOs.size();
}
#endif
} else {
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
}
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(FLOATS_PER_VERTEX, GL_FLOAT, FLOATS_PER_VERTEX * sizeof(float), 0);
glDrawRangeElementsEXT(GL_LINES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
gpu::Batch batch;
// this is what it takes to render a quad
batch.setInputFormat(details.streamFormat);
batch.setInputStream(0, *details.stream);
batch.draw(gpu::LINES, 2, 0);
gpu::GLBackend::renderBatch(batch);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}

View file

@ -85,30 +85,36 @@ public:
static const int UNKNOWN_ID;
void renderHemisphere(int slices, int stacks);
void renderSphere(float radius, int slices, int stacks, bool solid = true);
void renderSquare(int xDivisions, int yDivisions);
void renderHalfCylinder(int slices, int stacks);
void renderCone(float base, float height, int slices, int stacks);
void renderGrid(int xDivisions, int yDivisions);
void renderGrid(int x, int y, int width, int height, int rows, int cols, int id = UNKNOWN_ID);
void renderSolidCube(float size);
void renderWireCube(float size);
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, int id = UNKNOWN_ID);
void renderQuad(int x, int y, int width, int height, int id = UNKNOWN_ID)
{ renderQuad(glm::vec2(x,y), glm::vec2(x + width, y + height), id); }
void renderSphere(float radius, int slices, int stacks, const glm::vec3& color, bool solid = true)
{ renderSphere(radius, slices, stacks, glm::vec4(color, 1.0f), solid); }
void renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid = true);
void renderGrid(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 renderSolidCube(float size, const glm::vec4& color);
void renderWireCube(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 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(const glm::vec2& minCorner, const glm::vec2& maxCorner, int id = UNKNOWN_ID);
void renderQuad(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, int id = UNKNOWN_ID);
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, int id = UNKNOWN_ID);
void renderQuad(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, int id = UNKNOWN_ID);
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
int id = UNKNOWN_ID);
void renderLine(const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& color, int id = UNKNOWN_ID)
@ -126,10 +132,23 @@ public:
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
void renderDashedLine(const glm::vec3& start, const glm::vec3& end, int id = UNKNOWN_ID);
void renderLine(const glm::vec2& p1, const glm::vec2& p2, int id = UNKNOWN_ID);
void updateVertices(int id, const QVector<glm::vec2>& points);
void updateVertices(int id, const QVector<glm::vec3>& points);
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(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color, int id = UNKNOWN_ID)
{ renderLine(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(const glm::vec2& p1, const glm::vec2& p2,
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
void updateVertices(int id, const QVector<glm::vec2>& points, const glm::vec4& color);
void updateVertices(int id, const QVector<glm::vec3>& points, const glm::vec4& color);
void renderVertices(GLenum mode, int id);
/// Loads geometry from the specified URL.
@ -200,8 +219,8 @@ private:
QHash<int, BatchItemDetails> _registeredLine3DVBOs;
QHash<int, Vec2Pair> _lastRegisteredLine2D;
QHash<Vec2Pair, VerticesIndices> _line2DVBOs;
QHash<int, VerticesIndices> _registeredLine2DVBOs;
QHash<Vec2Pair, BatchItemDetails> _line2DVBOs;
QHash<int, BatchItemDetails> _registeredLine2DVBOs;
QHash<int, BufferDetails> _registeredVertices;

View file

@ -167,7 +167,6 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
}
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glColor3f(1.0f, 1.0f, 1.0f);
renderFullscreenQuad();
glDisable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);

View file

@ -17,9 +17,10 @@
#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);
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, color);
}