List of usage examples for org.lwjgl.opengl GL30 glGenVertexArrays
@NativeType("void") public static int glGenVertexArrays()
From source file:fr.ign.cogit.geoxygene.util.gl.GLGradientComplex.java
License:Open Source License
/** * Bind Buffers with gl Context//from w ww . ja va 2s .co m */ private void generateVao() { // Create a new Vertex Array Object in memory and select it (bind) this.vaoId = GL30.glGenVertexArrays(); if (this.vaoId <= 0) { logger.error("VAO ID is invalid " + this.vaoId); } glBindVertexArray(this.vaoId); // create the Vertex VBO this.vboVerticesId = glGenBuffers(); if (this.vboVerticesId <= 0) { logger.error("VBO(Vertices) ID is invalid " + this.vboVerticesId); } glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vboVerticesId); int byteShift = 0; for (GLInput input : this.getInputs()) { GL20.glVertexAttribPointer(input.getLocation(), input.getComponentCount(), input.getGlType(), input.isNormalized(), this.getStride(), byteShift); byteShift += input.getComponentCount() * GLTools.sizeInBytes(input.getGlType()); glEnableVertexAttribArray(input.getLocation()); } glBufferData(GL_ARRAY_BUFFER, this.getFlippedVerticesBuffer(), GL_STATIC_DRAW); // displayBuffer(this.getFlippedVerticesBuffer()); // glBindBuffer(GL_ARRAY_BUFFER, 0); // create the index VBO this.vboIndicesId = glGenBuffers(); if (this.vboIndicesId <= 0) { logger.error("VBO(Indices) ID is invalid " + this.vboIndicesId); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this.vboIndicesId); glBufferData(GL_ELEMENT_ARRAY_BUFFER, this.getFlippedIndicesBuffer(), GL_STATIC_DRAW); // displayBuffer(this.getFlippedIndicesBuffer()); glBindVertexArray(0); }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glGenVertexArrays(int n, int[] arrays, int offset) { for (int i = offset; i < offset + n; i++) { arrays[i] = GL30.glGenVertexArrays(); }//from ww w . j a va 2 s .c om }
From source file:main.java.com.YeAJG.game.entity.Entity.java
License:Open Source License
private void SetupEntity(Vector3f[] vertex, Vector3f[] color, Vector2f[] uv) { // We'll define our quad using 4 vertices of the custom 'TexturedVertex' class vertices = new VertexData[vertex.length]; for (int i = 0; i < vertex.length; i++) { vertices[i] = new VertexData(); vertices[i].setXYZ(vertex[i].x, vertex[i].y, vertex[i].z); vertices[i].setRGBA(color[i].x, color[i].y, color[i].z, 1.0f); vertices[i].setST(uv[i].x, uv[i].y); }// w w w. j a va 2 s.c o m // Put each 'Vertex' in one FloatBuffer verticesByteBuffer = BufferUtils.createByteBuffer(vertices.length * VertexData.stride); FloatBuffer verticesFloatBuffer = verticesByteBuffer.asFloatBuffer(); for (int i = 0; i < vertices.length; i++) { // Add position, color and texture floats to the buffer verticesFloatBuffer.put(vertices[i].getElements()); } verticesFloatBuffer.flip(); // OpenGL expects to draw vertices in counter clockwise order by default // TODO: Move this to Setup. byte[] indices = { 0, 1, 2, 2, 3, 0 }; indicesCount = indices.length; ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(indicesCount); indicesBuffer.put(indices); indicesBuffer.flip(); // Create a new Vertex Array Object in memory and select it (bind) vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId); // Create a new Vertex Buffer Object in memory and select it (bind) vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesFloatBuffer, GL15.GL_STREAM_DRAW); // Put the position coordinates in attribute list 0 GL20.glVertexAttribPointer(0, VertexData.positionElementCount, GL11.GL_FLOAT, false, VertexData.stride, VertexData.positionByteOffset); // Put the color components in attribute list 1 GL20.glVertexAttribPointer(1, VertexData.colorElementCount, GL11.GL_FLOAT, false, VertexData.stride, VertexData.colorByteOffset); // Put the texture coordinates in attribute list 2 GL20.glVertexAttribPointer(2, VertexData.textureElementCount, GL11.GL_FLOAT, false, VertexData.stride, VertexData.textureByteOffset); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // Deselect (bind to 0) the VAO GL30.glBindVertexArray(0); // Create a new VBO for the indices and select it (bind) - INDICES vboiId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); Game.cameraPos = new Vector3f(0, 0, -1); Game.exitOnGLError("setupQuad"); }
From source file:main.Loader.java
private int createVAO() { int vaoID = GL30.glGenVertexArrays(); vaos.add(vaoID); GL30.glBindVertexArray(vaoID); return vaoID; }
From source file:me.sunchiro.game.engine.gl.Graphic.java
License:Open Source License
public void createWindow(int width, int height, String name) { this.width = width; this.height = height; glfwSetErrorCallback(errorCallback = Callbacks.errorCallbackPrint(System.err)); if (glfwInit() != GL11.GL_TRUE) throw new IllegalStateException("Unable to initialize GLFW"); glfwDefaultWindowHints(); // optional, the current window hints are glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE); // the window will stay // hidden//from www . j a v a2s . c o m glfwWindowHint(GLFW_RESIZABLE, GL11.GL_TRUE); // the window will be // resizable window = glfwCreateWindow(width, height, name, NULL, NULL); if (window == NULL) throw new RuntimeException("Failed to create the GLFW window"); // glfwSetKeyCallback(window,this.keyCallback = keyCallback); glfwSetWindowSizeCallback(window, resizeCallback()); ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); glfwSetWindowPos(window, (vidmode.asIntBuffer().get(0) - width) / 2, (vidmode.asIntBuffer().get(1) - height) / 2); glfwMakeContextCurrent(window); Graphic.instance = this; glfwSwapInterval(1); GL.createCapabilities(); setCapabilities(); glfwShowWindow(window); // Setup an XNA like background color GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glClearColor(bgColor.x, bgColor.y, bgColor.z, 0); // Map the internal OpenGL coordinate system to the entire screen GL11.glViewport(0, 0, width, height); matBuff = BufferUtils.createFloatBuffer(16); vaoId = GL30.glGenVertexArrays(); vboiId = GL15.glGenBuffers(); vboId = GL15.glGenBuffers(); tid_charmap = texManager.loadTexture("textures/charmap.png", GL13.GL_TEXTURE0); shader.setupShader(); // testQuad(); }
From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30VertexArray.java
License:Open Source License
@Override public void create() { ensureNotCreated("VertexArray is already created."); // Create the vertex array object this.vao = GL30.glGenVertexArrays(); // Create the index buffer this.ibo = GL15.glGenBuffers(); // Create the attributes list this.attributes = new TIntArrayList(3, -1); // Check for errors RenderUtil.checkGLError();/*from w w w . jav a 2 s . c om*/ super.create(); }
From source file:net.smert.frameworkgl.opengl.helpers.VertexArrayObjectHelper.java
License:Apache License
public int create() { return GL30.glGenVertexArrays(); }
From source file:opengl.test.Demo.java
@Override protected void init() { // GLFW.glfwSetInputMode(super.windowID, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_HIDDEN); this.CursorX = super.width / 2; this.CursorY = super.height / 2; this.xControl = 11.7f; this.vao = GL30.glGenVertexArrays(); this.caro = new Caro(vao); this.caro.setProjectionMatrix(Matrix4F.PROJECTION(0.5f, -0.5f, -0.5f, 0.5f, 1f, 10)); this.caro.setModelMatrix(Matrix4F.move(0, 0, 11.9f)); this.gt = new GioiThieu(vao); this.gt.setProjectionMatrix(Matrix4F.PROJECTION(0.5f, -0.5f, -0.5f, 0.5f, 1f, 10)); this.gt.setModelMatrix(Matrix4F.rotateOY(180).nhanMaTran(Matrix4F.move(0, 0, -11.9f))); this.c = new cube(vao, 3.0f, 3.0f, 12.0f); this.c.setProjectionMatrix(Matrix4F.PROJECTION(0.5f, -0.5f, -0.5f, 0.5f, 1f, 10)); this.table = new table(vao); this.table.setProjectionMatrix(Matrix4F.PROJECTION(0.5f, -0.5f, -0.5f, 0.5f, 1f, 10)); this.table.setModelMatrix(Matrix4F.rotateOY(180).nhanMaTran(Matrix4F.move(2, -3, -10.6f))); this.tivi = new tivi(vao); this.tivi.setProjectionMatrix(Matrix4F.PROJECTION(0.5f, -0.5f, -0.5f, 0.5f, 1f, 10)); this.tivi.setModelMatrix( Matrix4F.rotateOY(92.99915f).nhanMaTran(Matrix4F.move(1.8000002f, -1.9000002f, -10.600004f))); GL11.glEnable(GL11.GL_DEPTH_TEST);// w w w .jav a 2 s .c o m }
From source file:org.bonsaimind.badgersvoyage.opengl.RenderObject.java
License:Open Source License
protected void createOpenGL(int programId) { modelMatrix = new Matrix4f(); modelMatrixLocation = GL20.glGetUniformLocation(programId, "modelMatrix"); modelMatrixBuffer = BufferUtils.createFloatBuffer(16); verticesCount = vertices.length / 3; verticesBuffer = BufferUtils.createFloatBuffer(vertices.length); verticesBuffer.put(vertices);/*from ww w .j a va2 s. co m*/ verticesBuffer.flip(); vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId); vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
From source file:org.spout.engine.renderer.GL30BatchVertexRenderer.java
License:Open Source License
/** * Batch Renderer using OpenGL 3.0 mode. * @param renderMode Mode to render in/* www. ja v a 2 s . c om*/ */ public GL30BatchVertexRenderer(int renderMode) { super(renderMode); vao = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vao); vertexBuffers.put(0, new VertexBufferImpl("vPosition", 4, 0)); }