Cleanup uniformInjection

This commit is contained in:
Antoine 2021-06-14 14:50:23 +02:00
parent ae4a332eaf
commit acf62519f4
3 changed files with 16 additions and 30 deletions

View File

@ -26,13 +26,7 @@ public class HorizontalProgressBar extends ObjectGl{
this.max = newMax; this.max = newMax;
} }
/** protected void uniformInjection() {
* Do shader binding, texture binding and vertexArray drawing
*/
public void render(){
this.shader.enable();
if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime()); if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime());
if (this.leftToRight == 1) { if (this.leftToRight == 1) {
@ -46,9 +40,5 @@ public class HorizontalProgressBar extends ObjectGl{
this.shader.setUniformMat4f("projection", projection); this.shader.setUniformMat4f("projection", projection);
this.shader.setUniformMat4f("view", view); this.shader.setUniformMat4f("view", view);
this.shader.setUniformMat4f("transform", this.transform); this.shader.setUniformMat4f("transform", this.transform);
this.vertexArray.render();
this.shader.disable();
} }
} }

View File

@ -19,21 +19,13 @@ public class Letter extends ObjectGl {
this.indexBasedShader = b; this.indexBasedShader = b;
} }
public void render(){ protected void uniformInjection(){
this.shader.enable();
if (this.texture != null) this.texture.bind();
if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime()); if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime());
if (this.indexBasedShader) this.shader.setUniform1i("index",this.index); if (this.indexBasedShader) this.shader.setUniform1i("index",this.index);
this.shader.setUniformMat4f("projection", projection); this.shader.setUniformMat4f("projection", projection);
this.shader.setUniformMat4f("view", view); this.shader.setUniformMat4f("view", view);
this.shader.setUniformMat4f("transform", this.transform); this.shader.setUniformMat4f("transform", this.transform);
this.vertexArray.render();
if (this.texture != null) this.texture.unbind();
this.shader.disable();
} }
} }

View File

@ -265,6 +265,14 @@ public class ObjectGl {
return scalingFactor; return scalingFactor;
} }
protected void uniformInjection(){
if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime());
this.shader.setUniformMat4f("projection", projection);
this.shader.setUniformMat4f("view", view);
this.shader.setUniformMat4f("transform", this.transform);
}
/** /**
* Do shader binding, texture binding and vertexArray drawing * Do shader binding, texture binding and vertexArray drawing
*/ */
@ -273,11 +281,7 @@ public class ObjectGl {
this.shader.enable(); this.shader.enable();
if (this.texture != null) this.texture.bind(); if (this.texture != null) this.texture.bind();
if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime()); this.uniformInjection();
this.shader.setUniformMat4f("projection", projection);
this.shader.setUniformMat4f("view", view);
this.shader.setUniformMat4f("transform", this.transform);
this.vertexArray.render(); this.vertexArray.render();