système pour contrôler le rendu de sprite de taille differente
# Pour l'instant toutes les sprites d'un même état doivent être de la même taille
This commit is contained in:
@ -8,6 +8,13 @@ import engine.math.*;
|
||||
*/
|
||||
public class ObjectGl {
|
||||
|
||||
/**
|
||||
* STATE CONST DECLARATION
|
||||
*/
|
||||
public static final int DEFAULT = 0, STICK_BOTTOM = 1, STICK_TOP = 2;
|
||||
|
||||
private int stick_state;
|
||||
|
||||
protected VertexArray vertexArray;
|
||||
protected Shader shader;
|
||||
protected Matrix4f transform;
|
||||
@ -58,16 +65,17 @@ public class ObjectGl {
|
||||
this.scalingFactor = size;
|
||||
this.transform = Matrix4f.identity();
|
||||
this.scale(new Vector3f(size, size,1f));
|
||||
this.stick_state = DEFAULT;
|
||||
|
||||
// use different shader for each set of option
|
||||
if (tex == null && color == null){
|
||||
this.shader = new Shader("shaders/ObjectGl/vert.glsl","shaders/ObjectGl/frag.glsl");
|
||||
} else if (tex == null){
|
||||
this.shader = new Shader("shaders/ObjectGlColor/vert.glsl","shaders/ObjectGlColor/frag.glsl"); // TODO
|
||||
this.shader = new Shader("shaders/ObjectGlColor/vert.glsl","shaders/ObjectGlColor/frag.glsl");
|
||||
} else if (color == null){
|
||||
this.shader = new Shader("shaders/ObjectGlTex/vert.glsl","shaders/ObjectGlTex/frag.glsl");
|
||||
} else {
|
||||
this.shader = new Shader("shaders/ObjectGlTexColor/vert.glsl","shaders/ObjectGlTexColor/frag.glsl"); // TODO
|
||||
this.shader = new Shader("shaders/ObjectGlTexColor/vert.glsl","shaders/ObjectGlTexColor/frag.glsl");
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,8 +146,21 @@ public class ObjectGl {
|
||||
* @param w the length of the wrapping on the horizontal axis
|
||||
* @param h the length of the wrapping on the vertical axis
|
||||
*/
|
||||
public void setTextureWrap(float x, float y, float w, float h){
|
||||
public void setTextureWrap(float x, float y, float w, float h, int sticky){
|
||||
// TODO set sticky property + precision issue
|
||||
if (this.stick_state != sticky){ // Check if we're using a new dimension
|
||||
if (sticky == STICK_BOTTOM){
|
||||
this.stick_state = STICK_BOTTOM;
|
||||
this.translate(new Vector3f(0.0f, (h - this.height)*this.scalingFactor, 0.0f));
|
||||
} else if (sticky == STICK_TOP){
|
||||
this.stick_state = STICK_TOP;
|
||||
this.translate(new Vector3f(0.0f, (h - this.height)*this.scalingFactor, 0.0f));
|
||||
} else {
|
||||
this.stick_state = DEFAULT;
|
||||
}
|
||||
}
|
||||
this.height = h;
|
||||
this.width = w;
|
||||
this.vertexArray.swapVertexBufferObject(Primitive.createRectangle(this.zPos, w, h));
|
||||
int texWidth = this.texture.getWidth();
|
||||
int texHeight = this.texture.getHeight();
|
||||
|
Reference in New Issue
Block a user