List of usage examples for org.lwjgl.opengl GL15 glBindBuffer
public static void glBindBuffer(@NativeType("GLenum") int target, @NativeType("GLuint") int buffer)
From source file:com.auroraengine.opengl.model.GLIndexBuffer.java
License:Open Source License
@Override public void create() throws GLException { if (index_buffer != null && index == 0) { index = GL15.glGenBuffers();// www . ja va 2s . c o m if (index == 0) { throw new GLException("Buffer could not be generated."); } GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, index); GL15.glBufferData(index, index_buffer, usage.gl_draw); } }
From source file:com.auroraengine.opengl.model.GLVertexBuffers.java
License:Open Source License
@Override public void create() throws GLException { if (dynamic_bb != null && dynamic_index == 0) { dynamic_index = GL15.glGenBuffers(); if (dynamic_index == 0) { throw new GLException("Buffer could not be generated."); }/* w w w. j a v a2 s .co m*/ GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, dynamic_index); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, dynamic_bb, GL15.GL_DYNAMIC_DRAW); } if (stream_bb != null && stream_index == 0) { stream_index = GL15.glGenBuffers(); if (stream_index == 0) { throw new GLException("Buffer could not be generated."); } GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, stream_index); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, stream_bb, GL15.GL_STREAM_DRAW); } if (static_bb != null && static_index == 0) { static_index = GL15.glGenBuffers(); if (static_index == 0) { throw new GLException("Buffer could not be generated."); } GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, static_index); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, static_bb, GL15.GL_STATIC_DRAW); } }
From source file:com.auroraengine.opengl.model.IndexBuffer.java
License:Open Source License
public void bind() { if (index != 0) { GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, index); } }
From source file:com.auroraengine.opengl.model.IndexBuffer.java
License:Open Source License
@Override public void create() throws GLException { if (index == 0) { index = GL15.glGenBuffers();// w ww. j a v a 2 s. c o m if (index == 0) { throw new GLException("Buffer could not be generated."); } GLException.checkGL("Generating Buffer"); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, index); GLException.checkGL("Binding Buffer"); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, ib, permissions); GLException.checkGL("Setting Buffer Data"); } }
From source file:com.auroraengine.opengl.model.IndexBuffer.java
License:Open Source License
@Override public void update() throws GLException { // Need to update the buffer if it is able to if (index != 0 && permissions != GL15.GL_STATIC_DRAW) { // Edit according to the modifications of the buffer. GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, index); GLException.checkGL("Binding Buffer"); GL15.glBufferSubData(GL15.GL_ELEMENT_ARRAY_BUFFER, ib.position(), ib); GLException.checkGL("Setting Buffer Data"); }/*from www . j av a 2 s. c o m*/ }
From source file:com.auroraengine.opengl.model.VertexBuffer.java
License:Open Source License
public void bind() { if (index != 0) { GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, index); } }
From source file:com.auroraengine.opengl.model.VertexBuffer.java
License:Open Source License
@Override public void create() throws GLException { if (index == 0) { index = GL15.glGenBuffers();//from w w w .ja v a 2 s . c o m if (index == 0) { throw new GLException("Buffer could not be generated."); } GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, index); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, bb, permissions); } }
From source file:com.auroraengine.opengl.model.VertexBuffer.java
License:Open Source License
@Override public void update() throws GLException { // Need to update the buffer if it is able to if (index != 0 && permissions != GL15.GL_STATIC_DRAW) { // Edit according to the modifications of the buffer. GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, index); GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, bb.position(), bb); }/* w w w. j a v a 2 s . c o m*/ }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glBindBuffer(int target, int buffer) { GL15.glBindBuffer(target, buffer); }
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);//w w w .j a v a2 s. co m 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); } }