swapTexWrap from pixels coordinates of the source image
This commit is contained in:
@ -21,6 +21,8 @@ public class ObjectGl {
|
||||
public static Matrix4f view;
|
||||
|
||||
public float zPos;
|
||||
public float width;
|
||||
public float height;
|
||||
|
||||
public ObjectGl(){
|
||||
|
||||
@ -31,6 +33,8 @@ public class ObjectGl {
|
||||
this.transform = Matrix4f.identity();
|
||||
this.shader = new Shader("shaders/ObjectGl/vert.glsl","shaders/ObjectGl/frag.glsl");
|
||||
this.zPos = z;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
}
|
||||
|
||||
public void resetTransform(){
|
||||
|
@ -12,5 +12,7 @@ public class ObjectGlColor extends ObjectGl{
|
||||
this.transform = Matrix4f.identity();
|
||||
this.shader = new Shader("shaders/ObjectGlColor/vert.glsl","shaders/ObjectGlColor/frag.glsl");
|
||||
this.zPos = z;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ public class ObjectGlTex extends ObjectGl{
|
||||
this.transform = Matrix4f.identity();
|
||||
this.shader = new Shader("shaders/ObjectGlTex/vert.glsl","shaders/ObjectGlTex/frag.glsl");
|
||||
this.zPos = z;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.setTexture(texPath);
|
||||
}
|
||||
|
||||
@ -39,11 +41,15 @@ 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();
|
||||
x /= texWidth;
|
||||
w /= texWidth;
|
||||
y /= texHeight;
|
||||
h /= texHeight;
|
||||
float[] result = {
|
||||
x / texWidth, y / texHeight,
|
||||
x + w / texWidth, y / texHeight,
|
||||
x + w / texWidth, y + h / texHeight,
|
||||
x / texWidth, y + h / texHeight,
|
||||
x , y ,
|
||||
x + w , y ,
|
||||
x + w , y + h ,
|
||||
x , y + h ,
|
||||
};
|
||||
// TODO scaling object
|
||||
this.setTextureWrap(result);
|
||||
|
@ -17,6 +17,8 @@ public class ObjectGlTexColor extends ObjectGlTex{
|
||||
this.transform = Matrix4f.identity();
|
||||
this.shader = new Shader("shaders/ObjectGlTexColor/vert.glsl","shaders/ObjectGlTexColor/frag.glsl");
|
||||
this.zPos = z;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.setTexture(texPath);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user