List of usage examples for org.lwjgl.opengl GL15 GL_ARRAY_BUFFER
int GL_ARRAY_BUFFER
To view the source code for org.lwjgl.opengl GL15 GL_ARRAY_BUFFER.
Click Source Link
From source file:a1.gui.GUI_Map.java
License:Open Source License
private void initVBO() { tile_vbo = GL15.glGenBuffers();/*from w ww. ja va 2 s.co m*/ tileGrid_vbo = GL15.glGenBuffers(); claim_vbo = GL15.glGenBuffers(); FloatBuffer data = BufferUtils.createFloatBuffer(tile_vboSize); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tile_vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_DYNAMIC_DRAW); data = BufferUtils.createFloatBuffer(tileGrid_vboSize); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tileGrid_vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_DYNAMIC_DRAW); data = BufferUtils.createFloatBuffer(claim_vboSize); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, claim_vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_DYNAMIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:a1.gui.GUI_Map.java
License:Open Source License
private void updateVBO() { tile_drawCount = tile_Offset / 4;//w ww. jav a2 s .com tileGrid_drawCount = tileGrid_Offset / 2; claim_drawCount = claim_Offset / 6; FloatBuffer data = BufferUtils.createFloatBuffer(tile_Offset); data.put(tile_vboUpdate, 0, tile_Offset); data.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tile_vbo); GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, data); data = BufferUtils.createFloatBuffer(tileGrid_Offset); data.put(tileGrid_vboUpdate, 0, tileGrid_Offset); data.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tileGrid_vbo); GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, data); data = BufferUtils.createFloatBuffer(claim_Offset); data.put(claim_vboUpdate, 0, claim_Offset); data.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, claim_vbo); GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, data); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); tile_Offset = 0; tileGrid_Offset = 0; claim_Offset = 0; }
From source file:a1.gui.GUI_Map.java
License:Open Source License
public void DrawTiles() { int x, y, i;/* www . j a v a 2s . c om*/ int stw, sth; Coord oc, tc, ctc, sc; RenderedTiles = 0; Render2D.ChangeColor(); Sprite.setStaticColor(); // ? ? stw = (TILE_SIZE * 4) - 2; sth = TILE_SIZE * 2; // ? ? Coord sz = scaled_size; oc = viewoffset(sz, mc); // ? ? tc = mc.div(TILE_SIZE); tc.x += -(sz.x / (2 * stw)) - (sz.y / (2 * sth)) - 2; tc.y += (sz.x / (2 * stw)) - (sz.y / (2 * sth)); if (needUpdateView) { needUpdateView = false; for (y = 0; y < (sz.y / sth) + 13; y++) { for (x = 0; x < (sz.x / stw) + 3; x++) { for (i = 0; i < 2; i++) { // ctc = tc.add(new Coord(x + y, y - x + i)); // ? sc = m2s(ctc.mul(TILE_SIZE)).add(oc); sc.x -= TILE_SIZE * 2; // // ? drawtile(ctc, sc); } } } // ? ? if (Config.tile_grid) { for (y = 0; y < (sz.y / sth) + 2; y++) { for (x = 0; x < (sz.x / stw) + 3; x++) { for (i = 0; i < 2; i++) { ctc = tc.add(new Coord(x + y, -x + y + i)); sc = m2s(ctc.mul(TILE_SIZE)).add(oc); drawtile_grid(sc); } } } } if (render_claims) { Color col; for (ClaimPersonal claim : Claims.claims.values()) { if (Player.CharID == claim.owner_id) { col = new Color(0f, 1f, 1f, 0.25f); // if (Claims.expand_claim != null) // continue; } else col = new Color(1f, 0f, 0f, 0.25f); putClaim(claim, oc, col); } if (Claims.expand_claim != null) { col = new Color(0f, 0f, 0.8f, 0.17f); putClaim(Claims.expand_claim, oc, col); } } // updateVBO(); } Color.white.bind(); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tile_vbo); GL11.glVertexPointer(2, GL11.GL_FLOAT, 16, 0L); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 16, 8L); Resource.textures.get("tiles").bind(); GL11.glDrawArrays(GL11.GL_QUADS, 0, tile_drawCount); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); if (render_claims) { GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, claim_vbo); GL11.glColorPointer(4, GL11.GL_FLOAT, 24, 0L); GL11.glVertexPointer(2, GL11.GL_FLOAT, 24, 16L); GL11.glDrawArrays(GL11.GL_QUADS, 0, claim_drawCount); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); } if (Config.tile_grid) { GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.4f); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tileGrid_vbo); GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0L); GL11.glDrawArrays(GL11.GL_LINES, 0, tileGrid_drawCount); } GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); }
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; }//from w ww . j a v a 2 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);/*from ww w . jav a 2 s .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:br.com.perin.renderEngine.Loader.java
private void bindIndicesBuffer(int[] indices) { int vboId = GL15.glGenBuffers(); vbos.add(vboId);/*from ww w .ja va2 s . c om*/ GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboId); IntBuffer buffer = storeDataInIntBuffer(indices); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:com.adavr.player.context.QuadContext.java
License:Open Source License
@Override public void setup() { final float w = width / 2f; final float h = height / 2f; vertices = new TextureVertex[] { new TextureVertex(-w + offset.x, h + offset.y, offset.z, 1f, new Color(1, 0, 0, 1), new UV(0, 0)), new TextureVertex(-w + offset.x, -h + offset.y, offset.z, 1f, new Color(0, 1, 0, 1), new UV(0, 1)), new TextureVertex(w + offset.x, -h + offset.y, offset.z, 1f, new Color(0, 0, 1, 1), new UV(1, 1)), new TextureVertex(w + offset.x, h + offset.y, offset.z, 1f, new Color(1, 1, 1, 1), new UV(1, 0)) }; GLDataBuffer verticesBuffer = new GLDataBuffer(64); verticesBuffer.put(vertices);/*w w w .ja v a 2 s .c o m*/ vao = VertexArray.create(); VertexArray.bind(vao); { verticesVBO = VertexBuffer.create(GL15.GL_ARRAY_BUFFER); VertexBuffer.bind(verticesVBO); { verticesVBO.bufferData(verticesBuffer.getFlippedBuffer(), GL15.GL_STATIC_DRAW); int stride = Vertex.SIZE + Color.SIZE + UV.SIZE; vao.addAtrribute(Vertex.COUNT, stride); vao.addAtrribute(Color.COUNT, stride); vao.addAtrribute(UV.COUNT, stride); } VertexBuffer.unbind(verticesVBO); } VertexArray.unbind(); ByteBuffer indicesBuffer = GLObject.setupByteBuffer(new byte[] { 0, 1, 2, 2, 3, 0 }); indicesCount = indicesBuffer.limit(); indicesVBO = VertexBuffer.create(GL15.GL_ELEMENT_ARRAY_BUFFER); VertexBuffer.bind(indicesVBO); { indicesVBO.bufferData(indicesBuffer, GL15.GL_STATIC_DRAW); } VertexBuffer.unbind(indicesVBO); }
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."); }/* ww w . j av a 2 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.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();//ww w . j a va 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); } }