List of usage examples for org.lwjgl.opengl GL15 GL_ARRAY_BUFFER
int GL_ARRAY_BUFFER
To view the source code for org.lwjgl.opengl GL15 GL_ARRAY_BUFFER.
Click Source Link
From source file:com.xrbpowered.gl.res.shaders.InstanceBuffer.java
License:Open Source License
public void enable() { int offs = 0; for (int i = 0; i < elemCount.length; i++) { GL20.glEnableVertexAttribArray(attribId + i); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, iboId); GL20.glVertexAttribPointer(attribId + i, elemCount[i], GL11.GL_FLOAT, false, stride, offs); offs += 4 * elemCount[i];//from w w w .ja v a2 s . co m GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL33.glVertexAttribDivisor(attribId + i, divisor); // GL20.glGetVertexAttrib(attribId, GL33.GL_VERTEX_ATTRIB_ARRAY_DIVISOR, testParam); Client.checkError(); } }
From source file:com.xrbpowered.gl.res.shaders.InstanceBuffer.java
License:Open Source License
public void disable() { for (int i = 0; i < elemCount.length; i++) GL20.glDisableVertexAttribArray(attribId + i); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:com.xrbpowered.gl.res.StaticMesh.java
License:Open Source License
private void create(VertexInfo info, FloatBuffer vertexBuffer, ShortBuffer indexBuffer, int countElements, int verticesPerElement, boolean dynamic) { this.countElements = countElements; this.drawMode = getDrawMode(verticesPerElement); int usage = dynamic ? GL15.GL_DYNAMIC_DRAW : GL15.GL_STATIC_DRAW; vaoId = GL30.glGenVertexArrays();//from w ww. j ava2 s .c o m GL30.glBindVertexArray(vaoId); vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuffer, usage); this.countAttribs = info.getAttributeCount(); info.initAttribPointers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); if (indexBuffer != null) { vboiId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer, usage); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); } }
From source file:com.xrbpowered.gl.res.StaticMesh.java
License:Open Source License
public void destroy() { GL30.glBindVertexArray(vaoId);/*from w w w .jav a 2s .c o m*/ for (int i = 0; i < countAttribs; i++) GL20.glDisableVertexAttribArray(i); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glDeleteBuffers(vboId); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); if (vboiId != GL11.GL_INVALID_VALUE) GL15.glDeleteBuffers(vboiId); GL30.glBindVertexArray(0); GL30.glDeleteVertexArrays(vaoId); }
From source file:cuchaz.jfxgl.prism.TexturedQuad.java
License:Open Source License
public TexturedQuad(int x, int y, int w, int h, int texId, Shader shader) { this.shader = shader; this.texId = texId; // make the vertex array vaoId = GL30.glGenVertexArrays();/*www . j a va2 s . com*/ GL30.glBindVertexArray(vaoId); try (MemoryStack m = MemoryStack.stackPush()) { // make the indices ByteBuffer indexBuf = m.bytes(new byte[] { 0, 1, 2, 0, 2, 3 }); iboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, iboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, indexBuf, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, iboId); // make the vertices FloatBuffer vertexBuf = m.floats( new float[] { x + 0, y + 0, 0, 0, x + w, y + 0, 1, 0, x + w, y + h, 1, 1, x + 0, y + h, 0, 1 }); vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuf, GL15.GL_STATIC_DRAW); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, 2, GL11.GL_FLOAT, false, Float.BYTES * 4, 0); GL20.glEnableVertexAttribArray(1); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, Float.BYTES * 4, Float.BYTES * 2); } // unbind things GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
From source file:Data.Building.java
License:Apache License
@Override public void setup() { // OpenGL expects vertices to be defined counter clockwise by default triangulize(geometry);// w ww. j ava 2 s. c o m // Sending data to OpenGL requires the usage of (flipped) byte buffers FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length); verticesBuffer.put(vertices); verticesBuffer.flip(); vertexCount = vertices.length; // Create a new Vertex Array Object in memory and select it (bind) // A VAO can have up to 16 attributes (VBO's) assigned to it by default vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId); // Create a new Vertex Buffer Object in memory and select it (bind) // A VBO is a collection of Vectors which in this case resemble the location of each vertex. vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW); // Put the VBO in the attributes list at index 0 GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); // Deselect (bind to 0) the VBO GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // Deselect (bind to 0) the VAO GL30.glBindVertexArray(0); Util.exitOnGLError("Error in setupQuad"); }
From source file:Data.Building.java
License:Apache License
@Override public void destroy() { // Disable the VBO index from the VAO attributes list GL20.glDisableVertexAttribArray(0);/*from ww w. j av a 2 s . c om*/ // Delete the VBO GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glDeleteBuffers(vboId); // Delete the VAO GL30.glBindVertexArray(0); GL30.glDeleteVertexArrays(vaoId); }
From source file:dataAccess.lwjgl.VAO_Loader.java
/** * Stores data in an attribute list of a VAO. * * @param vaoID The id of the VAO to which data will be added. * @param attributeNumber The number of the attribute list in which the data * will be stored./*w w w . j a v a2 s. co m*/ * @param data The data that will be stored in the attribute list. */ private static void storeDataInAttributeList(int vaoID, int attributeNumber, int coordinateSize, float[] data) { // bind VAO so that it can be used. bindVAO(vaoID); // Create new VBO. int vboID = GL15.glGenBuffers(); // Adds VBO to list so that it can be cleared when needed. vbos.add(vboID); // VBO has to be bound aswel. bindArrayBuffer(vboID); // Converts float array to an instance of FloatBuffer, which can // be stored in a VBO. FloatBuffer buffer = Convert.toReadableFloatBuffer(data); // Puts the buffer into the VBO, and GL_STATIC_DRAW tells it that it // won't ever be modified. GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW); // Specifies that this is for the Vertex Array. GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0); // Unbind the VBO. unbindArrayBuffer(); // unbind VAO so that another may be bound. unbindVAO(); }
From source file:dataAccess.lwjgl.VAO_Loader.java
/** * Binds the VBO, so that it can be modified. * * @param vboID The ID of the VBO that will be bound. *///from w w w . j av a 2 s .c o m private static void bindArrayBuffer(int vboID) { GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID); }
From source file:dataAccess.lwjgl.VAO_Loader.java
/** * Unbinds the VBO. */ private static void unbindArrayBuffer() { GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }