From b5d18197ff1bd953f6e08afc031431cc5d76559f Mon Sep 17 00:00:00 2001 From: Antoine Date: Thu, 13 May 2021 21:05:11 +0200 Subject: [PATCH] Ajout de classe primitive --- src/engine/Engine.java | 7 +++---- src/engine/Primitive.java | 11 +++++++++++ src/engine/Scene.java | 10 +++------- 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 src/engine/Primitive.java diff --git a/src/engine/Engine.java b/src/engine/Engine.java index d906554..8eba812 100644 --- a/src/engine/Engine.java +++ b/src/engine/Engine.java @@ -40,8 +40,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 = 800; + int height = 600; this.window = glfwCreateWindow(width, height, "Boulevard Combattant", NULL, NULL); assert this.window != NULL; @@ -63,8 +63,7 @@ public class Engine { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); System.out.println("OpenGL: " + glGetString(GL_VERSION)); - - this.scene = new Scene(); + this.scene = new Scene("shaders/vert.vert", "shaders/frag.frag", Primitive.triangle); } diff --git a/src/engine/Primitive.java b/src/engine/Primitive.java new file mode 100644 index 0000000..887595e --- /dev/null +++ b/src/engine/Primitive.java @@ -0,0 +1,11 @@ +package engine; + +public class Primitive { + + public static float[] triangle = new float[] { + 0.0f, 0.5f, 0.0f, + 0.5f, -0.5f, 0.0f, + -0.5f, -0.5f, 0.0f, + }; + +} diff --git a/src/engine/Scene.java b/src/engine/Scene.java index 53d8fdb..301c470 100644 --- a/src/engine/Scene.java +++ b/src/engine/Scene.java @@ -7,13 +7,9 @@ public class Scene { VertexArray vertexArray; Shader shader; - public Scene(){ - this.vertices = new float[] { - -0.5f, -0.5f, 0.0f, //left - 0.5f, -0.5f, 0.0f, //right - 0.0f, 0.5f, 0.0f //top - }; - this.shader = new Shader("shaders/vert.vert", "shaders/frag.frag"); + public Scene(String vertPath, String fragPath, float[] vertices){ + this.vertices = vertices; + this.shader = new Shader(vertPath, fragPath); this.vertexArray = new VertexArray(this.vertices); }