ProgressBar.java added, can be used to represent healthbar ;o)

This commit is contained in:
Antoine
2021-06-12 02:47:13 +02:00
parent f85a15b393
commit 8b9d698acc
4 changed files with 103 additions and 8 deletions

View File

@ -0,0 +1,45 @@
package engine.object;
import engine.math.Vector3f;
import static org.lwjgl.glfw.GLFW.glfwGetTime;
public class ProgressBar extends ObjectGl{
private float max;
private float current;
public ProgressBar(float z, float w, float h, float size, float current, float max) {
super(z, w, h, size, null, new Vector3f(0f, 1f, 0f));
this.current = current;
this.max = max;
this.setShader("shaders/StylishShaders/BasicNoTexVert.glsl", "shaders/StylishShaders/ProgressBarFrag.glsl");
}
public void setCurrent(float newCurrent){
this.current = newCurrent;
}
public void setMax(float newMax){
this.max = newMax;
}
/**
* Do shader binding, texture binding and vertexArray drawing
*/
public void render(){
this.shader.enable();
if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime());
this.shader.setUniform1f("fill", (this.current / this.max) * this.getWidth());
this.shader.setUniformMat4f("projection", projection);
this.shader.setUniformMat4f("view", view);
this.shader.setUniformMat4f("transform", this.transform);
this.vertexArray.render();
this.shader.disable();
}
}