diff --git a/src/engine/Engine.java b/src/engine/Engine.java index b41ca64..4acb645 100644 --- a/src/engine/Engine.java +++ b/src/engine/Engine.java @@ -286,12 +286,13 @@ public class Engine { if (System.currentTimeMillis() - timer > 1000) { timer += 1000; System.out.println("FPS: " + frame); + texTest.setNewText("FPS " + frame); frame = 0; } - while (!nextFrame) { - nextFrame = System.currentTimeMillis() - lastFrame >= 16.66f; - } +// while (!nextFrame) { +// nextFrame = System.currentTimeMillis() - lastFrame >= 16.66f; +// } nextFrame = false; if (engine.shouldClose()) engine.setRunning(false); diff --git a/src/engine/object/Text.java b/src/engine/object/Text.java index 3f4af03..7d2e0aa 100644 --- a/src/engine/object/Text.java +++ b/src/engine/object/Text.java @@ -8,10 +8,10 @@ import java.util.List; public class Text { - private final List charList; - private float size; - private Engine engine; - private float zPos; + private List charList; + private final float size; + private final Engine engine; + private final float zPos; public Text(String text, float z, float size, Engine engine){ this.charList = new ArrayList<>(); @@ -19,12 +19,16 @@ public class Text { this.size = size; this.engine = engine; this.textToArrayObjectGl(text); + this.addCharListInEngine(); } private void textToArrayObjectGl(String s){ for (int i = 0; i < s.length(); i++){ this.charList.add(this.charToObjectGl(s.charAt(i))); } + } + + private void addCharListInEngine(){ int i = 0; for (ObjectGl c : this.charList){ c.translate(new Vector3f(i * 10.0f * this.size, 0.0f, 0.0f)); @@ -33,6 +37,14 @@ public class Text { } } + public void setNewText(String text){ + // TODO NE PAS REGENERER L'OBJECTGL DE ZERO A CHAQUE FOIS + this.remove(); + this.charList = new ArrayList<>(); + textToArrayObjectGl(text); + this.addCharListInEngine(); + } + public void remove(){ for (ObjectGl obj : this.charList){ this.engine.remove_objectGl(obj); @@ -48,6 +60,9 @@ public class Text { else if (a < 91 && a > 64){ objectGl.setTextureWrap(0.0f + (a - 65) * 10.0f,30.0f,10.0f,10.0f, ObjectGl.DEFAULT); } + else if (a < 64 && a > 31){ + objectGl.setTextureWrap(0.0f + (a - 32) * 10.0f,0.0f,10.0f,10.0f, ObjectGl.DEFAULT); + } return objectGl; }