swapTexWrap from pixels coordinates of the source image
This commit is contained in:
parent
4fc87e7b08
commit
29685f8e40
@ -9,5 +9,5 @@ uniform sampler2D texture1;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(texture1, vec2(-texCoord.y, -texCoord.x)) * color;
|
||||
FragColor = texture(texture1, texCoord) * color;
|
||||
}
|
@ -159,9 +159,10 @@ public class Engine {
|
||||
List<String> path2 = new ArrayList<>();
|
||||
path2.add("textures/awesomeface.png");
|
||||
|
||||
ObjectGlTex smiley = new ObjectGlTex(-200.5f,200.5f,0.0f,320.0f*6,578.0f*6, path, Primitive.stdTexWrap);
|
||||
engine.add_objectGl(smiley);
|
||||
smiley.translate(new Vector3f(-600.0f,0.0f,9.0f));
|
||||
ObjectGlTex zangief = new ObjectGlTex(0f,0f,0f,400f,900f, path, Primitive.stdTexWrap);
|
||||
engine.add_objectGl(zangief);
|
||||
zangief.translate(new Vector3f(-600.0f,-100.0f,10.0f));
|
||||
zangief.setTextureWrap(52,2,70,83);
|
||||
|
||||
ObjectGlTex smiley2 = new ObjectGlTex(-0.5f,0.5f,0.0f,500.0f,500.0f, path2, Primitive.stdTexWrap);
|
||||
engine.add_objectGl(smiley2);
|
||||
@ -178,11 +179,14 @@ public class Engine {
|
||||
lastFrame = System.currentTimeMillis();
|
||||
// Game logic should fit here
|
||||
|
||||
input(smiley, speed);
|
||||
input(zangief, speed);
|
||||
// input(smiley2, speed);
|
||||
smiley.setTextureWrap(0,0,200,200);
|
||||
|
||||
//essential part v
|
||||
/*
|
||||
********************
|
||||
* essential part v *
|
||||
********************
|
||||
*/
|
||||
engine.update();
|
||||
engine.render();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user