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: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 {// 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. *//* w w w.j av a2 s . c om*/ 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.oscim.gdx.LwjglGL20.java
License:Apache License
public void vertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, Buffer buffer) { if (buffer instanceof ByteBuffer) { if (type == BYTE) GL20.glVertexAttribPointer(indx, size, false, normalized, stride, (ByteBuffer) buffer); else if (type == UNSIGNED_BYTE) GL20.glVertexAttribPointer(indx, size, true, normalized, stride, (ByteBuffer) buffer); else if (type == SHORT) GL20.glVertexAttribPointer(indx, size, false, normalized, stride, ((ByteBuffer) buffer).asShortBuffer()); else if (type == UNSIGNED_SHORT) GL20.glVertexAttribPointer(indx, size, true, normalized, stride, ((ByteBuffer) buffer).asShortBuffer()); else if (type == FLOAT) GL20.glVertexAttribPointer(indx, size, normalized, stride, ((ByteBuffer) buffer).asFloatBuffer()); else/*from w ww . j a v a 2 s . c o m*/ throw new GdxRuntimeException("Can't use " + buffer.getClass().getName() + " with type " + type + " with this method. Use ByteBuffer and one of GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT or GL_FLOAT for type. Blame LWJGL"); } else if (buffer instanceof FloatBuffer) { if (type == FLOAT) GL20.glVertexAttribPointer(indx, size, normalized, stride, (FloatBuffer) buffer); else throw new GdxRuntimeException( "Can't use " + buffer.getClass().getName() + " with type " + type + " with this method."); } else throw new GdxRuntimeException("Can't use " + buffer.getClass().getName() + " with this method. Use ByteBuffer instead. Blame LWJGL"); }
From source file:org.oscim.gdx.LwjglGL20.java
License:Apache License
public void vertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, int ptr) { GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr); }
From source file:org.spout.engine.renderer.GL20BatchVertexRenderer.java
License:Open Source License
/** * Draws this batch/*from ww w . j a va2 s. c o 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 . j a v a2 s .c o 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.shader.ClientShader.java
License:Open Source License
@Override public void enableAttribute(String name, int size, int type, int stride, long offset, int layout) { GL20.glEnableVertexAttribArray(layout); GL20.glVertexAttribPointer(layout, size, type, false, 0, offset); }
From source file:org.spout.engine.renderer.vertexbuffer.GLFloatBuffer.java
License:Open Source License
public void bind() { if (vboId == -1) throw new IllegalStateException("Cannot bind a vertex buffer without data!"); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL20.glVertexAttribPointer(getLayout(), getElements(), GL11.GL_FLOAT, false, 0, 0); }