List of usage examples for org.lwjgl.opengl GL20 glVertexAttribPointer
public static void glVertexAttribPointer(@NativeType("GLuint") int index, @NativeType("GLint") int size, @NativeType("GLenum") int type, @NativeType("GLboolean") boolean normalized, @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer)
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20VertexArray.java
License:MIT License
@Override public void setData(VertexData vertexData) { checkCreated();//from www.ja v a 2 s .c om // Generate a new indices buffer if we don't have one yet if (indicesBufferID == 0) { indicesBufferID = GL15.glGenBuffers(); } // Bind the indices buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferID); // Get the new count of indices final int newIndicesCount = vertexData.getIndicesCount(); // If the new count is greater than or 50% smaller than the old one, we'll reallocate the memory // In the first case because we need more space, in the other to save space if (newIndicesCount > indicesCount || newIndicesCount <= indicesCount * 0.5) { GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, vertexData.getIndicesBuffer(), GL15.GL_STATIC_DRAW); } else { // Else, we replace the data with the new one, but we don't resize, so some old data might be left trailing in the buffer GL15.glBufferSubData(GL15.GL_ELEMENT_ARRAY_BUFFER, 0, vertexData.getIndicesBuffer()); } // Unbind the indices buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); // Update the total indices count indicesCount = newIndicesCount; // Ensure the count fits under the total one indicesDrawCount = indicesDrawCount <= 0 ? indicesCount : Math.min(indicesDrawCount, indicesCount); // Ensure that the indices offset and count fits inside the valid part of the buffer indicesOffset = Math.min(indicesOffset, indicesDrawCount - 1); indicesDrawCount -= indicesOffset; // Bind the vao if (extension.has()) { extension.glBindVertexArray(id); } // Create a new array of attribute buffers ID of the correct size final int attributeCount = vertexData.getAttributeCount(); final int[] newAttributeBufferIDs = new int[attributeCount]; // Copy all the old buffer IDs that will fit in the new array so we can reuse them System.arraycopy(attributeBufferIDs, 0, newAttributeBufferIDs, 0, Math.min(attributeBufferIDs.length, newAttributeBufferIDs.length)); // Delete any buffers that we don't need (new array is smaller than the previous one) for (int i = newAttributeBufferIDs.length; i < attributeBufferIDs.length; i++) { GL15.glDeleteBuffers(attributeBufferIDs[i]); } // Create new buffers if necessary (new array is larger than the previous one) for (int i = attributeBufferIDs.length; i < newAttributeBufferIDs.length; i++) { newAttributeBufferIDs[i] = GL15.glGenBuffers(); } // Copy the old valid attribute buffer sizes final int[] newAttributeBufferSizes = new int[attributeCount]; System.arraycopy(attributeBufferSizes, 0, newAttributeBufferSizes, 0, Math.min(attributeBufferSizes.length, newAttributeBufferSizes.length)); // If we don't have a vao, we have to save the properties manually if (!extension.has()) { attributeSizes = new int[attributeCount]; attributeTypes = new int[attributeCount]; attributeNormalizing = new boolean[attributeCount]; } // Upload the new vertex data for (int i = 0; i < attributeCount; i++) { final VertexAttribute attribute = vertexData.getAttribute(i); final ByteBuffer attributeData = attribute.getData(); // Get the current buffer size final int bufferSize = newAttributeBufferSizes[i]; // Get the new buffer size final int newBufferSize = attributeData.remaining(); // Bind the target buffer GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, newAttributeBufferIDs[i]); // If the new count is greater than or 50% smaller than the old one, we'll reallocate the memory if (newBufferSize > bufferSize || newBufferSize <= bufferSize * 0.5) { GL15.glBufferData(GL15.GL_ARRAY_BUFFER, attributeData, GL15.GL_STATIC_DRAW); } else { // Else, we replace the data with the new one, but we don't resize, so some old data might be left trailing in the buffer GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, attributeData); } // Update the buffer size to the new one newAttributeBufferSizes[i] = newBufferSize; // Next, we add the pointer to the data in the vao if (extension.has()) { // As a float, normalized or not GL20.glVertexAttribPointer(i, attribute.getSize(), attribute.getType().getGLConstant(), attribute.getUploadMode().normalize(), 0, 0); // Enable the attribute GL20.glEnableVertexAttribArray(i); } else { // Else we save the properties for rendering attributeSizes[i] = attribute.getSize(); attributeTypes[i] = attribute.getType().getGLConstant(); attributeNormalizing[i] = attribute.getUploadMode().normalize(); } } // Unbind the last vbo GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // Unbind the vao if (extension.has()) { extension.glBindVertexArray(0); } // Update the attribute buffer IDs to the new ones attributeBufferIDs = newAttributeBufferIDs; // Update the attribute buffer sizes to the new ones attributeBufferSizes = newAttributeBufferSizes; // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20VertexArray.java
License:MIT License
@Override public void draw() { checkCreated();/* w w w . j a v a 2s.co m*/ if (extension.has()) { // Bind the vao extension.glBindVertexArray(id); } else { // Enable the vertex attributes for (int i = 0; i < attributeBufferIDs.length; i++) { // Bind the buffer GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, attributeBufferIDs[i]); // Define the attribute GL20.glVertexAttribPointer(i, attributeSizes[i], attributeTypes[i], attributeNormalizing[i], 0, 0); // Enable it GL20.glEnableVertexAttribArray(i); } // Unbind the last buffer GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); } // Bind the index buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferID); // Set the polygon mode GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, polygonMode.getGLConstant()); // Draw all indices with the provided mode GL11.glDrawElements(drawingMode.getGLConstant(), indicesDrawCount, GL11.GL_UNSIGNED_INT, indicesOffset * DataType.INT.getByteSize()); // Unbind the indices buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.flowpowered.caustic.lwjgl.gl30.GL30VertexArray.java
License:MIT License
@Override public void setData(VertexData vertexData) { checkCreated();//from w ww. j av a 2s. co m // Generate a new indices buffer if we don't have one yet if (indicesBufferID == 0) { indicesBufferID = GL15.glGenBuffers(); } // Bind the indices buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferID); // Get the new count of indices final int newIndicesCount = vertexData.getIndicesCount(); // If the new count is greater than or 50% smaller than the old one, we'll reallocate the memory // In the first case because we need more space, in the other to save space if (newIndicesCount > indicesCount || newIndicesCount <= indicesCount * 0.5) { GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, vertexData.getIndicesBuffer(), GL15.GL_STATIC_DRAW); } else { // Else, we replace the data with the new one, but we don't resize, so some old data might be left trailing in the buffer GL15.glBufferSubData(GL15.GL_ELEMENT_ARRAY_BUFFER, 0, vertexData.getIndicesBuffer()); } // Unbind the indices buffer GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); // Update the total indices count indicesCount = newIndicesCount; // Ensure the count fits under the total one indicesDrawCount = indicesDrawCount <= 0 ? indicesCount : Math.min(indicesDrawCount, indicesCount); // Ensure that the indices offset and count fits inside the valid part of the buffer indicesOffset = Math.min(indicesOffset, indicesDrawCount - 1); indicesDrawCount -= indicesOffset; // Bind the vao GL30.glBindVertexArray(id); // Create a new array of attribute buffers ID of the correct size final int attributeCount = vertexData.getAttributeCount(); final int[] newAttributeBufferIDs = new int[attributeCount]; // Copy all the old buffer IDs that will fit in the new array so we can reuse them System.arraycopy(attributeBufferIDs, 0, newAttributeBufferIDs, 0, Math.min(attributeBufferIDs.length, newAttributeBufferIDs.length)); // Delete any buffers that we don't need (new array is smaller than the previous one) for (int i = newAttributeBufferIDs.length; i < attributeBufferIDs.length; i++) { GL15.glDeleteBuffers(attributeBufferIDs[i]); } // Create new buffers if necessary (new array is larger than the previous one) for (int i = attributeBufferIDs.length; i < newAttributeBufferIDs.length; i++) { newAttributeBufferIDs[i] = GL15.glGenBuffers(); } // Copy the old valid attribute buffer sizes final int[] newAttributeBufferSizes = new int[attributeCount]; System.arraycopy(attributeBufferSizes, 0, newAttributeBufferSizes, 0, Math.min(attributeBufferSizes.length, newAttributeBufferSizes.length)); // Upload the new vertex data for (int i = 0; i < attributeCount; i++) { final VertexAttribute attribute = vertexData.getAttribute(i); final ByteBuffer attributeData = attribute.getData(); // Get the current buffer size final int bufferSize = newAttributeBufferSizes[i]; // Get the new buffer size final int newBufferSize = attributeData.remaining(); // Bind the target buffer GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, newAttributeBufferIDs[i]); // If the new count is greater than or 50% smaller than the old one, we'll reallocate the memory if (newBufferSize > bufferSize || newBufferSize <= bufferSize * 0.5) { GL15.glBufferData(GL15.GL_ARRAY_BUFFER, attributeData, GL15.GL_STATIC_DRAW); } else { // Else, we replace the data with the new one, but we don't resize, so some old data might be left trailing in the buffer GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, attributeData); } // Update the buffer size to the new one newAttributeBufferSizes[i] = newBufferSize; // Next, we add the pointer to the data in the vao // We have three ways to interpret integer data if (attribute.getType().isInteger() && attribute.getUploadMode() == UploadMode.KEEP_INT) { // Directly as an int GL30.glVertexAttribIPointer(i, attribute.getSize(), attribute.getType().getGLConstant(), 0, 0); } else { // Or as a float, normalized or not GL20.glVertexAttribPointer(i, attribute.getSize(), attribute.getType().getGLConstant(), attribute.getUploadMode().normalize(), 0, 0); } // Finally enable the attribute GL20.glEnableVertexAttribArray(i); } // Unbind the last vbo GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // Unbind the vao GL30.glBindVertexArray(0); // Update the attribute buffer IDs to the new ones attributeBufferIDs = newAttributeBufferIDs; // Update the attribute buffer sizes to the new ones attributeBufferSizes = newAttributeBufferSizes; // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.geekyaubergine.geekyjgameutil.model.ModelLoader.java
License:Open Source License
/** * Stores data in attribute list/*from w w w . ja va 2 s . c o m*/ * @param attributeNumber Index in the attribute list to store data * @param data Data to store in attribute * @param dataSize Size of the data being stored */ private static void storeDataInAttributeList(int attributeNumber, float[] data, int dataSize) { Validate.isTrue(attributeNumber >= 0, "Attribute index must be a positive number"); Validate.isTrue(dataSize >= 0, "Data size must be a positive number"); int vboID = GL15.glGenBuffers(); vbos.add(vboID); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID); FloatBuffer buffer = storeDataInFloatBuffer(data); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(attributeNumber, dataSize, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:com.github.kajdreef.mazerunnermvn.Object.GameObject.java
protected void createVBO() { FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length * Vertex.elementCount); for (int i = 0; i < vertices.length; i++) { verticesBuffer.put(vertices[i].getElements()); }/*from w w w. j a v a 2 s.co m*/ verticesBuffer.flip(); // Create the indices buffer and place the data in it. ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(indicesData.length); indicesBuffer.put(indicesData); indicesBuffer.flip(); // Initialize the VAO vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId); // Initialize the VBO vboVerticesId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboVerticesId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW); // Put the positions in attribute list 0 GL20.glVertexAttribPointer(0, Vertex.positionElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.positionByteOffset); // Put the color components in attribute list 1 GL20.glVertexAttribPointer(1, Vertex.colorElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.colorByteOffset); // Put the texture coordinates in attribute list 2 GL20.glVertexAttribPointer(2, Vertex.textureElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.textureByteOffset); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); // Deselect the VAO GL30.glBindVertexArray(0); // Create a VBO for the indices. vboIndicesId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboIndicesId); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); }
From source file:com.grillecube.client.opengl.GLVertexArray.java
/** set VertexArray attribute depending on bounded VertexBuffer */ public void setAttribute(int index, int size, int type, boolean normalized, int stride, long pointer) { GL20.glVertexAttribPointer(index, size, type, normalized, stride, pointer); }
From source file:com.grillecube.engine.opengl.object.GLVertexArray.java
/** set VertexArray attribute depending on bounded VertexBuffer */ public void setAttribute(int attributeID, int length, int type, boolean normalized, int stride, int offset) { GL20.glVertexAttribPointer(attributeID, length, type, normalized, stride, offset); }
From source file:com.opengrave.og.base.Renderable2D.java
License:Open Source License
@Override public void dealWithChange() { Util.checkErr();/*ww w . j ava 2 s . com*/ if (vaoID == 0) { vaoID = GL30.glGenVertexArrays(); } GL30.glBindVertexArray(vaoID); Util.checkErr(); if (vbopID == 0) { vbopID = GL15.glGenBuffers(); } Util.checkErr(); if (vbocID == 0) { vbocID = GL15.glGenBuffers(); } Util.checkErr(); if (vbotID == 0) { vbotID = GL15.glGenBuffers(); } Util.checkErr(); if (changed) { changed = false; vertexList.clear(); posBuffer.clear(); colBuffer.clear(); texBuffer.clear(); recreate(); Util.checkErr(); int verts = vertexList.size(); if (vertexList.size() == 0) { return; } if (posBuffer.capacity() != verts * 2) { posBuffer = BufferUtils.createFloatBuffer(verts * 2); } Util.checkErr(); if (colBuffer.capacity() != verts * 4) { colBuffer = BufferUtils.createFloatBuffer(verts * 4); } if (texBuffer.capacity() != verts * 3) { texBuffer = BufferUtils.createFloatBuffer(verts * 3); } for (Vertex2D v2 : vertexList) { posBuffer.put(v2.x).put(v2.y); texBuffer.put(v2.tx).put(v2.ty).put(v2.tz); colBuffer.put(v2.r).put(v2.g).put(v2.b).put(v2.a); } posBuffer.flip(); texBuffer.flip(); colBuffer.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbopID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, posBuffer, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(0, 2, GL11.GL_FLOAT, false, 0, 0); Util.checkErr(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbocID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, colBuffer, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(1, 4, GL11.GL_FLOAT, false, 0, 0); Util.checkErr(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbotID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, texBuffer, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 0, 0); Util.checkErr(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); } }
From source file:com.opengrave.og.base.Renderable3D.java
License:Open Source License
@Override public void dealWithChange() { if (vao_ID == 0) { vao_ID = GL30.glGenVertexArrays(); changed = true;//from w w w . j a v a 2s .c o m } // set VAO object GL30.glBindVertexArray(vao_ID); if (vbo_index_ID == 0) { vbo_index_ID = GL15.glGenBuffers(); } if (vbo_pos_ID == 0) { vbo_pos_ID = GL15.glGenBuffers(); } if (vbo_norm_ID == 0) { vbo_norm_ID = GL15.glGenBuffers(); } if (vbo_tex_ID == 0) { vbo_tex_ID = GL15.glGenBuffers(); } if (changed) { recreate(); changed = false; indexCount = vertexList.size(); IntBuffer indexList = BufferUtils.createIntBuffer(indexCount); ArrayList<Vertex3D> verts = new ArrayList<Vertex3D>(); for (Vertex3D thisVert : vertexList) { // Vertex3D thisVert = vertexList.get(i); int index = -1; if (verts.indexOf(thisVert) == -1) { verts.add(thisVert); } index = verts.indexOf(thisVert); indexList.put(index); } int vertCount = verts.size(); indexList.flip(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vbo_index_ID); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indexList, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); FloatBuffer pos = BufferUtils.createFloatBuffer(vertCount * 3); FloatBuffer norm = BufferUtils.createFloatBuffer(vertCount * 3); FloatBuffer tex = BufferUtils.createFloatBuffer(vertCount * 3); box.clear(); for (int i = 0; i < verts.size(); i++) { Vertex3D v1 = verts.get(i); box.addVector3f(v1.getPos()); pos.put(v1.x).put(v1.y).put(v1.z); norm.put(v1.nx).put(v1.ny).put(v1.nz); tex.put(v1.tx).put(v1.ty).put(v1.tz); } // Set Vertex data pos.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_pos_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, pos, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); // Set Norm data norm.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_norm_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, norm, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(1, 3, GL11.GL_FLOAT, false, 0, 0); // Set Texture Co-ord data tex.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_tex_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, tex, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 0, 0); // Unset VBO object GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); } // Unset VAO object GL30.glBindVertexArray(0); }
From source file:com.opengrave.og.base.RenderableBoneAnimated.java
License:Open Source License
@Override public void dealWithChange() { if (vao_ID == 0) { vao_ID = GL30.glGenVertexArrays(); }/*from www . j a v a 2 s.com*/ GL30.glBindVertexArray(vao_ID); if (vbo_index_ID == 0) { vbo_index_ID = GL15.glGenBuffers(); } if (vbo_pos_ID == 0) { vbo_pos_ID = GL15.glGenBuffers(); } if (vbo_norm_ID == 0) { vbo_norm_ID = GL15.glGenBuffers(); } if (vbo_tex_ID == 0) { vbo_tex_ID = GL15.glGenBuffers(); } if (vbo_weight_ID == 0) { vbo_weight_ID = GL15.glGenBuffers(); } if (vbo_bone_ID == 0) { vbo_bone_ID = GL15.glGenBuffers(); } if (changed) { // vertexList.clear(); recreate(); changed = false; indexCount = vertexList.size(); IntBuffer indexList = BufferUtils.createIntBuffer(indexCount); ArrayList<VertexAnimated> verts = new ArrayList<VertexAnimated>(); for (VertexAnimated thisVert : vertexList) { int index = -1; if (verts.indexOf(thisVert) == -1) { verts.add(thisVert); } index = verts.indexOf(thisVert); indexList.put(index); } int vertCount = verts.size(); indexList.flip(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vbo_index_ID); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indexList, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); FloatBuffer pos = BufferUtils.createFloatBuffer(vertCount * 3); FloatBuffer norm = BufferUtils.createFloatBuffer(vertCount * 3); FloatBuffer tex = BufferUtils.createFloatBuffer(vertCount * 3); FloatBuffer bone = BufferUtils.createFloatBuffer(vertCount * 4); FloatBuffer weight = BufferUtils.createFloatBuffer(vertCount * 4); // box.clear(); for (int i = 0; i < verts.size(); i++) { VertexAnimated v1 = verts.get(i); // box.addVector3f(v1.getPos()); pos.put(v1.x).put(v1.y).put(v1.z); norm.put(v1.nx).put(v1.ny).put(v1.nz); tex.put(v1.tx).put(v1.ty).put(v1.tz); bone.put(v1.influence.getBoneId(0)).put(v1.influence.getBoneId(1)).put(v1.influence.getBoneId(2)) .put(v1.influence.getBoneId(3)); weight.put(v1.influence.getWeight(0)).put(v1.influence.getWeight(1)).put(v1.influence.getWeight(2)) .put(v1.influence.getWeight(3)); } pos.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_pos_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, pos, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); norm.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_norm_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, norm, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(1, 3, GL11.GL_FLOAT, true, 0, 0); tex.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_tex_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, tex, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 0, 0); bone.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_bone_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, bone, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(3, 4, GL11.GL_FLOAT, false, 0, 0); weight.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_weight_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, weight, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(4, 4, GL11.GL_FLOAT, false, 0, 0); /* * changed = false; * * vertCount = vertexList.size(); FloatBuffer pos = * BufferUtils.createFloatBuffer(vertCount * 3); FloatBuffer norm = * BufferUtils.createFloatBuffer(vertCount * 3); FloatBuffer tex = * BufferUtils.createFloatBuffer(vertCount * 3); FloatBuffer bone = * BufferUtils.createFloatBuffer(vertCount * 4); FloatBuffer weight * = BufferUtils.createFloatBuffer(vertCount * 4); for * (VertexAnimated va : vertexList) { * pos.put(va.x).put(va.y).put(va.z); * norm.put(va.nx).put(va.ny).put(va.nz); * tex.put(va.tx).put(va.ty).put(va.tz); * bone.put(va.influence.getBoneId(0)) * .put(va.influence.getBoneId(1)) .put(va.influence.getBoneId(2)) * .put(va.influence.getBoneId(3)); * weight.put(va.influence.getWeight(0)) * .put(va.influence.getWeight(1)) .put(va.influence.getWeight(2)) * .put(va.influence.getWeight(3)); } * * pos.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_pos_ID); * GL15.glBufferData(GL15.GL_ARRAY_BUFFER, pos, * GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, * GL11.GL_FLOAT, false, 0, 0); * * norm.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, * vbo_norm_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, norm, * GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(1, 3, * GL11.GL_FLOAT, false, 0, 0); * * tex.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_tex_ID); * GL15.glBufferData(GL15.GL_ARRAY_BUFFER, tex, * GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(2, 3, * GL11.GL_FLOAT, false, 0, 0); * * bone.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, * vbo_bone_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, bone, * GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(3, 4, * GL11.GL_FLOAT, false, 0, 0); * * weight.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, * vbo_weight_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, weight, * GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(4, 4, * GL11.GL_FLOAT, false, 0, 0); */ GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); } GL30.glBindVertexArray(0); }