Java Code Examples for com.jogamp.opengl.GL3#glBufferData()
The following examples show how to use
com.jogamp.opengl.GL3#glBufferData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Gl_320_draw_range_arrays.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); int uniformTransformBlockSize = Math.max(2 * Mat4.SIZE, uniformBufferOffset.get(0)); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformTransformBlockSize, null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(positionBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return checkError(gl3, "initBuffer"); }
Example 2
Source File: Gl_320_texture_pixel_store.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glGetIntegerv( GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0)); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return checkError(gl3, "initBuffer"); }
Example 3
Source File: Gl_330_fbo_multisample_explicit_nv.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL3 gl3) { ByteBuffer vertexBuffer = GLBuffers.newDirectByteBuffer(vertexSize); gl3.glGenBuffers(1, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(0)); for (int i = 0; i < vertexCount; i++) { vertexData[i].toBb(vertexBuffer, i); } gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); return checkError(gl3, "initBuffer"); }
Example 4
Source File: Gl_320_fbo_rtt.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL3 gl3) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return checkError(gl3, "initBuffer"); }
Example 5
Source File: Gl_320_glsl_precision.java From jogl-samples with MIT License | 5 votes |
private boolean initBuffer(GL3 gl3) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0)); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return checkError(gl3, "initBuffer"); }
Example 6
Source File: Gl_320_primitive_point_clip.java From jogl-samples with MIT License | 5 votes |
private boolean initBuffer(GL3 gl3) { // Generate a buffer object gl3.glGenBuffers(1, bufferName); // Bind the buffer for use gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(0)); vertexCount = 5; // Reserve buffer memory but don't copy the values gl3.glBufferData(GL_ARRAY_BUFFER, glf.Vertex_v4fc4f.SIZE * vertexCount, null, GL_STATIC_DRAW); ByteBuffer data = gl3.glMapBufferRange(GL_ARRAY_BUFFER, 0, // Offset glf.Vertex_v4fc4f.SIZE * vertexCount, // Size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); float[] floatArray = { -1.0f, 0.0f, 2.0f, 1.0f, +1.0f, 0.0f, 0.0f, 1.0f, -0.5f, 0.0f, 2.5f, 1.0f, +1.0f, 0.5f, 0.0f, 1.0f, +0.0f, 0.0f, 3.0f, 1.0f, +1.0f, 1.0f, 0.0f, 1.0f, +0.5f, 0.0f, 3.5f, 1.0f, +0.0f, 1.0f, 0.0f, 1.0f, +1.0f, 0.0f, 4.0f, 1.0f, +0.0f, 0.0f, 1.0f, 1.0f}; data.asFloatBuffer().put(floatArray).rewind(); gl3.glUnmapBuffer(GL_ARRAY_BUFFER); // Unbind the buffer gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); return checkError(gl3, "initArrayBuffer"); }
Example 7
Source File: Gl_320_primitive_line_msaa.java From jogl-samples with MIT License | 5 votes |
private boolean initBuffer(GL3 gl3) { gl3.glGenBuffers(Buffer.MAX, bufferName); float[] data = new float[2 * 36]; for (int i = 0; i < 36; ++i) { float angle = (float) Math.PI * 2.0f * i / (data.length / 2); data[i * 2 + 0] = Glm.normalize(new float[]{(float) Math.sin(angle), (float) Math.cos(angle)})[0]; data[i * 2 + 1] = Glm.normalize(new float[]{(float) Math.sin(angle), (float) Math.cos(angle)})[1]; } vertexCount = 18;//static_cast<GLsizei>(Data.size() - 8); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(data); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, data.length * Float.BYTES, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0)); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return true; }
Example 8
Source File: JCudaDriverSimpleJOGL.java From jcuda-samples with MIT License | 5 votes |
/** * Create the vertex buffer object (VBO) that stores the * vertex positions. * * @param gl The GL context */ private void initVBO(GL3 gl) { int buffer[] = new int[1]; // Create the vertex array object gl.glGenVertexArrays(1, IntBuffer.wrap(buffer)); vertexArrayObject = buffer[0]; gl.glBindVertexArray(vertexArrayObject); // Create the vertex buffer object gl.glGenBuffers(1, IntBuffer.wrap(buffer)); vertexBufferObject = buffer[0]; // Initialize the vertex buffer object gl.glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject); int size = meshWidth * meshHeight * 4 * Sizeof.FLOAT; gl.glBufferData(GL_ARRAY_BUFFER, size, (Buffer) null, GL_DYNAMIC_DRAW); // Initialize the attribute location of the input // vertices for the shader program int location = gl.glGetAttribLocation(shaderProgramID, "inVertex"); gl.glVertexAttribPointer(location, 4, GL_FLOAT, false, 0, 0); gl.glEnableVertexAttribArray(location); // Register the vertexBufferObject for use with CUDA vboGraphicsResource = new CUgraphicsResource(); cuGraphicsGLRegisterBuffer( vboGraphicsResource, vertexBufferObject, CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD); }
Example 9
Source File: Gl_320_fbo_depth_stencil.java From jogl-samples with MIT License | 5 votes |
private boolean initBuffer(GL3 gl3) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); IntBuffer uniformBufferOffsetAlignment = GLBuffers.newDirectIntBuffer(1); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffsetAlignment); uniformBufferOffsetAlignment.put(0, glm.ceilMultiple(Mat4.SIZE, uniformBufferOffsetAlignment.get(0))); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBufferOffsetAlignment.get(0) * 2, null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffsetAlignment); return true; }
Example 10
Source File: Gl_320_texture_derivative.java From jogl-samples with MIT License | 5 votes |
private boolean initBuffer(GL3 gl3) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0)); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return true; }
Example 11
Source File: Gl_320_transform_feedback_interleaved.java From jogl-samples with MIT License | 4 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData); // Generate a buffer object gl3.glGenBuffers(Program.MAX, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Program.TRANSFORM)); gl3.glBufferData(GL_ARRAY_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Program.FEEDBACK)); gl3.glBufferData(GL_ARRAY_BUFFER, Vertex_v4fc4f.SIZE * vertexCount, null, GL_STATIC_COPY); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(positionBuffer); return checkError(gl3, "initBuffer"); }
Example 12
Source File: Gl_320_buffer_uniform.java From jogl-samples with MIT License | 4 votes |
private boolean initBuffer(GL3 gl3) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); { gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.PER_DRAW)); gl3.glBufferData(GL_UNIFORM_BUFFER, Transform.SIZE, null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); } { Light light = new Light(new Vec3(0.0f, 0.0f, 100.f)); FloatBuffer lightBuffer = GLBuffers.newDirectFloatBuffer(light.toFa_()); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.PER_PASS)); gl3.glBufferData(GL_UNIFORM_BUFFER, Light.SIZE, lightBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(lightBuffer); } { Material material = new Material(new Vec3(0.7f, 0.0f, 0.0f), new Vec3(0.0f, 0.5f, 0.0f), new Vec3(0.0f, 0.0f, 0.5f), 128.0f); FloatBuffer materialBuffer = GLBuffers.newDirectFloatBuffer(material.toFa_()); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.PER_SCENE)); gl3.glBufferData(GL_UNIFORM_BUFFER, Material.SIZE, materialBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(materialBuffer); } BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }
Example 13
Source File: Gl_330_texture_integer_rgb10a2ui.java From jogl-samples with MIT License | 4 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl3.glGenBuffers(1, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(0)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }
Example 14
Source File: Gl_320_buffer_update.java From jogl-samples with MIT License | 4 votes |
private boolean initBuffer(GL3 gl3) { // Generate a buffer object gl3.glGenBuffers(Buffer.MAX, bufferName); // Bind the buffer for use gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.ARRAY)); // Reserve buffer memory but don't copy the values gl3.glBufferData( GL_ARRAY_BUFFER, positionSize, null, GL_STATIC_DRAW); // Copy the vertex data in the buffer, in this sample for the whole range of data. // It doesn't required to be the buffer size but pointers require no memory overlapping. ByteBuffer data = gl3.glMapBufferRange( GL_ARRAY_BUFFER, 0, // Offset positionSize, // Size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); data.asFloatBuffer().put(positionData).rewind(); // Explicitly send the data to the graphic card. gl3.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, positionSize); gl3.glUnmapBuffer(GL_ARRAY_BUFFER); // Unbind the buffer gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); // Copy buffer gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.COPY)); gl3.glBufferData(GL_ARRAY_BUFFER, positionSize, null, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_COPY_READ_BUFFER, bufferName.get(Buffer.ARRAY)); gl3.glBindBuffer(GL_COPY_WRITE_BUFFER, bufferName.get(Buffer.COPY)); gl3.glCopyBufferSubData( GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, positionSize); gl3.glBindBuffer(GL_COPY_READ_BUFFER, 0); gl3.glBindBuffer(GL_COPY_WRITE_BUFFER, 0); int[] uniformBlockSize = {0}; { gl3.glGetActiveUniformBlockiv( programName, uniformTransform, GL_UNIFORM_BLOCK_DATA_SIZE, uniformBlockSize, 0); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize[0], null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); } { FloatBuffer diffuseBuffer = GLBuffers.newDirectFloatBuffer(new float[]{1.0f, 0.5f, 0.0f, 1.0f}); gl3.glGetActiveUniformBlockiv( programName, uniformMaterial, GL_UNIFORM_BLOCK_DATA_SIZE, uniformBlockSize, 0); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.MATERIAL)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize[0], diffuseBuffer, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(diffuseBuffer); } return checkError(gl3, "initBuffer"); }
Example 15
Source File: Gl_330_query_time.java From jogl-samples with MIT License | 4 votes |
private boolean initArrayBuffer(GL3 gl3) { FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData); // Generate a buffer object gl3.glGenBuffers(1, bufferName); // Bind the buffer for use gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(0)); // Reserve buffer memory but and copy the values gl3.glBufferData(GL_ARRAY_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW); // Unbind the buffer gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(positionBuffer); return checkError(gl3, "initArrayBuffer"); }
Example 16
Source File: Gl_320_texture_compressed_ext.java From jogl-samples with MIT License | 3 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl3.glGenBuffers(1, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(0)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }
Example 17
Source File: Gl_300_fbo_multisample.java From jogl-samples with MIT License | 3 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl3.glGenBuffers(1, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(0)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); return checkError(gl3, "initBuffer"); }
Example 18
Source File: Gl_320_fbo_multisample_explicit.java From jogl-samples with MIT License | 3 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl3.glGenBuffers(1, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(0)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); return checkError(gl3, "initBuffer"); }
Example 19
Source File: Gl_320_draw_range_elements.java From jogl-samples with MIT License | 3 votes |
private boolean initBuffer(GL3 gl3) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0)); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return checkError(gl3, "initBuffer"); }
Example 20
Source File: Gl_320_texture_lod.java From jogl-samples with MIT License | 3 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl3.glGenBuffers(1, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(0)); gl3.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }