ProgressBar.java added, can be used to represent healthbar ;o)
This commit is contained in:
45
src/engine/object/ProgressBar.java
Normal file
45
src/engine/object/ProgressBar.java
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user