List of usage examples for org.lwjgl.opengl GL30 glGenVertexArrays
@NativeType("void") public static int glGenVertexArrays()
From source file:de.ikosa.mars.viewer.glviewer.engine.GLMeshBuilder.java
License:Open Source License
protected GLMesh createMesh(GLResources resourceManager, boolean fetchMaterial) { // create VBO buffers FloatBuffer interleavedBuffer = BufferUtils.createFloatBuffer(vertices.size() * 8); int stride = 12 + (hasNormals ? 12 : 0) + (hasTexCoords ? 8 : 0); int normalPosition = 12; int texCoordPosition = 12 + (hasNormals ? 12 : 0); // fill buffers for (GLVertex vertex : vertices) { interleavedBuffer.put(vertex.px); interleavedBuffer.put(vertex.py); interleavedBuffer.put(vertex.pz); if (hasNormals) { interleavedBuffer.put(vertex.nx); interleavedBuffer.put(vertex.ny); interleavedBuffer.put(vertex.nz); }/*from w ww . j a va2 s . c o m*/ if (hasTexCoords) { interleavedBuffer.put(vertex.tu); interleavedBuffer.put(vertex.tv); } } interleavedBuffer.flip(); // create VAO int vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId); // create VBOs int interleavedVboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, interleavedVboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, interleavedBuffer, GL15.GL_STATIC_DRAW); // position should always be there GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, stride, 0); if (hasNormals) GL20.glVertexAttribPointer(1, 3, GL11.GL_FLOAT, false, stride, normalPosition); if (hasTexCoords) GL20.glVertexAttribPointer(2, 2, GL11.GL_FLOAT, false, stride, texCoordPosition); // unbind buffers GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); // create mesh object GLMesh mesh = createInstance(vaoId, interleavedVboId); // create submeshes for material groups for (String material : indices.keySet()) { GLMaterial glMaterial = fetchMaterial ? resourceManager.getMaterial(material) : GLMaterial.nullMaterial; // create index buffer List<GLIndex> indicesForMaterial = indices.get(material); IntBuffer indexBuffer = BufferUtils.createIntBuffer(indicesForMaterial.size()); for (GLIndex index : indicesForMaterial) { indexBuffer.put(index.index); } indexBuffer.flip(); int indexVboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexVboId); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer, GL15.GL_STATIC_DRAW); GLSubMesh subMesh = new GLSubMesh(indexVboId, indicesForMaterial.size(), glMaterial, mesh); mesh.addSubMesh(subMesh); } GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); return mesh; }
From source file:de.ikosa.mars.viewer.glviewer.GLHeightMapMeshBuilder.java
License:Open Source License
public GLHeightMapMesh createMesh() { ML.d(String.format("Writing mesh \"%s\" to buffer...", name)); // create VBO buffers FloatBuffer interleavedBuffer = BufferUtils.createFloatBuffer(matrixSizeX * matrixSizeY * 9); int stride = 12 + 12 + 12; int normalPosition = 12; int texCoordPosition = 24; // fill buffers for (int y = 0; y < matrixSizeY; y++) { for (int x = 0; x < matrixSizeX; x++) { GLWorldVertex vertex = vMatrix[x][y]; interleavedBuffer.put(vertex.px); interleavedBuffer.put(vertex.py); interleavedBuffer.put(vertex.pz); interleavedBuffer.put(vertex.nx); interleavedBuffer.put(vertex.ny); interleavedBuffer.put(vertex.nz); interleavedBuffer.put(vertex.tu); interleavedBuffer.put(vertex.tv); interleavedBuffer.put(vertex.tw); }/*from w ww . j a v a2 s . c o m*/ } interleavedBuffer.flip(); ML.d("Done."); // create VAO int vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId); // create VBOs int interleavedVboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, interleavedVboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, interleavedBuffer, GL15.GL_STATIC_DRAW); // attribs GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, stride, 0); GL20.glVertexAttribPointer(1, 3, GL11.GL_FLOAT, false, stride, normalPosition); GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, stride, texCoordPosition); // unbind buffers GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); // create index buffer iBuffer.flip(); int indexVboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexVboId); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, iBuffer, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GLTextureArray terrainTexture = (GLTextureArray) GLResources.global.getTexture("terrain"); // create mesh object GLHeightMapMesh mesh = new GLHeightMapMesh(name, vaoId, interleavedVboId, indexVboId, indices, terrainTexture); return mesh; }
From source file:engine.render.TexturedQuad.java
private void setupQuad(Vector2f size) { TexturedVertex v0 = new TexturedVertex(); v0.setXYZ(-0.5f * size.x, 0.5f * size.y, 0); v0.setRGB(1, 0, 0);// www . j a va2s . c om v0.setST(0, 0); TexturedVertex v1 = new TexturedVertex(); v1.setXYZ(-0.5f * size.x, -0.5f * size.x, 0); v1.setRGB(0, 1, 0); v1.setST(0, 1); TexturedVertex v2 = new TexturedVertex(); v2.setXYZ(0.5f * size.y, -0.5f * size.x, 0); v2.setRGB(0, 0, 1); v2.setST(1, 1); TexturedVertex v3 = new TexturedVertex(); v3.setXYZ(0.5f * size.x, 0.5f * size.y, 0); v3.setRGB(1, 1, 1); v3.setST(1, 0); TexturedVertex[] vertices = new TexturedVertex[] { v0, v1, v2, v3 }; FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length * TexturedVertex.elementCount); for (int i = 0; i < vertices.length; i++) { verticesBuffer.put(vertices[i].getElements()); } verticesBuffer.flip(); byte[] indices = { 0, 1, 2, 2, 3, 0 }; indicesCount = indices.length; ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(indicesCount); indicesBuffer.put(indices); indicesBuffer.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, TexturedVertex.positionElementCount, GL11.GL_FLOAT, false, TexturedVertex.stride, TexturedVertex.positionByteOffset); GL20.glVertexAttribPointer(1, TexturedVertex.colorElementCount, GL11.GL_FLOAT, false, TexturedVertex.stride, TexturedVertex.colorByteOffset); GL20.glVertexAttribPointer(2, TexturedVertex.textureElementCount, GL11.GL_FLOAT, false, TexturedVertex.stride, TexturedVertex.textureByteOffset); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); 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); //this.exitOnGLError("setupQuad"); }
From source file:eu.over9000.veya.rendering.ChunkVAO.java
License:Open Source License
public void create() { // create objects if (holdsSolid) { this.ibo_handle_solid = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_handle_solid); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_buffer_solid, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); this.vbo_handle_solid = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo_handle_solid); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, this.vbo_buffer_solid, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); this.vao_handle_solid = GL30.glGenVertexArrays(); GL30.glBindVertexArray(this.vao_handle_solid); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo_handle_solid); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, Vertex.positionElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.positionByteOffset); GL20.glEnableVertexAttribArray(1); GL20.glVertexAttribPointer(1, Vertex.colorElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.colorByteCount);/*from w w w . jav a 2 s . co m*/ GL20.glEnableVertexAttribArray(2); GL20.glVertexAttribPointer(2, Vertex.textureElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.textureByteOffset); GL20.glEnableVertexAttribArray(3); GL20.glVertexAttribPointer(3, Vertex.normalElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.normalByteOffset); GL20.glEnableVertexAttribArray(4); GL20.glVertexAttribPointer(4, Vertex.aoElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.aoByteOffset); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_handle_solid); GL30.glBindVertexArray(0); } if (holdsTransparent) { this.ibo_handle_transparent = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_handle_transparent); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_buffer_transparent, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); this.vbo_handle_transparent = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo_handle_transparent); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, this.vbo_buffer_transparent, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); this.vao_handle_transparent = GL30.glGenVertexArrays(); GL30.glBindVertexArray(this.vao_handle_transparent); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo_handle_transparent); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, Vertex.positionElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.positionByteOffset); GL20.glEnableVertexAttribArray(1); GL20.glVertexAttribPointer(1, Vertex.colorElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.colorByteOffset); GL20.glEnableVertexAttribArray(2); GL20.glVertexAttribPointer(2, Vertex.textureElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.textureByteOffset); GL20.glEnableVertexAttribArray(3); GL20.glVertexAttribPointer(3, Vertex.normalElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.normalByteOffset); GL20.glEnableVertexAttribArray(4); GL20.glVertexAttribPointer(4, Vertex.aoElementCount, GL11.GL_FLOAT, false, Vertex.stride, Vertex.aoByteOffset); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo_handle_transparent); GL30.glBindVertexArray(0); } // System.out.println("created ChunkVAO with " + this.vertexData.length + " vertices"); }
From source file:eu.over9000.veya.rendering.Shadow.java
License:Open Source License
public void renderQuad() { if (quadVAO == 0) { final float[] quadVertices = { // Positions // Texture Coords -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, }; // Setup plane VAO final FloatBuffer fb = BufferUtils.createFloatBuffer(quadVertices.length); fb.put(quadVertices);/*from w ww . j a va2 s. c o m*/ fb.flip(); quadVAO = GL30.glGenVertexArrays(); quadVBO = GL15.glGenBuffers(); GL30.glBindVertexArray(quadVAO); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, quadVBO); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, fb, GL15.GL_STATIC_DRAW); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 5 * Float.BYTES, 0); GL20.glEnableVertexAttribArray(1); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 5 * Float.BYTES, 3 * Float.BYTES); } GL30.glBindVertexArray(quadVAO); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4); GL30.glBindVertexArray(0); }
From source file:fr.guillaume.prive.viper.core.graphic.GraphicMotor.java
private static void setupObjModels() { ObjModel spaceShipModel = ObjLoader.loadModel(new File("resources/model/fighter.obj")); FloatBuffer verticesBuffer = BufferUtils .createFloatBuffer(Vertex.ELEMENT_COUNT * spaceShipModel.getVertices().size()); spaceShipModel.getVertices().stream().forEach((v) -> verticesBuffer.put(v.getElements())); verticesBuffer.flip();// w w w . jav a 2s . com instance.shipVaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(instance.shipVaoId); instance.shipVboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, instance.shipVboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, Vertex.POSITION_ELEMENT_COUNT, GL11.GL_FLOAT, false, Vertex.STRIDE, 0); GL20.glVertexAttribPointer(1, Vertex.NORMAL_ELEMENT_COUNT, GL11.GL_FLOAT, false, Vertex.STRIDE, Vertex.NORMAL_BYTE_OFFSET); GL20.glVertexAttribPointer(2, Vertex.COLOR_ELEMENT_COUNT, GL11.GL_FLOAT, false, Vertex.STRIDE, Vertex.COLOR_BYTE_OFFSET); GL20.glVertexAttribPointer(3, Vertex.TEXTURE_ELEMENT_COUNT, GL11.GL_FLOAT, false, Vertex.STRIDE, Vertex.TEXTURE_BYTE_OFFSET); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); instance.shipVboiLenght = spaceShipModel.getIndices().length; IntBuffer indicesBuffer = BufferUtils.createIntBuffer(instance.shipVboiLenght); indicesBuffer.put(spaceShipModel.getIndices()); indicesBuffer.flip(); instance.shipVboiId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, instance.shipVboiId); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); }
From source file:fr.ign.cogit.geoxygene.appli.gl.GLBezierShadingComplex.java
License:Open Source License
/** * Bind Buffers with gl Context/*from w w w .j a v a 2s. c om*/ */ 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); // System.err // .println("loc = " + input.getLocation() + " " // + input.getComponentCount() + " " // + input.getGlType() + " stride = " // + this.getStride() + " shift = " + byteShift); byteShift += input.getComponentCount() * GLTools.sizeInBytes(input.getGlType()); glEnableVertexAttribArray(input.getLocation()); } glBufferData(GL_ARRAY_BUFFER, this.getFlippedVerticesBuffer(), GL_STATIC_DRAW); // 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); glBindVertexArray(0); }
From source file:fr.ign.cogit.geoxygene.appli.gl.GLPaintingComplex.java
License:Open Source License
/** * Bind Buffers with gl Context//from ww w . ja v a2 s .c o 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); // System.err.println("loc = " + input.getLocation() + " " // + input.getComponentCount() + " " + input.getGlType() // + " stride = " + this.getStride() + " shift = " + byteShift // + " name = " + input.getName() + " (" // + this.getClass().getSimpleName() + ")"); byteShift += input.getComponentCount() * GLTools.sizeInBytes(input.getGlType()); glEnableVertexAttribArray(input.getLocation()); } // System.err.println("previous"); // for (int nAttrib = 0; nAttrib < GLSimpleVertex.ATTRIBUTES_COUNT; // nAttrib++) // { // GL20.glVertexAttribPointer(GLSimpleVertex.ATTRIBUTES_ID[nAttrib], // GLSimpleVertex.ATTRIBUTES_COMPONENT_NUMBER[nAttrib], // GLSimpleVertex.ATTRIBUTES_TYPE[nAttrib], // false, GLSimpleVertex.VERTEX_BYTESIZE, // GLSimpleVertex.ATTRIBUTES_BYTEOFFSET[nAttrib]); // System.err.println("loc = " + GLSimpleVertex.ATTRIBUTES_ID[nAttrib] + // " " + // GLSimpleVertex.ATTRIBUTES_COMPONENT_NUMBER[nAttrib] + " " // + GLSimpleVertex.ATTRIBUTES_TYPE[nAttrib] + " stride = " + // GLSimpleVertex.VERTEX_BYTESIZE + " shift = " + // GLSimpleVertex.ATTRIBUTES_BYTEOFFSET[nAttrib]); // glEnableVertexAttribArray(GLSimpleVertex.ATTRIBUTES_ID[nAttrib]); // // } glBufferData(GL_ARRAY_BUFFER, this.getFlippedVerticesBuffer(), GL_STATIC_DRAW); // System.err // .println("Buffer la construction ********************************"); // GLTools.displayBuffer(this.getFlippedVerticesBuffer()); // System.err // .println("Buffer la construction ---------------------------------"); // 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:fr.ign.cogit.geoxygene.appli.gl.GLSimpleComplex.java
License:Open Source License
/** * Bind Buffers with gl Context/*w ww . j av a 2 s . c o 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); // 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); glBindVertexArray(0); }
From source file:fr.ign.cogit.geoxygene.appli.gl.GLTextComplex.java
License:Open Source License
/** * Bind Buffers with gl Context/*ww w . j a v a 2 s .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); // System.err.println("loc = " + input.getLocation() + " " // + input.getComponentCount() + " " + input.getGlType() // + " stride = " + this.getStride() + " shift = " + byteShift // + " name = " + input.getName() + " " // + this.getClass().getSimpleName()); byteShift += input.getComponentCount() * GLTools.sizeInBytes(input.getGlType()); glEnableVertexAttribArray(input.getLocation()); } // System.err.println("previous"); // for (int nAttrib = 0; nAttrib < GLSimpleVertex.ATTRIBUTES_COUNT; // nAttrib++) // { // GL20.glVertexAttribPointer(GLSimpleVertex.ATTRIBUTES_ID[nAttrib], // GLSimpleVertex.ATTRIBUTES_COMPONENT_NUMBER[nAttrib], // GLSimpleVertex.ATTRIBUTES_TYPE[nAttrib], // false, GLSimpleVertex.VERTEX_BYTESIZE, // GLSimpleVertex.ATTRIBUTES_BYTEOFFSET[nAttrib]); // System.err.println("loc = " + GLSimpleVertex.ATTRIBUTES_ID[nAttrib] + // " " + // GLSimpleVertex.ATTRIBUTES_COMPONENT_NUMBER[nAttrib] + " " // + GLSimpleVertex.ATTRIBUTES_TYPE[nAttrib] + " stride = " + // GLSimpleVertex.VERTEX_BYTESIZE + " shift = " + // GLSimpleVertex.ATTRIBUTES_BYTEOFFSET[nAttrib]); // glEnableVertexAttribArray(GLSimpleVertex.ATTRIBUTES_ID[nAttrib]); // // } 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); }