swapTexWrap added

This commit is contained in:
Antoine
2021-05-20 19:02:28 +02:00
parent 859344b131
commit 4fc87e7b08
6 changed files with 56 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import engine.graphics.Shader;
import engine.graphics.Texture;
import engine.graphics.VertexArray;
import engine.math.Matrix4f;
import engine.math.Vector3f;
import java.util.ArrayList;
import java.util.List;
@ -35,6 +36,23 @@ public class ObjectGlTex extends ObjectGl{
}
}
public void setTextureWrap(float x, float y, float w, float h){
int texWidth = this.textures.get(0).getWidth();
int texHeight = this.textures.get(0).getHeight();
float[] result = {
x / texWidth, y / texHeight,
x + w / texWidth, y / texHeight,
x + w / texWidth, y + h / texHeight,
x / texWidth, y + h / texHeight,
};
// TODO scaling object
this.setTextureWrap(result);
}
public void setTextureWrap(float[] texture){
this.vertexArray.swapTextureBufferObject(texture);
}
@Override
public void render() {
this.shader.enable();