diff --git a/shaders/StylishShaders/PerlinNoise.glsl b/shaders/StylishShaders/PerlinNoise.glsl index b3f4362..7ff344f 100644 --- a/shaders/StylishShaders/PerlinNoise.glsl +++ b/shaders/StylishShaders/PerlinNoise.glsl @@ -18,14 +18,14 @@ void main() vec2 fragCoordTemp = fragCoord; fragCoordTemp = 8. * fragCoordTemp / fragCoordTemp.y-vec2(7,4); - perlinNoise = sin(perlinNoise + time); + perlinNoise = sin(perlinNoise + time*15); perlinNoise = mix(perlinNoise,color,0.5f); vec4 tex = texture(texture1, texCoord); if (tex.a == 0.0){ FragColor = tex; } else{ - FragColor = mix(tex, perlinNoise, 0.5); + FragColor = mix(tex, perlinNoise, 0.5f); FragColor.a = 1.0f; } } diff --git a/src/engine/Engine.java b/src/engine/Engine.java index b09c2ca..70f2c0e 100644 --- a/src/engine/Engine.java +++ b/src/engine/Engine.java @@ -27,14 +27,18 @@ public class Engine { private boolean running; + private final int width; + private final int height; + /** * Create the engine and initial attributes use .init() to start the engine */ - public Engine() { + public Engine(int width, int height, float aspectRatio) { this.running = false; this.objectsGl = new ArrayList<>(); - float width = 1280.0f; - ObjectGl.projection = Matrix4f.orthographic(-width, width, -width * 9.0f / 16.0f, width * 9.0f / 16.0f, 0.1f, 100.0f); + this.width = width; + this.height = height; + ObjectGl.projection = Matrix4f.orthographic(-width, width, -width * aspectRatio, width * aspectRatio, 0.1f, 100.0f); ObjectGl.view = Matrix4f.translate(new Vector3f(0.0f,0.0f,1.0f)); } @@ -54,8 +58,8 @@ public class Engine { glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //Compatible MAC glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //Le core profile est l'interface 'avancĂ©' d'openGL - int width = 1280; - int height = 720; + int width = this.width; + int height = this.height; this.setWindow(glfwCreateWindow(width, height, "Boulevard Combattant", NULL, NULL)); assert getWindow() != NULL; @@ -115,7 +119,7 @@ public class Engine { /** * Add obj to the render queue - * @param obj + * @param obj ObjectGl to render */ public void add_objectGl(ObjectGl obj){ objectsGl.add(obj); @@ -157,7 +161,7 @@ public class Engine { }; public static void main(String[] args) { - Engine engine = new Engine(); + Engine engine = new Engine(1280, 720, 9.0f/16.0f); int speed = 10 ; //vitesse déplacement Object engine.init(); @@ -170,7 +174,7 @@ public class Engine { zangief.setTextureWrap(58,0,62,84, ObjectGl.STICK_TOP); engine.add_objectGl(zangief); zangief.translate(new Vector3f(-5000.0f,500.0f,10.0f)); - zangief.setColor(new Vector3f(0.0f, 0.0f, 1.0f)); + zangief.setColor(new Vector3f(1.0f, 1.0f, 1.0f)); zangief.useTime = true; zangief.setShader("shaders/StylishShaders/BasicVert.glsl","shaders/StylishShaders/PerlinNoise.glsl");