Plus de problème de perf

This commit is contained in:
Antoine 2021-06-18 22:02:00 +02:00
parent d06411aff2
commit 631437a1e9

View File

@ -56,70 +56,55 @@ public class UIInputList extends UIDummy{
public void createNextButton(int i){ public void createNextButton(int i){
boolean[] input = inputBuffer.getInputList()[i].getTab(); boolean[] input = inputBuffer.getInputList()[i].getTab();
ObjectGl obj = null;
if (input[0]) { if (input[0]) {
// UP // UP
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.up); obj.setTexture(tex.up);
listIcon.add(obj);
} if (input[1]){ } if (input[1]){
// DOWN // DOWN
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.down); obj.setTexture(tex.down);
listIcon.add(obj);
} if (input[2]){ //Pour l'instant on fait comme si l'avant était toujours à droite donc arrière à gauche } if (input[2]){ //Pour l'instant on fait comme si l'avant était toujours à droite donc arrière à gauche
// BACK // BACK
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.left); obj.setTexture(tex.left);
listIcon.add(obj);
} if (input[3]){ } if (input[3]){
// FORWARD // FORWARD
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.right); obj.setTexture(tex.right);
listIcon.add(obj);
} if (input[4]){ } if (input[4]){
// A // A
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.X); obj.setTexture(tex.X);
listIcon.add(obj);
} if (input[5]){ } if (input[5]){
// B // B
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.A); obj.setTexture(tex.A);
listIcon.add(obj);
} if (input[6]){ } if (input[6]){
// C // C
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.Y); obj.setTexture(tex.Y);
listIcon.add(obj);
} if (input[7]){ } if (input[7]){
// D // D
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.B); obj.setTexture(tex.B);
listIcon.add(obj);
} }
for (ObjectGl obj : listIcon){ if (obj != null){
listIcon.add(obj);
obj.setShader("shaders/ObjectGlTex/vert.glsl", "shaders/ObjectGlTex/frag.glsl"); obj.setShader("shaders/ObjectGlTex/vert.glsl", "shaders/ObjectGlTex/frag.glsl");
engine.add_objectGl(obj);
} }
} }
public void createButtonList(){ public void createButtonList(){
engine.remove_objectsGl(listIcon); createNextButton(this.posBuffer);
listIcon = new ArrayList<>();
int count = 0; if(listIcon.size() > 30){
int index = this.posBuffer; engine.remove_objectGl(listIcon.get(0));
do { listIcon.remove(listIcon.get(0));
createNextButton(index); }
index --;
count ++;
if (index < 0){
index = this.sizeBuffer - 1;
}
} while(count < 30);
Collections.reverse(listIcon);
engine.add_objectsGl(listIcon);
} }
/** /**