From ef42203481b67d9f368dee3484f84345bd2f8960 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 17 Dec 2014 15:58:52 -0800 Subject: [PATCH] add wire cube implementation to GeometryCache and DeferredLightingEffect --- libraries/render-utils/src/DeferredLightingEffect.cpp | 2 +- libraries/render-utils/src/GeometryCache.cpp | 8 ++++++-- libraries/render-utils/src/GeometryCache.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 14d383418f..065ca3a741 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -68,7 +68,7 @@ void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int sta void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks) { bindSimpleProgram(); - glutWireSphere(radius, slices, stacks); + DependencyManager::get()->renderSphere(radius, slices, stacks, false); releaseSimpleProgram(); } diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 56092945a2..a770d942fe 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -119,7 +119,7 @@ const int NUM_COORDS_PER_VERTEX = 3; const int NUM_BYTES_PER_VERTEX = NUM_COORDS_PER_VERTEX * sizeof(GLfloat); const int NUM_BYTES_PER_INDEX = sizeof(GLushort); -void GeometryCache::renderSphere(float radius, int slices, int stacks) { +void GeometryCache::renderSphere(float radius, int slices, int stacks, bool solid) { VerticesIndices& vbo = _sphereVBOs[IntPair(slices, stacks)]; int vertices = slices * (stacks - 1) + 2; int indices = slices * stacks * NUM_VERTICES_PER_TRIANGULATED_QUAD; @@ -211,7 +211,11 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks) { glPushMatrix(); glScalef(radius, radius, radius); - glDrawRangeElementsEXT(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0); + if (solid) { + glDrawRangeElementsEXT(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0); + } else { + glDrawRangeElementsEXT(GL_LINES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0); + } glPopMatrix(); glDisableClientState(GL_VERTEX_ARRAY); diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 97f24f94a3..f0045c10bf 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -38,7 +38,7 @@ class GeometryCache : public ResourceCache { public: void renderHemisphere(int slices, int stacks); - void renderSphere(float radius, 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);