change renderDashedLine() to take a color paramter

This commit is contained in:
ZappoMan 2015-01-28 15:08:59 -08:00
parent f9bcb65467
commit efb044ea5e
7 changed files with 28 additions and 24 deletions

View file

@ -320,8 +320,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
static float textureFOV = 0.0f, textureAspectRatio = 1.0f; static float textureFOV = 0.0f, textureAspectRatio = 1.0f;
if (textureFOV != _textureFov || if (textureFOV != _textureFov ||
textureAspectRatio != _textureAspectRatio) { textureAspectRatio != _textureAspectRatio) {
@ -436,8 +434,6 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
glEnable(GL_LIGHTING); 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 { void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const {

View file

@ -162,6 +162,8 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT, textColor); _textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT, textColor);
// Render vertical lines for the frame // Render vertical lines for the frame
// 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(0, 0, h, COLOR_FRAME);
renderVerticalLine(barWidth, 0, h, COLOR_FRAME); renderVerticalLine(barWidth, 0, h, COLOR_FRAME);

View file

@ -111,20 +111,20 @@ void Cube3DOverlay::render(RenderArgs* args) {
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
geometryCache->renderDashedLine(bottomLeftNear, bottomRightNear); geometryCache->renderDashedLine(bottomLeftNear, bottomRightNear, cubeColor);
geometryCache->renderDashedLine(bottomRightNear, bottomRightFar); geometryCache->renderDashedLine(bottomRightNear, bottomRightFar, cubeColor);
geometryCache->renderDashedLine(bottomRightFar, bottomLeftFar); geometryCache->renderDashedLine(bottomRightFar, bottomLeftFar, cubeColor);
geometryCache->renderDashedLine(bottomLeftFar, bottomLeftNear); geometryCache->renderDashedLine(bottomLeftFar, bottomLeftNear, cubeColor);
geometryCache->renderDashedLine(topLeftNear, topRightNear); geometryCache->renderDashedLine(topLeftNear, topRightNear, cubeColor);
geometryCache->renderDashedLine(topRightNear, topRightFar); geometryCache->renderDashedLine(topRightNear, topRightFar, cubeColor);
geometryCache->renderDashedLine(topRightFar, topLeftFar); geometryCache->renderDashedLine(topRightFar, topLeftFar, cubeColor);
geometryCache->renderDashedLine(topLeftFar, topLeftNear); geometryCache->renderDashedLine(topLeftFar, topLeftNear, cubeColor);
geometryCache->renderDashedLine(bottomLeftNear, topLeftNear); geometryCache->renderDashedLine(bottomLeftNear, topLeftNear, cubeColor);
geometryCache->renderDashedLine(bottomRightNear, topRightNear); geometryCache->renderDashedLine(bottomRightNear, topRightNear, cubeColor);
geometryCache->renderDashedLine(bottomLeftFar, topLeftFar); geometryCache->renderDashedLine(bottomLeftFar, topLeftFar, cubeColor);
geometryCache->renderDashedLine(bottomRightFar, topRightFar); geometryCache->renderDashedLine(bottomRightFar, topRightFar, cubeColor);
} else { } else {
glScalef(dimensions.x, dimensions.y, dimensions.z); glScalef(dimensions.x, dimensions.y, dimensions.z);

View file

@ -60,8 +60,7 @@ void Line3DOverlay::render(RenderArgs* args) {
if (getIsDashedLine()) { if (getIsDashedLine()) {
// TODO: add support for color to renderDashedLine() // TODO: add support for color to renderDashedLine()
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); DependencyManager::get<GeometryCache>()->renderDashedLine(_position, _end, colorv4, _geometryCacheID);
DependencyManager::get<GeometryCache>()->renderDashedLine(_position, _end, _geometryCacheID);
} else { } else {
DependencyManager::get<GeometryCache>()->renderLine(_start, _end, colorv4, _geometryCacheID); DependencyManager::get<GeometryCache>()->renderLine(_start, _end, colorv4, _geometryCacheID);
} }

View file

@ -81,10 +81,10 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
glm::vec3 point3(halfDimensions.x, 0.0f, halfDimensions.y); glm::vec3 point3(halfDimensions.x, 0.0f, halfDimensions.y);
glm::vec3 point4(-halfDimensions.x, 0.0f, halfDimensions.y); glm::vec3 point4(-halfDimensions.x, 0.0f, halfDimensions.y);
geometryCache->renderDashedLine(point1, point2); geometryCache->renderDashedLine(point1, point2, rectangleColor);
geometryCache->renderDashedLine(point2, point3); geometryCache->renderDashedLine(point2, point3, rectangleColor);
geometryCache->renderDashedLine(point3, point4); geometryCache->renderDashedLine(point3, point4, rectangleColor);
geometryCache->renderDashedLine(point4, point1); geometryCache->renderDashedLine(point4, point1, rectangleColor);
} else { } else {

View file

@ -1366,7 +1366,8 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
} }
void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& end, int id) { // TODO: switch this over to use BatchItemDetails like the other line and vertices functions
void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
bool registered = (id != UNKNOWN_ID); bool registered = (id != UNKNOWN_ID);
Vec3Pair key(start, end); Vec3Pair key(start, end);
BufferDetails& details = registered ? _registeredDashedLines[id] : _dashedLines[key]; BufferDetails& details = registered ? _registeredDashedLines[id] : _dashedLines[key];
@ -1383,6 +1384,12 @@ void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& en
} }
if (!details.buffer.isCreated()) { if (!details.buffer.isCreated()) {
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);
// draw each line segment with appropriate gaps // draw each line segment with appropriate gaps
const float DASH_LENGTH = 0.05f; const float DASH_LENGTH = 0.05f;

View file

@ -134,7 +134,7 @@ public:
void renderLine(const glm::vec3& p1, const glm::vec3& p2, void renderLine(const glm::vec3& p1, const glm::vec3& p2,
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID); const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
void renderDashedLine(const glm::vec3& start, const glm::vec3& end, int id = UNKNOWN_ID); void 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) 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); } { renderLine(p1, p2, glm::vec4(color, 1.0f), id); }