Nouveau shader pour les barres de progression qui donne un aspect "tube"

This commit is contained in:
Antoine
2021-06-17 14:34:52 +02:00
parent d587940b45
commit ec45df9c5e
4 changed files with 49 additions and 2 deletions

View File

@ -9,13 +9,15 @@ public class HorizontalProgressBar extends ObjectGl {
private float max;
private float current;
private int leftToRight;
private boolean useHeight;
public HorizontalProgressBar(float z, float w, float h, float size, float current, float max, boolean leftToRight) {
super(z, w, h, size, null, new Vector3f(0f, 1f, 0f));
this.max = max;
this.current = current;
this.leftToRight = leftToRight ? 1 : 0;
this.setShader("shaders/StylishShaders/BasicNoTexVert.glsl", "shaders/StylishShaders/HorizontalProgressBar.glsl");
this.useHeight = false;
this.setShader("shaders/StylishShaders/BasicNoTexVert.glsl", "shaders/StylishShaders/HorizontalProgressBarFrag.glsl");
}
public void setCurrent(float newCurrent) {
@ -26,6 +28,10 @@ public class HorizontalProgressBar extends ObjectGl {
this.max = newMax;
}
public void setUseHeight(boolean b){
this.useHeight = b;
}
protected void uniformInjection() {
if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime());
@ -35,6 +41,10 @@ public class HorizontalProgressBar extends ObjectGl {
this.shader.setUniform1f("fill", Math.abs(((this.current / this.max) * this.getWidth()) - this.getWidth()));
}
if (this.useHeight) {
this.shader.setUniform1f("height", this.height);
}
this.shader.setUniform1i("leftToRight", this.leftToRight);
this.shader.setUniformMat4f("projection", projection);