List of usage examples for org.lwjgl.opengl GL20 glEnableVertexAttribArray
public static void glEnableVertexAttribArray(@NativeType("GLuint") int index)
From source file:opengl.test.object.XO.java
/** * Method nay duoc tach rieng ra tu initVertex * Vi render nhieu doi tuong neu dung Multi vbo --> truoc khi draw phai bind lai vbo --> moi lan bind lai se phai set lai VertexAttribPointer */// w ww .ja va 2 s. c om @Override protected void VertexAttribPointer() { if (this.vbo == 0) throw new RuntimeException("Chua khoi tao VBO"); int positionID = GL20.glGetAttribLocation(programID, "position"); GL20.glEnableVertexAttribArray(positionID); GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 6 * 4, 0);// float size = 4 byte --> next is 3*4 byte // size = 3 --> position = x,y,z vec3 int colorID = GL20.glGetAttribLocation(programID, "color"); GL20.glEnableVertexAttribArray(colorID); GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 6 * 4, 3 * 4); // size = 3 --> vec3 }
From source file:opengl.test.object.XO.java
@Override public void render() { this.bind();// use porgrma --> ket thuc disable program GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo); this.VertexAttribPointer(); GL20.glEnableVertexAttribArray(0);// set index ve 0 GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max //GL11./*from w w w .jav a 2 s . c o m*/ GL20.glDisableVertexAttribArray(0);// disable GL30.glBindVertexArray(0);// unbind vao this.unbind();// dsiable program }
From source file:org.bonsaimind.badgersvoyage.opengl.RenderObject.java
License:Open Source License
public void render() { GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, verticesCount); }
From source file:org.jogamp.glg2d.impl.shader.AnyModePipeline.java
License:Apache License
public void bindBuffer() { GL20.glEnableVertexAttribArray(vertCoordLocation); vertCoordBuffer = ensureIsGLBuffer(vertCoordBuffer); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertCoordBuffer); GL20.glVertexAttribPointer(vertCoordLocation, 2, GL11.GL_FLOAT, false, 0, 0); }
From source file:org.jogamp.glg2d.impl.shader.GeometryShaderStrokePipeline.java
License:Apache License
protected void bindBuffer(FloatBuffer vertexBuffer) { GL20.glEnableVertexAttribArray(vertCoordLocation); GL20.glEnableVertexAttribArray(vertBeforeLocation); GL20.glEnableVertexAttribArray(vertAfterLocation); if (GL15.glIsBuffer(vertCoordBuffer)) { GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertCoordBuffer); GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, vertexBuffer); } else {//from w w w. j a v a 2 s . c o m vertCoordBuffer = GLG2DUtils.genBufferId(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertCoordBuffer); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuffer, GL15.GL_STREAM_DRAW); } GL20.glVertexAttribPointer(vertCoordLocation, 2, GL11.GL_FLOAT, false, 0, 2 * (Float.SIZE / Byte.SIZE)); GL20.glVertexAttribPointer(vertBeforeLocation, 2, GL11.GL_FLOAT, false, 0, 0); GL20.glVertexAttribPointer(vertAfterLocation, 2, GL11.GL_FLOAT, false, 0, 4 * (Float.SIZE / Byte.SIZE)); }
From source file:org.jogamp.glg2d.impl.shader.GL2ES2ImagePipeline.java
License:Apache License
protected void bufferData(FloatBuffer buffer) { vertexBufferId = ensureIsGLBuffer(vertexBufferId); GL20.glEnableVertexAttribArray(vertCoordLocation); GL20.glEnableVertexAttribArray(texCoordLocation); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBufferId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(vertCoordLocation, 2, GL11.GL_FLOAT, false, 4 * (Float.SIZE / Byte.SIZE), 0); GL20.glVertexAttribPointer(texCoordLocation, 2, GL11.GL_FLOAT, false, 4 * (Float.SIZE / Byte.SIZE), 2 * (Float.SIZE / Byte.SIZE)); }
From source file:org.meanworks.engine.render.geometry.mesh.renderers.VAOMeshRenderer.java
License:Open Source License
/** * Compiles this mesh and makes sure all attributes are set up correctly. *//*from ww w . j av a 2s . co m*/ public boolean compile() { // Preliminary check for (BufferEntry bufferEntry : vertexBuffers) { if (bufferEntry == null || bufferEntry.buffer == null || bufferEntry.bufferAttributes.size() == 0) { EngineLogger.error("Could not compile Mesh, invalid buffer entry."); return false; } } if (vertexBufferArray == null) { vertexBufferArray = new VertexBufferArray(); } vertexBufferArray.bind(); { for (BufferEntry bufferEntry : vertexBuffers) { bufferEntry.buffer.bind(); for (BufferAttribute bufferAttribute : bufferEntry.bufferAttributes) { GL20.glEnableVertexAttribArray(bufferAttribute.index); GL20.glVertexAttribPointer(bufferAttribute.index, bufferAttribute.size, bufferAttribute.type, bufferAttribute.normalized, bufferAttribute.stride, bufferAttribute.bufferOffset); } } if (indexBuffer != null) { indexBuffer.bind(); } } vertexBufferArray.unbind(); int error = GL11.glGetError(); if (error != 0) { EngineLogger.error("Could not compile Mesh, " + GLU.gluErrorString(error)); return false; } return true; }
From source file:org.spout.engine.renderer.GL20BatchVertexRenderer.java
License:Open Source License
/** * Draws this batch/*from w w w. ja v a 2 s.co m*/ */ @Override public void doRender(RenderMaterial material, int startVert, int endVert) { material.assign(); for (VertexBufferImpl vb : vertexBuffers.valueCollection()) { vb.bind(); GL20.glEnableVertexAttribArray(vb.getLayout()); GL20.glVertexAttribPointer(vb.getLayout(), vb.getElements(), GL11.GL_FLOAT, false, 0, 0); //activeMaterial.getShader().enableAttribute(vb.getName(), vb.getElements(), GL11.GL_FLOAT, 0, 0, vb.getLayout()); } GL11.glDrawArrays(renderMode, startVert, endVert); for (VertexBufferImpl vb : vertexBuffers.valueCollection()) { GL20.glDisableVertexAttribArray(vb.getLayout()); } }
From source file:org.spout.engine.renderer.GL30BatchVertexRenderer.java
License:Open Source License
/** * Draws this batch/*from w w w. ja va 2 s . co m*/ */ @Override public void doRender(RenderMaterial material, int startVert, int endVert) { GL30.glBindVertexArray(vao); material.assign(); for (VertexBufferImpl vb : vertexBuffers.valueCollection()) { vb.bind(); GL20.glEnableVertexAttribArray(vb.getLayout()); GL20.glVertexAttribPointer(vb.getLayout(), vb.getElements(), GL11.GL_FLOAT, false, 0, 0); //activeMaterial.getShader().enableAttribute(vb.getName(), vb.getElements(), GL11.GL_FLOAT, 0, 0, vb.getLayout()); } GL11.glDrawArrays(renderMode, startVert, endVert); for (VertexBufferImpl vb : vertexBuffers.valueCollection()) { GL20.glDisableVertexAttribArray(vb.getLayout()); } }
From source file:org.spout.engine.renderer.GL40BatchVertexRenderer.java
License:Open Source License
@Override protected boolean doFlush(boolean force) { if (flushingBuffer.flush(force)) { GL30.glBindVertexArray(vao);// w w w . j av a 2 s .c o m SpoutRenderer.checkGLError(); if (currentBuffer != null) { currentBuffer.unbind(); for (int layout : currentBuffer.getLayout()) { GL20.glDisableVertexAttribArray(layout); SpoutRenderer.checkGLError(); } } flushingBuffer.bind(true); for (int layout : flushingBuffer.getLayout()) { GL20.glEnableVertexAttribArray(layout); SpoutRenderer.checkGLError(); } GL30.glBindVertexArray(0); SpoutRenderer.checkGLError(); return true; } return false; }