List of usage examples for org.lwjgl.opengl GL30 glGenVertexArrays
@NativeType("void") public static int glGenVertexArrays()
From source file:com.redthirddivision.quad.rendering.models.Model.java
License:Apache License
private int createVAO() { int vaoID = GL30.glGenVertexArrays(); ResourceManager.addVAO(vaoID); GL30.glBindVertexArray(vaoID); return vaoID; }
From source file:com.rfdickerson.openworld.CubeGeometry.java
@Override void init() {/* ww w . j av a 2s .c om*/ float[] vertices = { -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f }; byte[] indices = { 0, 1, 2, 0, 2, 3, 0, 3, 4, 4, 3, 5, 0, 4, 6, 0, 6, 1 }; indicesCount = indices.length; ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(indicesCount); indicesBuffer.put(indices); indicesBuffer.flip(); FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length); verticesBuffer.put(vertices); verticesBuffer.flip(); //vertexCount = 6; 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); 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.isLoaded = true; exitOnGLError("init terrain patch"); }
From source file:com.rfdickerson.openworld.RenderSurface.java
@Override void init() {/* ww w.ja v a 2s . co m*/ float[] vertices = { -0.5f, 0f, -0.5f, -0.5f, 0f, 0.5f, 0.5f, 0f, 0.5f, 0.5f, 0f, -0.5f }; byte[] indices = { 0, 1, 3, 1, 2, 3 }; indicesCount = indices.length; ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(indicesCount); indicesBuffer.put(indices); indicesBuffer.flip(); FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length); verticesBuffer.put(vertices); verticesBuffer.flip(); //vertexCount = 6; 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); 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.isLoaded = true; exitOnGLError("init terrain patch"); }
From source file:com.samrj.devil.gl.VAO.java
private VAO(Pair<VertexData, ShaderProgram> pair) { DGL.checkState();//from w w w . j a v a 2 s. c o m if (!DGL.getCapabilities().OpenGL30) throw new UnsupportedOperationException("Vertex arrays unsupported in OpenGL < 3.0"); id = GL30.glGenVertexArrays(); this.pair = pair; bind(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, pair.a.vbo()); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, pair.a.ibo()); for (ShaderProgram.Attribute satt : pair.b.getAttributes()) { VertexData.Attribute att = pair.a.getAttribute(satt.name); if (att != null) { AttributeType type = att.getType(); for (int layer = 0; layer < type.layers; layer++) { int location = satt.location + layer; GL20.glEnableVertexAttribArray(location); vertexAttribPointer(location, type, att.getStride(), att.getOffset() + layer * type.size); } } } }
From source file:com.voxelplugineering.voxelsniper.render.buffer.BufferManager.java
License:Open Source License
public void setup() { vaoId = GL30.glGenVertexArrays(); setup = true;/*from w w w. j av a 2 s . c o m*/ for (BufferSection b : this.sections) { b.create(vaoId); } OpenGLUtilities.checkGLError("setupQuad"); }
From source file:com.xrbpowered.gl.res.shaders.FeedbackVertices.java
License:Open Source License
public FeedbackVertices(Shader transformShader, Shader renderShader, int count, boolean createIndices) { this.transformShader = transformShader; this.renderShader = renderShader; this.countElements = count; vertexBuffer = BufferUtils.createByteBuffer(count * transformShader.info.getStride()).asFloatBuffer(); feedbackBuffer = BufferUtils.createByteBuffer(count * renderShader.info.getStride()).asFloatBuffer(); vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId);/*from w w w . j ava2 s .com*/ vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, count * transformShader.info.getStride(), GL15.GL_DYNAMIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); vboFeedbackId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboFeedbackId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, count * renderShader.info.getStride(), GL15.GL_DYNAMIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); if (createIndices) { indexBuffer = BufferUtils.createByteBuffer(count * 4).asIntBuffer(); vboiId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, count * 4, GL15.GL_DYNAMIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); } Client.checkError(); }
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(); GL30.glBindVertexArray(vaoId);/*from w w w. j a v a 2 s. c o m*/ 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: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(); GL30.glBindVertexArray(vaoId);/*from w ww . jav a2 s .c o m*/ 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);//from w w w.jav a 2s . 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:dataAccess.lwjgl.VAO_Loader.java
/** * Creates a new VAO.//w w w. j ava 2s . com * * @return Its ID that points to the VAO in memory. */ private static int createVAO() { int vaoID = GL30.glGenVertexArrays(); // Adds VAO to list so that it can be cleared when needed. vaos.add(vaoID); return vaoID; }