add wire cube implementation to GeometryCache and DeferredLightingEffect

This commit is contained in:
ZappoMan 2014-12-17 15:58:52 -08:00
parent 1617d79f2e
commit ef42203481
3 changed files with 8 additions and 4 deletions

View file

@ -68,7 +68,7 @@ void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int sta
void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks) { void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks) {
bindSimpleProgram(); bindSimpleProgram();
glutWireSphere(radius, slices, stacks); DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks, false);
releaseSimpleProgram(); releaseSimpleProgram();
} }

View file

@ -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_VERTEX = NUM_COORDS_PER_VERTEX * sizeof(GLfloat);
const int NUM_BYTES_PER_INDEX = sizeof(GLushort); 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)]; VerticesIndices& vbo = _sphereVBOs[IntPair(slices, stacks)];
int vertices = slices * (stacks - 1) + 2; int vertices = slices * (stacks - 1) + 2;
int indices = slices * stacks * NUM_VERTICES_PER_TRIANGULATED_QUAD; int indices = slices * stacks * NUM_VERTICES_PER_TRIANGULATED_QUAD;
@ -211,7 +211,11 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks) {
glPushMatrix(); glPushMatrix();
glScalef(radius, radius, radius); 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(); glPopMatrix();
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);

View file

@ -38,7 +38,7 @@ class GeometryCache : public ResourceCache {
public: public:
void renderHemisphere(int slices, int stacks); 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 renderSquare(int xDivisions, int yDivisions);
void renderHalfCylinder(int slices, int stacks); void renderHalfCylinder(int slices, int stacks);
void renderCone(float base, float height, int slices, int stacks); void renderCone(float base, float height, int slices, int stacks);