Ajout de classe primitive

This commit is contained in:
Antoine 2021-05-13 21:05:11 +02:00
parent e2b43446c8
commit b5d18197ff
3 changed files with 17 additions and 11 deletions

View File

@ -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);
}

11
src/engine/Primitive.java Normal file
View File

@ -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,
};
}

View File

@ -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);
}