1
0
Fork 0

Bug Fixes

This commit is contained in:
MrDev023 2017-01-14 17:59:15 +01:00
parent 9124915237
commit 18bb7ab823
13 changed files with 469 additions and 272 deletions

View file

@ -14,23 +14,19 @@ import globalgamejam.math.*;
public class Camera {
public static Matrix4f matrix = new Matrix4f();
public static final float SPEED = 1.0f;//Speed de base
public static float rot = 0.0f;//rotation de la camera
public static float rotation = 0.0f;//rotation de la camera
public static Vector2f pos = new Vector2f();
public static void update(){
float speed = SPEED * Main.delta;//speed reel par frame en fonction des fps
//class Input pour tous ce qui est entrer et sortis
public static void init(){
matrix = new Matrix4f();
rotation = 0.0f;
pos = new Vector2f();
}
public static void transform(){
matrix.loadIdentity();
matrix.rotate(new Quaternion(new Vector3f(0,0,1),rot));
matrix.tranlate(-pos.x, -pos.y, 0);
matrix.translate(-pos.x,-pos.y,0);
matrix.rotate(new Quaternion(new Vector3f(0,0,1),rotation));
}
}

View file

@ -18,7 +18,7 @@ public class DisplayManager {
public static void preRender2D(){
projection.loadIdentity();
projection.Ortho2D(0, Main.WIDTH, 0, Main.HEIGHT, -1, 1);
projection.Ortho2D(-Main.WIDTH/2.0f, Main.WIDTH/2.0f, -Main.HEIGHT/2.0f, Main.HEIGHT/2.0f, -1, 1);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_BLEND);
@ -28,7 +28,7 @@ public class DisplayManager {
public static void preRenderGUI(){
projection.loadIdentity();
//Permet de centrer la camera au centre de l'ecran
projection.Ortho2D(-Main.WIDTH/2.0f, Main.WIDTH/2.0f, -Main.HEIGHT/2.0f, Main.HEIGHT/2.0f, -1, 1);
projection.Ortho2D(0, Main.WIDTH, 0, Main.HEIGHT, -1, 1);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_BLEND);

View file

@ -1,98 +0,0 @@
package globalgamejam.render;
import globalgamejam.math.Color4f;
import globalgamejam.math.Matrix4f;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.*;
import java.nio.FloatBuffer;
/**
* Created by MrDev023 (Florian RICHER) on 14/01/2017.
*/
public abstract class Tile {
private int vbo;
private Texture texture;
private Color4f color;
private Matrix4f transform;
private int size;
public Tile(){
this.texture = new Texture(0,0,0);
this.transform = new Matrix4f();
this.color = Color4f.WHITE;
this.vbo = GL15.glGenBuffers();
load();
}
private void load(){
float[] a = new float[]{
-1.0f,-1.0f, 0.0f,0.0f,
1.0f,-1.0f, 1.0f,0.0f,
1.0f,1.0f, 1.0f,1.0f,
1.0f,-1.0f, 0.0f,1.0f,
};
FloatBuffer buffer = BufferUtils.createFloatBuffer(a.length);
buffer.put(a).flip();
size = a.length/(2+2);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
GL20.glEnableVertexAttribArray(Shaders.MAIN_SHADERS.getAttribLocation("vert"));
GL20.glVertexAttribPointer(Shaders.MAIN_SHADERS.getAttribLocation("vert"), 2, GL11.GL_FLOAT, false, (2+2)*4, 0);
GL20.glEnableVertexAttribArray(Shaders.MAIN_SHADERS.getAttribLocation("vertTexCoord"));
GL20.glVertexAttribPointer(Shaders.MAIN_SHADERS.getAttribLocation("vertTexCoord"), 2, GL11.GL_FLOAT, true, (2+2)*4, 2*4);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
public void render(){
Shaders.MAIN_SHADERS.bind();
Shaders.MAIN_SHADERS.uniform("camera", Camera.matrix);
Shaders.MAIN_SHADERS.uniform("transform", transform);
Shaders.MAIN_SHADERS.uniform("projection", DisplayManager.projection);
Shaders.MAIN_SHADERS.uniform("color", this.color);
GL13.glActiveTexture(GL13.GL_TEXTURE0);
texture.bind();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
GL11.glDrawArrays(GL11.GL_QUADS, 0, size);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
texture.unbind();
Shaders.MAIN_SHADERS.unbind();
}
public void destroy(){
GL15.glDeleteBuffers(vbo);
texture.destroy();
transform = null;
}
public Texture getTexture() {
return texture;
}
public void setTexture(Texture texture) {
this.texture = texture;
}
public Color4f getColor() {
return color;
}
public void setColor(Color4f color4f) {
this.color = color4f;
}
public int getVbo() {
return vbo;
}
public Matrix4f getTransform() {
return transform;
}
}