Merge pull request #4191 from ZappoMan/moreImmediateModeRemoval

Removal of glColorXXX()
This commit is contained in:
samcake 2015-01-30 10:21:18 -08:00
commit e3fa2e1995
54 changed files with 1545 additions and 1346 deletions

View file

@ -2799,8 +2799,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
if (!selfAvatarOnly) {
// 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

@ -1251,7 +1251,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();
@ -1260,7 +1259,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();
}
@ -1271,7 +1271,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();
@ -1281,7 +1280,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

@ -36,22 +36,18 @@ void renderWorldBox() {
auto geometryCache = DependencyManager::get<GeometryCache>();
// Show edge of world
float red[] = {1, 0, 0};
float green[] = {0, 1, 0};
float blue[] = {0, 0, 1};
float gray[] = {0.5, 0.5, 0.5};
glm::vec3 red(1.0f, 0.0f, 0.0f);
glm::vec3 green(0.0f, 1.0f, 0.0f);
glm::vec3 blue(0.0f, 0.0f, 1.0f);
glm::vec3 grey(0.5f, 0.5f, 0.5f);
glDisable(GL_LIGHTING);
glLineWidth(1.0);
glColor3fv(red);
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(TREE_SCALE, 0, 0));
glColor3fv(green);
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(0, TREE_SCALE, 0));
glColor3fv(blue);
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(0, 0, TREE_SCALE));
glColor3fv(gray);
geometryCache->renderLine(glm::vec3(0, 0, TREE_SCALE), glm::vec3(TREE_SCALE, 0, TREE_SCALE));
geometryCache->renderLine(glm::vec3(TREE_SCALE, 0, TREE_SCALE), glm::vec3(TREE_SCALE, 0, 0));
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(TREE_SCALE, 0, 0), red);
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(0, TREE_SCALE, 0), green);
geometryCache->renderLine(glm::vec3(0, 0, 0), glm::vec3(0, 0, TREE_SCALE), blue);
geometryCache->renderLine(glm::vec3(0, 0, TREE_SCALE), glm::vec3(TREE_SCALE, 0, TREE_SCALE), grey);
geometryCache->renderLine(glm::vec3(TREE_SCALE, 0, TREE_SCALE), glm::vec3(TREE_SCALE, 0, 0), grey);
// Draw meter markers along the 3 axis to help with measuring things
@ -60,23 +56,19 @@ void renderWorldBox() {
glEnable(GL_LIGHTING);
glPushMatrix();
glTranslatef(MARKER_DISTANCE, 0, 0);
glColor3fv(red);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, red);
glPopMatrix();
glPushMatrix();
glTranslatef(0, MARKER_DISTANCE, 0);
glColor3fv(green);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, green);
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0, MARKER_DISTANCE);
glColor3fv(blue);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, blue);
glPopMatrix();
glPushMatrix();
glColor3fv(gray);
glTranslatef(MARKER_DISTANCE, 0, MARKER_DISTANCE);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10);
geometryCache->renderSphere(MARKER_RADIUS, 10, 10, grey);
glPopMatrix();
}
@ -114,25 +106,23 @@ void drawText(int x, int y, float scale, float radians, int mono,
//
glPushMatrix();
glTranslatef(static_cast<float>(x), static_cast<float>(y), 0.0f);
glColor3fv(color);
glRotated(double(radians * DEGREES_PER_RADIAN), 0.0, 0.0, 1.0);
glScalef(scale / 0.1f, scale / 0.1f, 1.0f);
textRenderer(mono)->draw(0, 0, string);
glm::vec4 colorV4 = {color[0], color[1], color[3], 1.0f };
textRenderer(mono)->draw(0, 0, string, colorV4);
glPopMatrix();
}
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();
bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection,

View file

@ -50,14 +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);
glColor4f(1, 1, 1, 1);
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h, backgroundColor);
int horizontalOffset = x + 5;
int verticalOffset = y;

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,10 +194,8 @@ void AudioScope::renderLineStrip(int id, const float* color, int x, int y, int n
}
geometryCache->updateVertices(id, points);
geometryCache->renderVertices(GL_LINE_STRIP, id);
glColor4f(1, 1, 1, 1);
geometryCache->updateVertices(id, points, color);
geometryCache->renderVertices(gpu::LINE_STRIP, id);
}
int AudioScope::addBufferToScope(QByteArray* byteArray, int frameOffset, const int16_t* source, int sourceSamplesPerChannel,

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

@ -62,17 +62,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;
@ -98,14 +100,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

@ -302,8 +302,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
glm::vec3 axis = glm::axis(rotation);
glRotatef(angle, axis.x, axis.y, axis.z);
glColor3f(laserColor.x, laserColor.y, laserColor.z);
geometryCache->renderLine(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, laserLength, 0.0f));
geometryCache->renderLine(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, laserLength, 0.0f), laserColor);
} glPopMatrix();
}
@ -328,8 +327,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
float angle = glm::degrees(glm::angle(rotation));
glm::vec3 axis = glm::axis(rotation);
glRotatef(angle, axis.x, axis.y, axis.z);
glColor3f(laserColor.x, laserColor.y, laserColor.z);
geometryCache->renderLine(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, laserLength, 0.0f));
geometryCache->renderLine(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, laserLength, 0.0f), laserColor);
} glPopMatrix();
}
@ -405,15 +403,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();
}
}
@ -437,11 +434,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();
}
@ -572,15 +569,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();
@ -706,15 +700,15 @@ 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);
glm::vec4 color(0.93f, 0.93f, 0.93f, _displayNameAlpha);
QByteArray ba = _displayName.toLocal8Bit();
const char* text = ba.data();
glDisable(GL_POLYGON_OFFSET_FILL);
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text);
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text, color);
glPopMatrix();
@ -949,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) {
auto geometryCache = DependencyManager::get<GeometryCache>();
@ -994,8 +989,8 @@ 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->renderVertices(GL_TRIANGLES, _jointConesID);
geometryCache->updateVertices(_jointConesID, points, color);
geometryCache->renderVertices(gpu::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();
}
}
@ -132,7 +131,6 @@ void Hand::render(bool isMine, Model::RenderMode renderMode) {
void Hand::renderHandTargets(bool isMine) {
glPushMatrix();
MyAvatar* myAvatar = Application::getInstance()->getAvatar();
const float avatarScale = Application::getInstance()->getAvatar()->getScale();
const float alpha = 1.0f;
@ -152,8 +150,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,17 +164,17 @@ 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();
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

@ -344,11 +344,10 @@ void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosi
glLineWidth(2.0);
// TODO: implement support for lines with gradient colors
// glColor4f(0.2f, 0.2f, 0.2f, 1.0f); --> to --> glColor4f(1.0f, 1.0f, 1.0f, 0.0f);
glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
geometryCache->renderLine(leftEyePosition, lookatPosition, _leftEyeLookAtID);
geometryCache->renderLine(rightEyePosition, lookatPosition, _rightEyeLookAtID);
glm::vec4 startColor(0.2f, 0.2f, 0.2f, 1.0f);
glm::vec4 endColor(1.0f, 1.0f, 1.0f, 0.0f);
geometryCache->renderLine(leftEyePosition, lookatPosition, startColor, endColor, _leftEyeLookAtID);
geometryCache->renderLine(rightEyePosition, lookatPosition, startColor, endColor, _rightEyeLookAtID);
DependencyManager::get<GlowEffect>()->end();
}

View file

@ -383,17 +383,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();
}
@ -1950,14 +1948,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,8 +366,8 @@ 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->renderVertices(GL_TRIANGLE_FAN, _triangleFanID);
geometryCache->updateVertices(_triangleFanID, points, color);
geometryCache->renderVertices(gpu::TRIANGLE_FAN, _triangleFanID);
}
glPopMatrix();
@ -396,14 +396,14 @@ void SkeletonModel::renderOrientationDirections(int jointIndex, glm::vec3 positi
glm::vec3 pUp = position + orientation * IDENTITY_UP * size;
glm::vec3 pFront = position + orientation * IDENTITY_FRONT * size;
glColor3f(1.0f, 0.0f, 0.0f);
geometryCache->renderLine(position, pRight, jointLineIDs._right);
glm::vec3 red(1.0f, 0.0f, 0.0f);
geometryCache->renderLine(position, pRight, red, jointLineIDs._right);
glColor3f(0.0f, 1.0f, 0.0f);
geometryCache->renderLine(position, pUp, jointLineIDs._up);
glm::vec3 green(0.0f, 1.0f, 0.0f);
geometryCache->renderLine(position, pUp, green, jointLineIDs._up);
glColor3f(0.0f, 0.0f, 1.0f);
geometryCache->renderLine(position, pFront, jointLineIDs._front);
glm::vec3 blue(0.0f, 0.0f, 1.0f);
geometryCache->renderLine(position, pFront, blue, jointLineIDs._front);
}
@ -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);
auto 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

@ -218,6 +218,6 @@ void PrioVR::renderCalibrationCountdown() {
auto glCanvas = DependencyManager::get<GLCanvas>();
textRenderer->draw((glCanvas->width() - textRenderer->computeWidth(text.constData())) / 2,
glCanvas->height() / 2,
text);
text, glm::vec4(1,1,1,1));
#endif
}

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

@ -118,10 +118,16 @@ void ApplicationOverlay::renderReticle(glm::quat orientation, float alpha) {
glm::vec3 topRight = getPoint(-reticleSize / 2.0f, -reticleSize / 2.0f);
glm::vec3 bottomLeft = getPoint(reticleSize / 2.0f, reticleSize / 2.0f);
glm::vec3 bottomRight = getPoint(-reticleSize / 2.0f, reticleSize / 2.0f);
glColor4f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], alpha);
// TODO: this version of renderQuad() needs to take a color
glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], alpha };
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomLeft, bottomRight, topRight,
glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 0.0f),
glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f), _reticleQuad);
glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f),
reticleColor, _reticleQuad);
} glPopMatrix();
}
@ -246,13 +252,13 @@ 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();
@ -315,8 +321,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
glDepthMask(GL_FALSE);
glDisable(GL_ALPHA_TEST);
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
static float textureFOV = 0.0f, textureAspectRatio = 1.0f;
if (textureFOV != _textureFov ||
textureAspectRatio != _textureAspectRatio) {
@ -375,7 +379,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
glTranslatef(pos.x, pos.y, pos.z);
glRotatef(glm::degrees(glm::angle(rot)), axis.x, axis.y, axis.z);
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
glm::vec4 overlayColor = {1.0f, 1.0f, 1.0f, _alpha};
//Render
const GLfloat distance = 1.0f;
@ -394,7 +398,8 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
glm::vec3(x + quadWidth, y, -distance),
glm::vec3(x, y, -distance),
glm::vec2(0.0f, 1.0f), glm::vec2(1.0f, 1.0f),
glm::vec2(1.0f, 0.0f), glm::vec2(0.0f, 0.0f));
glm::vec2(1.0f, 0.0f), glm::vec2(0.0f, 0.0f),
overlayColor);
auto glCanvas = DependencyManager::get<GLCanvas>();
if (_crosshairTexture == 0) {
@ -410,7 +415,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
const float mouseX = (application->getMouseX() / (float)glCanvas->width()) * quadWidth;
const float mouseY = (1.0 - (application->getMouseY() / (float)glCanvas->height())) * quadHeight;
glColor3f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2]);
glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f };
DependencyManager::get<GeometryCache>()->renderQuad(glm::vec3(x + mouseX, y + mouseY, -distance),
glm::vec3(x + mouseX + reticleSize, y + mouseY, -distance),
@ -418,7 +423,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
glm::vec3(x + mouseX, y + mouseY - reticleSize, -distance),
glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 0.0f),
glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f),
_reticleQuad);
reticleColor, _reticleQuad);
glEnable(GL_DEPTH_TEST);
@ -430,8 +435,6 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
glEnable(GL_LIGHTING);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const {
@ -674,14 +677,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));
}
}
@ -757,7 +759,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;
@ -770,18 +772,17 @@ 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);
geometryCache->renderVertices(gpu::LINE_STRIP, _magnifierBorder);
glEnable(GL_TEXTURE_2D);
}
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
glm::vec4 magnifierColor = { 1.0f, 1.0f, 1.0f, _alpha };
DependencyManager::get<GeometryCache>()->renderQuad(bottomLeft, bottomRight, topRight, topLeft,
glm::vec2(magnifyULeft, magnifyVBottom),
glm::vec2(magnifyURight, magnifyVBottom),
glm::vec2(magnifyURight, magnifyVTop),
glm::vec2(magnifyULeft, magnifyVTop),
_magnifierQuad);
magnifierColor, _magnifierQuad);
} glPopMatrix();
}
@ -810,9 +811,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;
@ -847,59 +848,56 @@ void ApplicationOverlay::renderAudioMeter() {
DependencyManager::get<AudioScope>()->render(glCanvas->width(), glCanvas->height());
DependencyManager::get<AudioIOStatsRenderer>()->render(WHITE_TEXT, glCanvas->width(), glCanvas->height());
if (isClipping) {
glColor3f(1, 0, 0);
} else {
glColor3f(0.475f, 0.475f, 0.475f);
}
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,23 +953,24 @@ 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);
geometryCache->renderVertices(gpu::LINE_STRIP, _domainStatusBorder);
}
}

View file

@ -86,20 +86,21 @@ void BandwidthMeter::Stream::updateValue(double amount) {
glm::clamp(dt / _msToAverage, 0.0, 1.0));
}
void BandwidthMeter::setColorRGBA(unsigned c) {
glm::vec4 BandwidthMeter::getColorRGBA(unsigned c) {
glColor4ub(GLubyte( c >> 24),
GLubyte((c >> 16) & 0xff),
GLubyte((c >> 8) & 0xff),
GLubyte( c & 0xff));
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::renderBox(int x, int y, int w, int h) {
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, 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) {
DependencyManager::get<GeometryCache>()->renderLine(glm::vec2(x, y), glm::vec2(x, y + h));
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) {
@ -155,15 +156,16 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
glTranslatef((float)barX, (float)y, 0.0f);
// Render captions
setColorRGBA(COLOR_TEXT);
_textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT);
_textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN);
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT);
glm::vec4 textColor = getColorRGBA(COLOR_TEXT);
_textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT, textColor);
_textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN, textColor);
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT, textColor);
// Render vertical lines for the frame
setColorRGBA(COLOR_FRAME);
renderVerticalLine(0, 0, h);
renderVerticalLine(barWidth, 0, h);
// TODO: I think there may be a bug in this newest code and/or the GeometryCache code, because it seems like
// sometimes the bandwidth meter doesn't render the vertical lines
renderVerticalLine(0, 0, h, COLOR_FRAME);
renderVerticalLine(barWidth, 0, h, COLOR_FRAME);
// Adjust scale
int steps;
@ -192,9 +194,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,30 +206,27 @@ 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;
}
// Render numbers
char fmtBuf[8];
setColorRGBA(COLOR_TEXT);
sprintf(fmtBuf, "%0.1f", totalIn);
_textRenderer->draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
PADDING_HORIZ_VALUE),
textYupperLine, fmtBuf);
textYupperLine, fmtBuf, textColor);
sprintf(fmtBuf, "%0.1f", totalOut);
_textRenderer->draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
PADDING_HORIZ_VALUE),
textYlowerLine, fmtBuf);
textYlowerLine, fmtBuf, textColor);
glPopMatrix();

View file

@ -69,9 +69,9 @@ public:
ChannelInfo const& channelInfo(ChannelIndex i) const { return _channels[i]; }
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

@ -356,11 +356,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();
@ -492,17 +490,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

@ -105,10 +105,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);
@ -118,7 +119,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

@ -158,14 +158,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,10 +161,10 @@ void Circle3DOverlay::render(RenderArgs* args) {
points << lastOuterPoint << lastInnerPoint;
geometryCache->updateVertices(_quadVerticesID, points);
geometryCache->updateVertices(_quadVerticesID, points, color);
}
geometryCache->renderVertices(GL_QUAD_STRIP, _quadVerticesID);
geometryCache->renderVertices(gpu::QUAD_STRIP, _quadVerticesID);
} else {
if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
@ -200,13 +199,13 @@ 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()) {
geometryCache->renderVertices(GL_LINES, _lineVerticesID);
geometryCache->renderVertices(gpu::LINES, _lineVerticesID);
} else {
geometryCache->renderVertices(GL_LINE_STRIP, _lineVerticesID);
geometryCache->renderVertices(gpu::LINE_STRIP, _lineVerticesID);
}
}
@ -270,17 +269,20 @@ 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);
geometryCache->renderVertices(gpu::LINES, _majorTicksVerticesID);
xColor minorColor = getMinorTickMarksColor();
glColor4f(minorColor.red / MAX_COLOR, minorColor.green / MAX_COLOR, minorColor.blue / MAX_COLOR, alpha);
geometryCache->renderVertices(GL_LINES, _minorTicksVerticesID);
geometryCache->renderVertices(gpu::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 {
@ -113,24 +111,24 @@ void Cube3DOverlay::render(RenderArgs* args) {
auto geometryCache = DependencyManager::get<GeometryCache>();
geometryCache->renderDashedLine(bottomLeftNear, bottomRightNear);
geometryCache->renderDashedLine(bottomRightNear, bottomRightFar);
geometryCache->renderDashedLine(bottomRightFar, bottomLeftFar);
geometryCache->renderDashedLine(bottomLeftFar, bottomLeftNear);
geometryCache->renderDashedLine(bottomLeftNear, bottomRightNear, cubeColor);
geometryCache->renderDashedLine(bottomRightNear, bottomRightFar, cubeColor);
geometryCache->renderDashedLine(bottomRightFar, bottomLeftFar, cubeColor);
geometryCache->renderDashedLine(bottomLeftFar, bottomLeftNear, cubeColor);
geometryCache->renderDashedLine(topLeftNear, topRightNear);
geometryCache->renderDashedLine(topRightNear, topRightFar);
geometryCache->renderDashedLine(topRightFar, topLeftFar);
geometryCache->renderDashedLine(topLeftFar, topLeftNear);
geometryCache->renderDashedLine(topLeftNear, topRightNear, cubeColor);
geometryCache->renderDashedLine(topRightNear, topRightFar, cubeColor);
geometryCache->renderDashedLine(topRightFar, topLeftFar, cubeColor);
geometryCache->renderDashedLine(topLeftFar, topLeftNear, cubeColor);
geometryCache->renderDashedLine(bottomLeftNear, topLeftNear);
geometryCache->renderDashedLine(bottomRightNear, topRightNear);
geometryCache->renderDashedLine(bottomLeftFar, topLeftFar);
geometryCache->renderDashedLine(bottomRightFar, topRightFar);
geometryCache->renderDashedLine(bottomLeftNear, topLeftNear, cubeColor);
geometryCache->renderDashedLine(bottomRightNear, topRightNear, cubeColor);
geometryCache->renderDashedLine(bottomLeftFar, topLeftFar, cubeColor);
geometryCache->renderDashedLine(bottomRightFar, topRightFar, cubeColor);
} 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

@ -30,9 +30,9 @@ ImageOverlay::ImageOverlay() :
ImageOverlay::ImageOverlay(const ImageOverlay* imageOverlay) :
Overlay2D(imageOverlay),
_texture(imageOverlay->_texture),
_imageURL(imageOverlay->_imageURL),
_textureImage(imageOverlay->_textureImage),
_texture(imageOverlay->_texture),
_fromImage(imageOverlay->_fromImage),
_renderImage(imageOverlay->_renderImage),
_wantClipFromImage(imageOverlay->_wantClipFromImage)
@ -75,7 +75,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);
int left = _bounds.left();
int right = _bounds.right() + 1;
@ -85,9 +85,11 @@ void ImageOverlay::render(RenderArgs* args) {
glm::vec2 topLeft(left, top);
glm::vec2 bottomRight(right, bottom);
if (_renderImage) {
float imageWidth = _texture->getWidth();
float imageHeight = _texture->getHeight();
float imageWidth = _texture->getWidth();
float imageHeight = _texture->getHeight();
// if for some reason our image is not over 0 width or height, don't attempt to render the image
if (_renderImage && imageWidth > 0 && imageHeight > 0) {
QRect fromImage;
if (_wantClipFromImage) {
@ -113,9 +115,9 @@ void ImageOverlay::render(RenderArgs* args) {
glm::vec2 texCoordTopLeft(x, y);
glm::vec2 texCoordBottomRight(x + w, y + h);
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

@ -49,7 +49,7 @@ void Line3DOverlay::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 colorv4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glm::vec3 position = getPosition();
glm::quat rotation = getRotation();
@ -59,9 +59,10 @@ void Line3DOverlay::render(RenderArgs* args) {
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
if (getIsDashedLine()) {
DependencyManager::get<GeometryCache>()->renderDashedLine(_position, _end, _geometryCacheID);
// TODO: add support for color to renderDashedLine()
DependencyManager::get<GeometryCache>()->renderDashedLine(_position, _end, colorv4, _geometryCacheID);
} else {
DependencyManager::get<GeometryCache>()->renderLine(_start, _end, _geometryCacheID);
DependencyManager::get<GeometryCache>()->renderLine(_start, _end, colorv4, _geometryCacheID);
}
glEnable(GL_LIGHTING);

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()) {
@ -81,10 +81,10 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
glm::vec3 point3(halfDimensions.x, 0.0f, halfDimensions.y);
glm::vec3 point4(-halfDimensions.x, 0.0f, halfDimensions.y);
geometryCache->renderDashedLine(point1, point2);
geometryCache->renderDashedLine(point2, point3);
geometryCache->renderDashedLine(point3, point4);
geometryCache->renderDashedLine(point4, point1);
geometryCache->renderDashedLine(point1, point2, rectangleColor);
geometryCache->renderDashedLine(point2, point3, rectangleColor);
geometryCache->renderDashedLine(point3, point4, rectangleColor);
geometryCache->renderDashedLine(point4, point1, rectangleColor);
} else {
@ -95,12 +95,12 @@ 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;
}
geometryCache->renderVertices(GL_LINE_STRIP, _geometryCacheID);
geometryCache->renderVertices(gpu::LINE_STRIP, _geometryCacheID);
}
}

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
@ -124,12 +124,11 @@ void Text3DOverlay::render(RenderArgs* args) {
enableClipPlane(GL_CLIP_PLANE2, 0.0f, -1.0f, 0.0f, clipMinimum.y + clipDimensions.y);
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR);
float alpha = getAlpha();
glm::vec4 textColor = {_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() };
QStringList lines = _text.split("\n");
int lineOffset = maxHeight;
foreach(QString thisLine, lines) {
textRenderer->draw(0, lineOffset, qPrintable(thisLine), alpha);
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textColor);
lineOffset += maxHeight;
}

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);
@ -90,15 +90,15 @@ void TextOverlay::render(RenderArgs* args) {
int x = _bounds.left() + _leftMargin + leftAdjust;
int y = _bounds.top() + _topMargin + topAdjust;
glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR);
float alpha = getAlpha();
glm::vec4 textColor = {_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, alpha };
QStringList lines = _text.split("\n");
int lineOffset = 0;
foreach(QString thisLine, lines) {
if (lineOffset == 0) {
lineOffset = textRenderer->calculateHeight(qPrintable(thisLine));
}
lineOffset += textRenderer->draw(x, y + lineOffset, qPrintable(thisLine), alpha);
lineOffset += textRenderer->draw(x, y + lineOffset, qPrintable(thisLine), textColor);
const int lineGap = 2;
lineOffset += lineGap;

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

@ -63,7 +63,7 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
}
#ifdef WANT_DEBUG
glColor4f(diffuseR, diffuseG, diffuseB, 1.0f);
glm::vec4 color(diffuseR, diffuseG, diffuseB, 1.0f);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glm::vec3 axis = glm::axis(rotation);
@ -73,7 +73,7 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
glScalef(dimensions.x, dimensions.y, dimensions.z);
DependencyManager::get<DeferredLightingEffect>()->renderWireSphere(0.5f, 15, 15);
DependencyManager::get<DeferredLightingEffect>()->renderWireSphere(0.5f, 15, 15, color);
glPopMatrix();
glPopMatrix();
#endif

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,14 @@ 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);
// TODO: it would be cool to select different slices/stacks geometry based on the size of the sphere
// and the distance to the viewer. This would allow us to reduce the triangle count for smaller spheres
// that aren't close enough to see the tessellation and use larger triangle count for spheres that would
// expose that effect
const int SLICES = 15;
const int STACKS = 15;
DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(0.5f, SLICES, STACKS, 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
@ -78,12 +78,11 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
xColor textColor = getTextColorX();
glColor3f(textColor.red / MAX_COLOR, textColor.green / MAX_COLOR, textColor.blue / MAX_COLOR);
glm::vec4 textColorV4(textColor.red / MAX_COLOR, textColor.green / MAX_COLOR, textColor.blue / MAX_COLOR, 1.0f);
QStringList lines = _text.split("\n");
int lineOffset = maxHeight;
float textAlpha = 1.0f; // getTextAlpha()
foreach(QString thisLine, lines) {
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textAlpha);
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textColorV4);
lineOffset += maxHeight;
}

View file

@ -46,7 +46,9 @@ enum Primitive {
LINE_STRIP,
TRIANGLES,
TRIANGLE_STRIP,
TRIANGLE_FAN,
QUADS,
QUAD_STRIP,
NUM_PRIMITIVES,
};

View file

@ -25,7 +25,9 @@ static const GLenum _primitiveToGLmode[NUM_PRIMITIVES] = {
GL_LINE_STRIP,
GL_TRIANGLES,
GL_TRIANGLE_STRIP,
GL_TRIANGLE_FAN,
GL_QUADS,
GL_QUAD_STRIP,
};
static const GLenum _elementTypeToGLType[NUM_TYPES]= {

View file

@ -202,6 +202,14 @@ public:
_element(element),
_stride(uint16(element.getSize()))
{};
BufferView(const BufferPointer& buffer, Size offset, Size size, uint16 stride, const Element& element = Element(gpu::SCALAR, gpu::UINT8, gpu::RAW)) :
_buffer(buffer),
_offset(offset),
_size(size),
_element(element),
_stride(stride)
{};
~BufferView() {}
BufferView(const BufferView& view) = default;
BufferView& operator=(const BufferView& view) = default;

View file

@ -221,27 +221,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();
}
@ -303,8 +303,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);
@ -471,7 +469,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);

File diff suppressed because it is too large Load diff

View file

@ -25,17 +25,24 @@
#include <AnimationCache.h>
#include "gpu/Stream.h"
#include <gpu/Batch.h>
#include <gpu/Stream.h>
class NetworkGeometry;
class NetworkMesh;
class NetworkTexture;
typedef glm::vec3 Vec3Key;
typedef QPair<glm::vec2, glm::vec2> Vec2Pair;
typedef QPair<Vec2Pair, Vec2Pair> Vec2PairPair;
typedef QPair<glm::vec3, glm::vec3> Vec3Pair;
typedef QPair<glm::vec4, glm::vec4> Vec4Pair;
typedef QPair<Vec3Pair, Vec2Pair> Vec3PairVec2Pair;
typedef QPair<Vec3Pair, Vec4Pair> Vec3PairVec4Pair;
typedef QPair<Vec4Pair, Vec4Pair> Vec4PairVec4Pair;
inline uint qHash(const glm::vec2& v, uint seed) {
// multiply by prime numbers greater than the possible size
@ -47,6 +54,11 @@ inline uint qHash(const Vec2Pair& v, uint seed) {
return qHash(v.first.x + 5009 * v.first.y + 5011 * v.second.x + 5021 * v.second.y, seed);
}
inline uint qHash(const glm::vec4& v, uint seed) {
// multiply by prime numbers greater than the possible size
return qHash(v.x + 5009 * v.y + 5011 * v.z + 5021 * v.w, seed);
}
inline uint qHash(const Vec2PairPair& v, uint seed) {
// multiply by prime numbers greater than the possible size
return qHash(v.first.first.x + 5009 * v.first.first.y
@ -55,17 +67,18 @@ inline uint qHash(const Vec2PairPair& v, uint seed) {
+ 5051 * v.second.second.x + 5059 * v.second.second.y, seed);
}
inline uint qHash(const glm::vec3& v, uint seed) {
// multiply by prime numbers greater than the possible size
return qHash(v.x + 5009 * v.y + 5011 * v.z, seed);
}
inline uint qHash(const Vec3Pair& v, uint seed) {
// multiply by prime numbers greater than the possible size
return qHash(v.first.x + 5009 * v.first.y + 5011 * v.first.z
+ 5021 * v.second.x + 5023 * v.second.y + 5039 * v.second.z, seed);
}
inline uint qHash(const Vec4Pair& v, uint seed) {
// multiply by prime numbers greater than the possible size
return qHash(v.first.x + 5009 * v.first.y + 5011 * v.first.z + 5021 * v.first.w
+ 5023 * v.second.x + 5039 * v.second.y + 5051 * v.second.z + 5059 * v.second.w , seed);
}
inline uint qHash(const Vec3PairVec2Pair& v, uint seed) {
// multiply by prime numbers greater than the possible size
return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z +
@ -74,6 +87,23 @@ inline uint qHash(const Vec3PairVec2Pair& v, uint seed) {
5077 * v.second.second.x + 5081 * v.second.second.y, seed);
}
inline uint qHash(const Vec3PairVec4Pair& v, uint seed) {
// multiply by prime numbers greater than the possible size
return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z
+ 5023 * v.first.second.x + 5039 * v.first.second.y + 5051 * v.first.second.z
+ 5077 * v.second.first.x + 5081 * v.second.first.y + 5087 * v.second.first.z + 5099 * v.second.first.w
+ 5101 * v.second.second.x + 5107 * v.second.second.y + 5113 * v.second.second.z + 5119 * v.second.second.w,
seed);
}
inline uint qHash(const Vec4PairVec4Pair& v, uint seed) {
// multiply by prime numbers greater than the possible size
return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z + 5021 * v.first.first.w
+ 5023 * v.first.second.x + 5039 * v.first.second.y + 5051 * v.first.second.z + 5059 * v.first.second.w
+ 5077 * v.second.first.x + 5081 * v.second.first.y + 5087 * v.second.first.z + 5099 * v.second.first.w
+ 5101 * v.second.second.x + 5107 * v.second.second.y + 5113 * v.second.second.z + 5119 * v.second.second.w,
seed);
}
/// Stores cached geometry.
class GeometryCache : public ResourceCache, public Dependency {
@ -84,40 +114,72 @@ public:
int allocateID() { return _nextID++; }
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);
// 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(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,
const glm::vec4& color, int id = UNKNOWN_ID);
void renderLine(const glm::vec3& p1, const glm::vec3& p2, 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 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(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 updateVertices(int id, const QVector<glm::vec2>& points);
void updateVertices(int id, const QVector<glm::vec3>& points);
void renderVertices(GLenum mode, int 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(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 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(gpu::Primitive primitiveType, int id);
/// Loads geometry from the specified URL.
/// \param fallback a fallback URL to load if the desired one is unavailable
@ -128,64 +190,91 @@ protected:
virtual QSharedPointer<Resource> createResource(const QUrl& url,
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
private:
GeometryCache();
virtual ~GeometryCache();
typedef QPair<int, int> IntPair;
typedef QPair<GLuint, GLuint> VerticesIndices;
QHash<IntPair, VerticesIndices> _hemisphereVBOs;
QHash<IntPair, VerticesIndices> _sphereVBOs;
QHash<IntPair, VerticesIndices> _squareVBOs;
QHash<IntPair, VerticesIndices> _halfCylinderVBOs;
QHash<IntPair, VerticesIndices> _coneVBOs;
QHash<float, VerticesIndices> _wireCubeVBOs;
QHash<float, VerticesIndices> _solidCubeVBOs;
QHash<Vec2Pair, VerticesIndices> _quad2DVBOs;
QHash<Vec2PairPair, VerticesIndices> _quad2DTextureVBOs;
QHash<Vec3Pair, VerticesIndices> _quad3DVBOs;
QHash<Vec3PairVec2Pair, VerticesIndices> _quad3DTextureVBOs;
QHash<int, VerticesIndices> _registeredQuadVBOs;
int _nextID;
QHash<int, Vec2Pair> _lastRegisteredQuad2D;
QHash<int, Vec2PairPair> _lastRegisteredQuad2DTexture;
QHash<int, Vec3Pair> _lastRegisteredQuad3D;
QHash<int, Vec3PairVec2Pair> _lastRegisteredQuad3DTexture;
QHash<int, Vec3Pair> _lastRegisteredRect;
QHash<Vec3Pair, VerticesIndices> _rectVBOs;
QHash<int, VerticesIndices> _registeredRectVBOs;
QHash<int, Vec3Pair> _lastRegisteredLine3D;
QHash<Vec3Pair, VerticesIndices> _line3DVBOs;
QHash<int, VerticesIndices> _registeredLine3DVBOs;
QHash<int, Vec2Pair> _lastRegisteredLine2D;
QHash<Vec2Pair, VerticesIndices> _line2DVBOs;
QHash<int, VerticesIndices> _registeredLine2DVBOs;
struct BufferDetails {
QOpenGLBuffer buffer;
int vertices;
int vertexSize;
};
QHash<int, BufferDetails> _registeredVertices;
QHash<float, gpu::BufferPointer> _cubeVerticies;
QHash<Vec2Pair, gpu::BufferPointer> _cubeColors;
gpu::BufferPointer _wireCubeIndexBuffer;
QHash<int, Vec3Pair> _lastRegisteredDashedLines;
QHash<Vec3Pair, BufferDetails> _dashedLines;
QHash<int, BufferDetails> _registeredDashedLines;
QHash<float, gpu::BufferPointer> _solidCubeVerticies;
QHash<Vec2Pair, gpu::BufferPointer> _solidCubeColors;
gpu::BufferPointer _solidCubeIndexBuffer;
class BatchItemDetails {
public:
static int population;
gpu::BufferPointer verticesBuffer;
gpu::BufferPointer colorBuffer;
gpu::Stream::FormatPointer streamFormat;
gpu::BufferStreamPointer stream;
int vertices;
int vertexSize;
bool isCreated;
BatchItemDetails();
BatchItemDetails(const GeometryCache::BatchItemDetails& other);
~BatchItemDetails();
void clear();
};
QHash<IntPair, VerticesIndices> _coneVBOs;
int _nextID;
QHash<int, Vec3PairVec4Pair> _lastRegisteredQuad3DTexture;
QHash<Vec3PairVec4Pair, BatchItemDetails> _quad3DTextures;
QHash<int, BatchItemDetails> _registeredQuad3DTextures;
QHash<int, Vec2PairPair> _lastRegisteredQuad2DTexture;
QHash<Vec2PairPair, BatchItemDetails> _quad2DTextures;
QHash<int, BatchItemDetails> _registeredQuad2DTextures;
QHash<IntPair, QOpenGLBuffer> _gridBuffers;
QHash<int, QOpenGLBuffer> _registeredAlternateGridBuffers;
QHash<Vec3Pair, QOpenGLBuffer> _alternateGridBuffers;
QHash<int, Vec3Pair> _lastRegisteredGrid;
QHash<int, Vec3Pair> _lastRegisteredQuad3D;
QHash<Vec3Pair, BatchItemDetails> _quad3D;
QHash<int, BatchItemDetails> _registeredQuad3D;
QHash<int, Vec2Pair> _lastRegisteredQuad2D;
QHash<Vec2Pair, BatchItemDetails> _quad2D;
QHash<int, BatchItemDetails> _registeredQuad2D;
QHash<int, Vec3Pair> _lastRegisteredBevelRects;
QHash<Vec3Pair, BatchItemDetails> _bevelRects;
QHash<int, BatchItemDetails> _registeredBevelRects;
QHash<int, Vec3Pair> _lastRegisteredLine3D;
QHash<Vec3Pair, BatchItemDetails> _line3DVBOs;
QHash<int, BatchItemDetails> _registeredLine3DVBOs;
QHash<int, Vec2Pair> _lastRegisteredLine2D;
QHash<Vec2Pair, BatchItemDetails> _line2DVBOs;
QHash<int, BatchItemDetails> _registeredLine2DVBOs;
QHash<int, BatchItemDetails> _registeredVertices;
QHash<int, Vec3PairVec2Pair> _lastRegisteredDashedLines;
QHash<Vec3PairVec2Pair, BatchItemDetails> _dashedLines;
QHash<int, BatchItemDetails> _registeredDashedLines;
QHash<IntPair, gpu::BufferPointer> _gridBuffers;
QHash<int, gpu::BufferPointer> _registeredAlternateGridBuffers;
QHash<Vec3Pair, gpu::BufferPointer> _alternateGridBuffers;
QHash<Vec3Pair, gpu::BufferPointer> _gridColors;
QHash<Vec2Pair, gpu::BufferPointer> _sphereVertices;
QHash<IntPair, gpu::BufferPointer> _sphereIndices;
QHash<Vec3Pair, gpu::BufferPointer> _sphereColors;
QHash<QUrl, QWeakPointer<NetworkGeometry> > _networkGeometry;
};
@ -211,7 +300,7 @@ public:
const FBXGeometry& getFBXGeometry() const { return _geometry; }
const QVector<NetworkMesh>& getMeshes() const { return _meshes; }
//
QVector<int> getJointMappings(const AnimationPointer& animation);
virtual void setLoadPriority(const QPointer<QObject>& owner, float priority);

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,11 @@
#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);
}

View file

@ -70,16 +70,11 @@ int TextRenderer::calculateHeight(const char* str) {
return maxHeight;
}
int TextRenderer::draw(int x, int y, const char* str, float alpha) {
// Grab the current color
float currentColor[4];
glGetFloatv(GL_CURRENT_COLOR, currentColor);
alpha = std::max(0.0f, std::min(alpha, 1.0f));
currentColor[3] *= alpha;
int compactColor = ((int(currentColor[0] * 255.0f) & 0xFF)) |
((int(currentColor[1] * 255.0f) & 0xFF) << 8) |
((int(currentColor[2] * 255.0f) & 0xFF) << 16) |
((int(currentColor[3] * 255.0f) & 0xFF) << 24);
int TextRenderer::draw(int x, int y, const char* str, const glm::vec4& color) {
int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
((int(color.y * 255.0f) & 0xFF) << 8) |
((int(color.z * 255.0f) & 0xFF) << 16) |
((int(color.w * 255.0f) & 0xFF) << 24);
int maxHeight = 0;
for (const char* ch = str; *ch != 0; ch++) {

View file

@ -13,6 +13,7 @@
#define hifi_TextRenderer_h
#include <gpu/GPUConfig.h>
#include <glm/glm.hpp>
#include <QColor>
#include <QFont>
@ -70,7 +71,7 @@ public:
int calculateHeight(const char* str);
// also returns the height of the tallest character
int draw(int x, int y, const char* str, float alpha = 1.0f);
int draw(int x, int y, const char* str, const glm::vec4& color);
int computeWidth(char ch);
int computeWidth(const char* str);

View file

@ -154,14 +154,16 @@ const gpu::TexturePointer& TextureCache::getPermutationNormalTexture() {
}
const unsigned char OPAQUE_WHITE[] = { 0xFF, 0xFF, 0xFF, 0xFF };
const unsigned char TRANSPARENT_WHITE[] = { 0xFF, 0xFF, 0xFF, 0x0 };
const unsigned char OPAQUE_BLACK[] = { 0x0, 0x0, 0x0, 0xFF };
//const unsigned char TRANSPARENT_WHITE[] = { 0xFF, 0xFF, 0xFF, 0x0 };
//const unsigned char OPAQUE_BLACK[] = { 0x0, 0x0, 0x0, 0xFF };
const unsigned char OPAQUE_BLUE[] = { 0x80, 0x80, 0xFF, 0xFF };
/*
static void loadSingleColorTexture(const unsigned char* color) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, color);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
*/
const gpu::TexturePointer& TextureCache::getWhiteTexture() {
if (_whiteTexture.isNull()) {

View file

@ -115,6 +115,16 @@ QDebug& operator<<(QDebug& dbg, const glm::vec3& v) {
return dbg;
}
QDebug& operator<<(QDebug& dbg, const glm::vec4& v) {
dbg.nospace() << "{type='glm::vec4'"
", x=" << v.x <<
", y=" << v.y <<
", z=" << v.z <<
", w=" << v.w <<
"}";
return dbg;
}
QDebug& operator<<(QDebug& dbg, const glm::quat& q) {
dbg.nospace() << "{type='glm::quat'"
", x=" << q.x <<

View file

@ -51,6 +51,7 @@ class QDebug;
// Add support for writing these to qDebug().
QDebug& operator<<(QDebug& s, const glm::vec2& v);
QDebug& operator<<(QDebug& s, const glm::vec3& v);
QDebug& operator<<(QDebug& s, const glm::vec4& v);
QDebug& operator<<(QDebug& s, const glm::quat& q);
QDebug& operator<<(QDebug& s, const glm::mat4& m);
#endif // QT_NO_DEBUG_STREAM