List of usage examples for org.lwjgl.opengl GL15 GL_STREAM_DRAW
int GL_STREAM_DRAW
To view the source code for org.lwjgl.opengl GL15 GL_STREAM_DRAW.
Click Source Link
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 ww.ja v a 2 s . c o 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.grillecube.client.opengl.GLVertexBuffer.java
/** set the vbo data */ public void bufferData(int target, ByteBuffer data, int usage) { if (data == null) { this.bufferSize(target, 0, GL15.GL_STREAM_DRAW); this.byteCount = 0; } else {/*from www. j a v a 2s . co m*/ GL15.glBufferData(target, data, usage); GL15.glBufferSubData(target, 0, data); this.byteCount = data.capacity(); } }
From source file:com.grillecube.client.opengl.GLVertexBuffer.java
/** update the whole vbo data, using stream draw */ public void bufferDataUpdate(int target, ByteBuffer data, int capacity) { this.bufferData(target, data, GL15.GL_STREAM_DRAW); }
From source file:com.grillecube.client.renderer.particles.ParticleRenderer.java
@Override public void initialize() { this.programBillboardedParticles = new ProgramParticleBillboarded(); this.programCube = new ProgramParticleCube(); // vao init//www. j av a2s. c o m this.cubeMesh = new CubeMesh(); this.cubeMesh.initialize(); this.cubeMesh.bind(); this.cubeInstancesVBO = GLH.glhGenVBO(); this.cubeInstancesVBO.bind(GL15.GL_ARRAY_BUFFER); this.cubeInstancesVBO.bufferSize(GL15.GL_ARRAY_BUFFER, 0, GL15.GL_STREAM_DRAW); this.cubeMesh.setAttributesInstanced(); }
From source file:com.grillecube.engine.opengl.object.GLVertexBuffer.java
/** set the vbo data */ public void bufferData(int target, FloatBuffer data, int usage) { if (data == null) { this.bufferSize(target, 0, GL15.GL_STREAM_DRAW); this._float_count = 0; } else {/*from ww w.ja va2 s.com*/ GL15.glBufferData(target, data, usage); GL15.glBufferSubData(target, 0, data); this._float_count = data.capacity(); } }
From source file:com.grillecube.engine.opengl.object.GLVertexBuffer.java
/** update the whole vbo data, using stream draw */ public void bufferDataUpdate(int target, FloatBuffer data, int capacity) { this.bufferData(target, data, GL15.GL_STREAM_DRAW); }
From source file:com.grillecube.engine.renderer.world.particles.ParticleRenderer.java
/** create a new cube object */ private void initializeVAO() { this._vao_cube = GLH.glhGenVAO(); this._vbo_cube = GLH.glhGenVBO(); this._vao_cube.bind(); this._vbo_cube.bind(GL15.GL_ARRAY_BUFFER); this._vbo_cube.bufferData(GL15.GL_ARRAY_BUFFER, Cube.makeWithTrianglesAndFaces(1), GL15.GL_STATIC_DRAW); this._vao_cube.setAttribute(this._vbo_cube, 0, 4, GL11.GL_FLOAT, false, 4 * 4, 0); this._vbo_cube_instances = GLH.glhGenVBO(); this._vbo_cube_instances.bind(GL15.GL_ARRAY_BUFFER); this._vbo_cube_instances.bufferSize(GL15.GL_ARRAY_BUFFER, 0, GL15.GL_STREAM_DRAW); this._vao_cube.setAttributeInstanced(1, 4, GL11.GL_FLOAT, false, FLOATS_PER_CUBE_INSTANCE * 4, 0 * 4); this._vao_cube.setAttributeInstanced(2, 4, GL11.GL_FLOAT, false, FLOATS_PER_CUBE_INSTANCE * 4, 4 * 4); this._vao_cube.setAttributeInstanced(3, 4, GL11.GL_FLOAT, false, FLOATS_PER_CUBE_INSTANCE * 4, 8 * 4); this._vao_cube.setAttributeInstanced(4, 4, GL11.GL_FLOAT, false, FLOATS_PER_CUBE_INSTANCE * 4, 12 * 4); this._vao_cube.setAttributeInstanced(5, 4, GL11.GL_FLOAT, false, FLOATS_PER_CUBE_INSTANCE * 4, 16 * 4); this._vao_cube.setAttributeInstanced(6, 1, GL11.GL_FLOAT, false, FLOATS_PER_CUBE_INSTANCE * 4, 20 * 4); this._vao_cube.enableAttribute(0); this._vao_cube.enableAttribute(1); this._vao_cube.enableAttribute(2); this._vao_cube.enableAttribute(3); this._vao_cube.enableAttribute(4); this._vao_cube.enableAttribute(5); this._vao_cube.enableAttribute(6); }
From source file:com.opengrave.og.base.Renderable2D.java
License:Open Source License
@Override public void dealWithChange() { Util.checkErr();/*from w w w .j a v a2 s . c o m*/ if (vaoID == 0) { vaoID = GL30.glGenVertexArrays(); } GL30.glBindVertexArray(vaoID); Util.checkErr(); if (vbopID == 0) { vbopID = GL15.glGenBuffers(); } Util.checkErr(); if (vbocID == 0) { vbocID = GL15.glGenBuffers(); } Util.checkErr(); if (vbotID == 0) { vbotID = GL15.glGenBuffers(); } Util.checkErr(); if (changed) { changed = false; vertexList.clear(); posBuffer.clear(); colBuffer.clear(); texBuffer.clear(); recreate(); Util.checkErr(); int verts = vertexList.size(); if (vertexList.size() == 0) { return; } if (posBuffer.capacity() != verts * 2) { posBuffer = BufferUtils.createFloatBuffer(verts * 2); } Util.checkErr(); if (colBuffer.capacity() != verts * 4) { colBuffer = BufferUtils.createFloatBuffer(verts * 4); } if (texBuffer.capacity() != verts * 3) { texBuffer = BufferUtils.createFloatBuffer(verts * 3); } for (Vertex2D v2 : vertexList) { posBuffer.put(v2.x).put(v2.y); texBuffer.put(v2.tx).put(v2.ty).put(v2.tz); colBuffer.put(v2.r).put(v2.g).put(v2.b).put(v2.a); } posBuffer.flip(); texBuffer.flip(); colBuffer.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbopID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, posBuffer, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(0, 2, GL11.GL_FLOAT, false, 0, 0); Util.checkErr(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbocID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, colBuffer, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(1, 4, GL11.GL_FLOAT, false, 0, 0); Util.checkErr(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbotID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, texBuffer, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 0, 0); Util.checkErr(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); } }
From source file:com.opengrave.og.base.RenderableParticles.java
License:Open Source License
@Override public void dealWithChange() { // Safely assume every frame is a new frame in terms of particle // positions. if (idVao == 0) { idVao = GL30.glGenVertexArrays(); }// www . j ava 2s . com GL30.glBindVertexArray(idVao); if (idVboColours == 0) { idVboColours = GL15.glGenBuffers(); } if (idVboPositions == 0) { idVboPositions = GL15.glGenBuffers(); } if (idVboScale == 0) { idVboScale = GL15.glGenBuffers(); } size = particleList.size() * 4; if (positions == null || positions.capacity() != size) { positions = BufferUtils.createFloatBuffer(size); } if (colours == null || colours.capacity() != size) { colours = BufferUtils.createFloatBuffer(size); } if (scales == null || scales.capacity() != size) { scales = BufferUtils.createFloatBuffer(size); } positions.rewind(); colours.rewind(); scales.rewind(); for (ParticlePart particle : particleList) { Vector3f pos = particle.getPosition().toVector3(), sca = particle.getScaleData(); Vector4f col = particle.getColour(); positions.put(pos.x).put(pos.y).put(pos.z).put(1f); colours.put(col.x).put(col.y).put(col.z).put(col.w); scales.put(sca.x).put(sca.y).put(sca.z).put(1f); } positions.flip(); colours.flip(); scales.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, idVboPositions); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, positions, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(0, 4, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, idVboColours); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, colours, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(1, 4, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, idVboScale); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, scales, GL15.GL_STREAM_DRAW); GL20.glVertexAttribPointer(2, 4, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }
From source file:com.samrj.devil.gl.VertexStream.java
License:Open Source License
@Override void onBegin() {/*from w w w . j av a2s .com*/ vboSize = maxVertices * vertexSize(); vertexBlock = new Memory(vboSize); vertexBuffer = vertexBlock.buffer; vbo = GL15.glGenBuffers(); int prevBinding = GL11.glGetInteger(GL15.GL_ARRAY_BUFFER_BINDING); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vboSize, GL15.GL_STREAM_DRAW); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, prevBinding); if (maxIndices > 0) { eboSize = maxIndices * 4; indexBlock = new Memory(eboSize); indexBuffer = indexBlock.buffer; ibo = GL15.glGenBuffers(); prevBinding = GL11.glGetInteger(GL15.GL_ELEMENT_ARRAY_BUFFER_BINDING); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, eboSize, GL15.GL_STREAM_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, prevBinding); } state = State.READY; Profiler.addUsedVRAM(vboSize * 8L); Profiler.addUsedVRAM(eboSize * 8L); }