mirror of
https://github.com/Cpt-Adok/SNAKE.git
synced 2026-01-25 10:34:06 +00:00
Ajout des fichiers de configuration minimal
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
import java.util.random.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.lwjgl.*;
|
||||
import org.lwjgl.glfw.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
import org.lwjgl.system.*;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
import static org.lwjgl.glfw.Callbacks.*;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.system.MemoryStack.*;
|
||||
import static org.lwjgl.system.MemoryUtil.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
if(!GLFW.glfwInit()) {
|
||||
System.err.println("initialization error");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
long window = GLFW.glfwCreateWindow(800, 600, "test fenetre", MemoryUtil.NULL, MemoryUtil.NULL);
|
||||
|
||||
GLFW.glfwMakeContextCurrent(window);
|
||||
GL.createCapabilities();
|
||||
|
||||
while (!GLFW.glfwWindowShouldClose(window)) {
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
|
||||
GLFW.glfwSwapBuffers(window);
|
||||
GLFW.glfwPollEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package graphics;
|
||||
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
public class EBO {
|
||||
private int id;
|
||||
|
||||
public EBO(int[] indices) {
|
||||
this.id = GL15.glGenBuffers();
|
||||
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.id);
|
||||
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_STATIC_DRAW);
|
||||
bind();
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
unbind();
|
||||
GL15.glDeleteBuffers(this.id);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, (int)this.id);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package graphics;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.glDrawArrays;
|
||||
import static org.lwjgl.opengl.GL11.glDrawElements;
|
||||
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
public class VAO {
|
||||
private int id;
|
||||
|
||||
public VAO() {
|
||||
this.id = GL30.glGenVertexArrays();
|
||||
bind();
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
unbind();
|
||||
GL30.glDeleteVertexArrays(id);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
GL30.glBindVertexArray(this.id);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
GL30.glBindVertexArray(0);
|
||||
}
|
||||
|
||||
public void setAttributePointer(int index, int size, int type, int stride, long offset) {
|
||||
GL30.glEnableVertexAttribArray(index);
|
||||
GL30.glVertexAttribPointer(index, size, type, false, stride, offset);
|
||||
}
|
||||
|
||||
public void drawElement(int mode, int count, int type, long indices) {
|
||||
bind();
|
||||
|
||||
glDrawElements(mode, count, type, indices);
|
||||
unbind();
|
||||
}
|
||||
|
||||
public void drawElementIndices(int mode, int first, int count) {
|
||||
bind();
|
||||
glDrawArrays(mode, first, count);
|
||||
unbind();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package graphics;
|
||||
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
public class VBO {
|
||||
private int id;
|
||||
|
||||
public VBO(float[] vertices) {
|
||||
this.id = GL15.glGenBuffers();
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.id);
|
||||
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_STATIC_DRAW);
|
||||
|
||||
bind();
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
unbind();
|
||||
GL15.glDeleteBuffers(this.id);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.id);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user