Java Code Examples for com.jogamp.opengl.GL3#glGetIntegerv()
The following examples show how to use
com.jogamp.opengl.GL3#glGetIntegerv() .
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_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 2
Source File: Gl_320_texture_streaming.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 true; }
Example 3
Source File: Gl_320_test_scissor.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 true; }
Example 4
Source File: Gl_320_texture_fetch.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 5
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 6
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 7
Source File: Gl_320_fbo_depth.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 8
Source File: Gl_320_fbo.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 9
Source File: Gl_320_glsl_builtin_blocks.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 checkError(gl3, "initBuffer"); }
Example 10
Source File: Gl_320_glsl_input_struct.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 11
Source File: Gl_320_fbo_blend.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 12
Source File: Gl_320_texture_float.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 checkError(gl3, "initBuffer"); }
Example 13
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 14
Source File: Gl_320_fbo_srgb_blend.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 15
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 16
Source File: Gl_300_test_alpha.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean begin(GL gl) { GL3 gl3 = (GL3) gl; boolean validated = true; int[] maxVaryingOutputComp = {0}; gl3.glGetIntegerv(GL_MAX_VARYING_COMPONENTS, maxVaryingOutputComp, 0); int[] maxVaryingOutputVec = {0}; gl3.glGetIntegerv(GL_MAX_VARYING_VECTORS, maxVaryingOutputVec, 0); if (validated) { validated = initTest(gl3); } if (validated) { validated = initProgram(gl3); } if (validated) { validated = initBuffer(gl3); } if (validated) { validated = initVertexArray(gl3); } if (validated) { validated = initTexture(gl3); } return validated && checkError(gl3, "begin"); }
Example 17
Source File: Gl_320_fbo_srgb.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 true; }
Example 18
Source File: Gl_320_query_conditional.java From jogl-samples with MIT License | 4 votes |
private boolean initBuffer(GL3 gl3) { IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData); gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); 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); int uniformTransformBlockSize = Math.max(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); uniformMaterialOffset = Math.max(Vec4.SIZE, uniformBufferOffset.get(0)); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.MATERIAL)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformMaterialOffset * 2, null, GL_STATIC_DRAW); { ByteBuffer pointer = gl3.glMapBufferRange(GL_UNIFORM_BUFFER, 0, uniformMaterialOffset * 2, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); float[][] materials = {new float[]{0.0f, 0.5f, 1.0f, 1.0f}, new float[]{1.0f, 0.5f, 0.0f, 1.0f}}; for (int i = 0; i < materials.length; i++) { for (int j = 0; j < materials[0].length; j++) { pointer.putFloat(i * uniformMaterialOffset + j * Float.BYTES, materials[i][j]); } } pointer.rewind(); gl3.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(uniformBufferOffset); BufferUtils.destroyDirectBuffer(positionBuffer); return checkError(gl3, "initBuffer"); }
Example 19
Source File: Gl_320_buffer_uniform_shared.java From jogl-samples with MIT License | 4 votes |
private boolean initBuffer(GL3 gl3) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData); gl3.glGenBuffers(Buffer.MAX, bufferName); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl3.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); gl3.glGetActiveUniformBlockiv( programName, uniformTransform, GL_UNIFORM_BLOCK_DATA_SIZE, uniformBlockSizeTransform); uniformBlockSizeTransform .put(0, (uniformBlockSizeTransform.get(0) / uniformBufferOffset.get(0) + 1) * uniformBufferOffset.get(0)); gl3.glGetActiveUniformBlockiv( programName, uniformMaterial, GL_UNIFORM_BLOCK_DATA_SIZE, uniformBlockSizeMaterial); uniformBlockSizeMaterial .put(0, (uniformBlockSizeMaterial.get(0) / uniformBufferOffset.get(0) + 1) * uniformBufferOffset.get(0)); gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.UNIFORM)); gl3.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSizeTransform.get(0) + uniformBlockSizeMaterial.get(0), null, GL_DYNAMIC_DRAW); gl3.glBindBuffer(GL_UNIFORM_BUFFER, 0); 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, positionSize, positionBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(positionBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return checkError(gl3, "initBuffer"); }
Example 20
Source File: Gl_320_sync.java From jogl-samples with MIT License | 4 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); return true; }