I changed the code since for be more explicit and have a cleaner code :
package fr.fireblaim.testvbo;
import org.lwjgl.*;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.opengl.*;
import java.nio.*;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.system.MemoryUtil.*;
public class Main {
public static void main(String[] args) {
if (!glfwInit()) {
System.out.println("GLFW not init.");
return;
}
GLFWErrorCallback.createPrint(System.err).set();
long window = glfwCreateWindow(500, 500, "Window", NULL, NULL);
if (window == NULL) {
System.out.println("Window not create.");
return;
}
glfwDefaultWindowHints();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwShowWindow(window);
glfwMakeContextCurrent(window);
GL.createCapabilities();
float[]vboData=new float[] {
10, -10,
10, -10,
10, 10,
-10, 10
};
FloatBuffer buf = BufferUtils.createFloatBuffer(vboData.length);
buf.put(vboData).flip();
int vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER,vbo);
glBufferData(GL_ARRAY_BUFFER, buf, GL_STATIC_DRAW);
while (!glfwWindowShouldClose(window)) {
glClearColor(0.2f, 0.2f, 0.2f, 1);
glClear(GL_COLOR_BUFFER_BIT);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(vbo, GL_FLOAT, 0, 0);
glDrawArrays(GL_QUADS, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
}
}
The buffer would be ok but I have the same jvm error....