From b8fffdb2ef93dd9d7b72754e354a354eb0d65551 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sat, 16 May 2015 04:26:57 +0200 Subject: [PATCH] bind/releaseSimpleProgram takes Batch --- .../src/DeferredLightingEffect.cpp | 33 +++++++++++++------ .../render-utils/src/DeferredLightingEffect.h | 2 ++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 3940ccf05b..b12fcc03a6 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -99,12 +99,25 @@ void DeferredLightingEffect::bindSimpleProgram() { glDisable(GL_BLEND); } +void DeferredLightingEffect::bindSimpleProgram(gpu::Batch& batch) { + DependencyManager::get()->setPrimaryDrawBuffers(batch, true, true, true); + batch._glUseProgram(_simpleProgram.programId()); + batch._glUniform1f(_glowIntensityLocation, DependencyManager::get()->getIntensity()); + batch._glDisable(GL_BLEND); +} + void DeferredLightingEffect::releaseSimpleProgram() { glEnable(GL_BLEND); _simpleProgram.release(); DependencyManager::get()->setPrimaryDrawBuffers(true, false, false); } +void DeferredLightingEffect::releaseSimpleProgram(gpu::Batch& batch) { + batch._glEnable(GL_BLEND); + batch._glUseProgram(0); + DependencyManager::get()->setPrimaryDrawBuffers(batch, true, false, false); +} + void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks, const glm::vec4& color) { gpu::Batch batch; renderSolidSphere(batch, radius, slices, stacks, color); @@ -112,9 +125,9 @@ void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int sta } void DeferredLightingEffect::renderSolidSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color) { - bindSimpleProgram(); + bindSimpleProgram(batch); DependencyManager::get()->renderSphere(batch, radius, slices, stacks, color); - releaseSimpleProgram(); + releaseSimpleProgram(batch); } void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stacks, const glm::vec4& color) { @@ -124,9 +137,9 @@ void DeferredLightingEffect::renderWireSphere(float radius, int slices, int stac } void DeferredLightingEffect::renderWireSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color) { - bindSimpleProgram(); + bindSimpleProgram(batch); DependencyManager::get()->renderSphere(batch, radius, slices, stacks, color, false); - releaseSimpleProgram(); + releaseSimpleProgram(batch); } void DeferredLightingEffect::renderSolidCube(float size, const glm::vec4& color) { @@ -136,9 +149,9 @@ void DeferredLightingEffect::renderSolidCube(float size, const glm::vec4& color) } void DeferredLightingEffect::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) { - bindSimpleProgram(); + bindSimpleProgram(batch); DependencyManager::get()->renderSolidCube(batch, size, color); - releaseSimpleProgram(); + releaseSimpleProgram(batch); } void DeferredLightingEffect::renderWireCube(float size, const glm::vec4& color) { @@ -148,9 +161,9 @@ void DeferredLightingEffect::renderWireCube(float size, const glm::vec4& color) } void DeferredLightingEffect::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) { - bindSimpleProgram(); + bindSimpleProgram(batch); DependencyManager::get()->renderWireCube(batch, size, color); - releaseSimpleProgram(); + releaseSimpleProgram(batch); } void DeferredLightingEffect::renderLine(const glm::vec3& p1, const glm::vec3& p2, @@ -162,9 +175,9 @@ void DeferredLightingEffect::renderLine(const glm::vec3& p1, const glm::vec3& p2 void DeferredLightingEffect::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, const glm::vec4& color1, const glm::vec4& color2) { - bindSimpleProgram(); + bindSimpleProgram(batch); DependencyManager::get()->renderLine(batch, p1, p2, color1, color2); - releaseSimpleProgram(); + releaseSimpleProgram(batch); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h index e979aeeb9c..367963b1c9 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -38,9 +38,11 @@ public: /// Sets up the state necessary to render static untextured geometry with the simple program. void bindSimpleProgram(); + void bindSimpleProgram(gpu::Batch& batch); /// Tears down the state necessary to render static untextured geometry with the simple program. void releaseSimpleProgram(); + void releaseSimpleProgram(gpu::Batch& batch); //// Renders a solid sphere with the simple program. void renderSolidSphere(float radius, int slices, int stacks, const glm::vec4& color);