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:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java
License:Apache License
/** * {@inheritDoc}//www. ja v a2 s .com */ @Override public void glVertexAttribPointer(int name, int component, int type, boolean normalised, int stride, int offset) { GL20.glVertexAttribPointer(name, component, type, normalised, stride, offset); }
From source file:bd.ac.seu.lwjgldemo.Renderer.java
private void setupModel() { int COLUMNS_PER_ROW = 3; vertices = new double[NUM_VERTICES * COLUMNS_PER_ROW]; for (int row = 0; row < vertices.length / COLUMNS_PER_ROW; row++) { vertices[row * COLUMNS_PER_ROW + 0] = Math.random(); vertices[row * COLUMNS_PER_ROW + 1] = Math.random(); vertices[row * COLUMNS_PER_ROW + 2] = 0; }/* w ww. jav a2 s . c o m*/ DoubleBuffer buffer = BufferUtils.createDoubleBuffer(vertices.length); buffer.put(vertices); buffer.flip(); vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId); vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_DOUBLE, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
From source file:br.com.perin.renderEngine.Loader.java
private void storeDataInAttributeList(int attributeNumber, int coordSize, float[] data) { int vboID = GL15.glGenBuffers(); vbos.add(vboID);// w w w . j a v a2s .c o m 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, coordSize, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:com.adavr.player.globjects.VertexArray.java
License:Open Source License
public int addAtrribute(int size, int stride) { int index = currentAttribIndex; GL20.glVertexAttribPointer(index, size, GL11.GL_FLOAT, false, stride, currentAttribOffset); currentAttribIndex++;/*from ww w .ja va 2 s . c o m*/ currentAttribOffset += size * 4; return index; }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, Buffer buffer) { if (buffer instanceof ByteBuffer) { GL20.glVertexAttribPointer(indx, size, type, normalized, stride, (ByteBuffer) buffer); } else if (buffer instanceof IntBuffer) { if (type == GL_INT) GL20.glVertexAttribPointer(indx, size, type, normalized, stride, (IntBuffer) buffer); else/* w w w.ja v a2s .c om*/ throw new GdxRuntimeException( "Can't use " + buffer.getClass().getName() + " with type " + type + " with this method."); } else if (buffer instanceof ShortBuffer) { if (type == GL_SHORT) GL20.glVertexAttribPointer(indx, size, type, normalized, stride, (ShortBuffer) buffer); else throw new GdxRuntimeException( "Can't use " + buffer.getClass().getName() + " with type " + type + " with this method."); } else if (buffer instanceof FloatBuffer) { if (type == GL_FLOAT) GL20.glVertexAttribPointer(indx, size, type, 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, ShortBuffer, IntBuffer or FloatBuffer instead. Blame LWJGL"); }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, int ptr) { GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL20.java
License:Apache License
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, Buffer buffer) { if (buffer instanceof ByteBuffer) { if (type == GL_BYTE) GL20.glVertexAttribPointer(indx, size, false, normalized, stride, (ByteBuffer) buffer); else if (type == GL_UNSIGNED_BYTE) GL20.glVertexAttribPointer(indx, size, true, normalized, stride, (ByteBuffer) buffer); else if (type == GL_SHORT) GL20.glVertexAttribPointer(indx, size, false, normalized, stride, ((ByteBuffer) buffer).asShortBuffer()); else if (type == GL_UNSIGNED_SHORT) GL20.glVertexAttribPointer(indx, size, true, normalized, stride, ((ByteBuffer) buffer).asShortBuffer()); else if (type == GL_FLOAT) GL20.glVertexAttribPointer(indx, size, normalized, stride, ((ByteBuffer) buffer).asFloatBuffer()); else/*ww w. j a va 2 s .c om*/ 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 == GL_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:com.badlogic.gdx.backends.lwjgl.swt.LwjglGL20.java
License:Apache License
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, Buffer buffer) { if (buffer instanceof ByteBuffer) { if (type == GL_BYTE) GL20.glVertexAttribPointer(indx, size, false, normalized, stride, (ByteBuffer) buffer); else if (type == GL_UNSIGNED_BYTE) GL20.glVertexAttribPointer(indx, size, true, normalized, stride, (ByteBuffer) buffer); else if (type == GL_SHORT) GL20.glVertexAttribPointer(indx, size, false, normalized, stride, ((ByteBuffer) buffer).asShortBuffer()); else if (type == GL_UNSIGNED_SHORT) GL20.glVertexAttribPointer(indx, size, true, normalized, stride, ((ByteBuffer) buffer).asShortBuffer()); else if (type == GL_FLOAT) GL20.glVertexAttribPointer(indx, size, normalized, stride, ((ByteBuffer) buffer).asFloatBuffer()); else//from w w w . j av a2 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 throw new GdxRuntimeException("Can't use " + buffer.getClass().getName() + " with this method. Use ByteBuffer instead. Blame LWJGL"); }
From source file:com.badlogic.gdx.backends.lwjgl3.Lwjgl3GL20.java
License:Apache License
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, Buffer buffer) { if (buffer instanceof ByteBuffer) { if (type == GL_BYTE) GL20.glVertexAttribPointer(indx, size, type, normalized, stride, (ByteBuffer) buffer); else if (type == GL_UNSIGNED_BYTE) GL20.glVertexAttribPointer(indx, size, type, normalized, stride, (ByteBuffer) buffer); else if (type == GL_SHORT) GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ((ByteBuffer) buffer).asShortBuffer()); else if (type == GL_UNSIGNED_SHORT) GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ((ByteBuffer) buffer).asShortBuffer()); else if (type == GL_FLOAT) GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ((ByteBuffer) buffer).asFloatBuffer()); else//from w w w .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 == GL_FLOAT) GL20.glVertexAttribPointer(indx, size, type, 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:com.colonycraft.rendering.world.ChunkMeshRenderer.java
License:Apache License
public static void renderChunkMesh(World world, Chunk chunk, int meshType) { /* Bind the correct texture */ GL11.glEnable(GL11.GL_TEXTURE_2D);/*from w w w .ja v a 2 s . c om*/ TextureStorage.getTexture("terrain").bind(); if (meshType == ChunkMesh.MESH_OPAQUE) { GL11.glDisable(GL11.GL_BLEND); } else if (meshType == ChunkMesh.MESH_TRANSLUCENT || meshType == ChunkMesh.MESH_GRASS) { GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f); } ChunkMesh cmesh = chunk.getMesh(); Mesh mesh = cmesh.getMesh(meshType); if (mesh == null) return; /* Bind the buffer */ GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, mesh.getVertexBufferHandle()); /* Enable the different kinds of data in the buffer */ GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); if (meshType == ChunkMesh.MESH_GRASS) { GL20.glEnableVertexAttribArray(GRASS_ATTRIBUTE_LIGHT); } else { GL20.glEnableVertexAttribArray(CHUNK_ATTRIBUTE_LIGHT); } /* Define the starting positions */ GL11.glVertexPointer(POSITION_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, POSITION_OFFSET * FLOAT_SIZE); GL11.glTexCoordPointer(TEX_COORD_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, TEX_COORD_OFFSET * FLOAT_SIZE); GL20.glVertexAttribPointer(CHUNK_ATTRIBUTE_LIGHT, 2, GL11.GL_FLOAT, false, STRIDE * FLOAT_SIZE, LIGHT_OFFSET * FLOAT_SIZE); /* Draw the buffer */ GL11.glDrawArrays(GL11.GL_QUADS, 0, mesh.vertices()); /* Unbind the buffer */ GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); /* Disable the different kinds of data */ GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); if (meshType == ChunkMesh.MESH_GRASS) { GL20.glDisableVertexAttribArray(GRASS_ATTRIBUTE_LIGHT); } else { GL20.glDisableVertexAttribArray(CHUNK_ATTRIBUTE_LIGHT); } if (meshType == ChunkMesh.MESH_TRANSLUCENT || meshType == ChunkMesh.MESH_GRASS) { GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_ALPHA_TEST); } }