WavyTextVert.glsl + support des shaders dans UIElementText.java

This commit is contained in:
Antoine
2021-06-14 17:03:10 +02:00
parent acf62519f4
commit 95d2d7e21c
5 changed files with 50 additions and 12 deletions

View File

@ -77,6 +77,7 @@ public class TestEngine {
UIElementText fpsTracker = new UIElementText("Boulevard Combattant", 5.0f, 0.0f,0.5f, 25.0f, engine);
engine.add_uiElement(fpsTracker);
fpsTracker.setShader("shaders/StylishShaders/WavyTextVert.glsl", "shaders/StylishShaders/TextFrag.glsl", true, true);
UIElementText uiTextCoordP1 = new UIElementText("Boulevard Combattant", 7.0f, 0.0f,0.05f, 25.0f, engine);
engine.add_uiElement(uiTextCoordP1);

View File

@ -2,6 +2,7 @@ package engine.gui;
import engine.Engine;
import engine.math.Vector3f;
import engine.object.Letter;
import engine.object.ObjectGl;
import engine.object.Text;
@ -12,7 +13,7 @@ import java.util.List;
*/
public class UIElementText extends UIDummy{
private final List<ObjectGl> objs;
private final List<Letter> objs;
private final Text txt;
/**
@ -38,7 +39,9 @@ public class UIElementText extends UIDummy{
* Ajouter l'element à la liste de rendu du moteur dont il est lié.
*/
public void init(){
this.engine.add_objectsGl(objs);
for (ObjectGl obj : this.txt.getCharList()){
this.engine.add_objectGl(obj);
}
}
/**
@ -49,6 +52,14 @@ public class UIElementText extends UIDummy{
this.txt.setNewText(txt);
}
public void setShader(String vert, String frag, boolean indexBasedShader, boolean useTime){
for (Letter l : this.txt.getCharList()){
l.setShader(vert, frag);
l.setIndexBasedShader(indexBasedShader);
l.useTime = useTime;
}
}
protected void getObjInPosition(){
int i = 0;
for (ObjectGl obj : this.txt.getCharList()){

View File

@ -12,7 +12,7 @@ import java.util.List;
*/
public class Text {
private List<ObjectGl> charList;
private List<Letter> charList;
private final float size;
private final Engine engine;
private final float zPos;
@ -40,13 +40,13 @@ public class Text {
private void addCharListInEngine(){
int i = 0;
for (ObjectGl obj : this.charList){
for (Letter obj : this.charList){
addCharInEngine(i, obj);
i++;
}
}
private void addCharInEngine(int i, ObjectGl obj){
private void addCharInEngine(int i, Letter obj){
obj.translate(new Vector3f(i * 10.0f * this.size, 0.0f, 0.0f));
obj.translate(transformation);
this.engine.add_objectGl(obj);
@ -57,13 +57,13 @@ public class Text {
public void setNewText(String text){
int i = 0;
for (ObjectGl obj : this.charList) {
for (Letter obj : this.charList) {
ObjectGlSetCharWrap(text.charAt(i), obj);
i++;
if (i >= text.length()) break;
}
while (i < text.length()){
ObjectGl obj = this.charToObjectGl(text.charAt(i), i);
Letter obj = this.charToObjectGl(text.charAt(i), i);
this.charList.add(obj);
addCharInEngine(i, obj);
i++;
@ -91,7 +91,7 @@ public class Text {
private void removeFromIndexToEnd(int i){
int j = 0;
for (ObjectGl objectGl : this.charList){
for (Letter objectGl : this.charList){
if (j >= i) {
this.engine.remove_objectGl(objectGl);
}
@ -100,8 +100,8 @@ public class Text {
this.charList = this.charList.subList(0, i);
}
private ObjectGl charToObjectGl(char a, int index){
ObjectGl objectGl = new Letter(this.zPos, 1.0f, 1.0f, this.size, "textures/dejavu10x10_gs_tc.png", null, index);
private Letter charToObjectGl(char a, int index){
Letter objectGl = new Letter(this.zPos, 1.0f, 1.0f, this.size, "textures/dejavu10x10_gs_tc.png", null, index);
objectGl.setShader("shaders/StylishShaders/BasicVert.glsl","shaders/StylishShaders/TextFrag.glsl");
ObjectGlSetCharWrap(a, objectGl);
return objectGl;
@ -119,7 +119,7 @@ public class Text {
}
}
public List<ObjectGl> getCharList(){
public List<Letter> getCharList(){
return this.charList;
}