com.jogamp.opengl.util.GLBuffers Java Examples
The following examples show how to use
com.jogamp.opengl.util.GLBuffers.
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_430_image_sampling.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); BufferUtils.destroyDirectBuffer(elementBuffer); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); BufferUtils.destroyDirectBuffer(vertexBuffer); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, Mat4.SIZE, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); return true; }
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_400_blend_rtt.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL4 gl4) { gl4.glGenFramebuffers(1, framebufferName); gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl4.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.R), 0); gl4.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, textureName.get(Texture.G), 0); gl4.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, textureName.get(Texture.B), 0); IntBuffer drawBuffers = GLBuffers.newDirectIntBuffer(4); drawBuffers.put(0, GL_NONE); drawBuffers.put(1, GL_COLOR_ATTACHMENT0); drawBuffers.put(2, GL_COLOR_ATTACHMENT1); drawBuffers.put(3, GL_COLOR_ATTACHMENT2); gl4.glDrawBuffers(4, drawBuffers); if (!isFramebufferComplete(gl4, framebufferName.get(0))) { return false; } gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); return true; }
Example #4
Source File: Gl_500_primitive_bindless_nv.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); BufferUtils.destroyDirectBuffer(vertexBuffer); gl4.glGetBufferParameterui64vNV(GL_ARRAY_BUFFER, GL_BUFFER_GPU_ADDRESS_NV, address); gl4.glMakeBufferResidentNV(GL_ARRAY_BUFFER, GL_READ_ONLY); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, Mat4.SIZE, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); return true; }
Example #5
Source File: Gl_400_texture_cube.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); int uniformBlockSize = Math.max(Transform.SIZE, uniformBufferOffset.get(0)); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(vertexBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return true; }
Example #6
Source File: Gl_420_texture_cube.java From jogl-samples with MIT License | 6 votes |
private boolean initSampler(GL4 gl4) { FloatBuffer borderColor = GLBuffers.newDirectFloatBuffer(new float[]{0.0f, 0.0f, 0.0f, 0.0f}); gl4.glGenSamplers(1, samplerName); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); gl4.glSamplerParameterfv(samplerName.get(0), GL_TEXTURE_BORDER_COLOR, borderColor); gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_MIN_LOD, -1000.f); gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_MAX_LOD, 1000.f); gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_LOD_BIAS, 0.0f); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_COMPARE_MODE, GL_NONE); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0f); BufferUtils.destroyDirectBuffer(borderColor); return true; }
Example #7
Source File: Gl_330_draw_instanced_array.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL3 gl3) { FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData); FloatBuffer colorBuffer = GLBuffers.newDirectFloatBuffer(colorData); gl3.glGenBuffers(Buffer.MAX, bufferName); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.POSITION)); gl3.glBufferData(GL_ARRAY_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.COLOR)); gl3.glBufferData(GL_ARRAY_BUFFER, colorSize, colorBuffer, GL_STATIC_DRAW); gl3.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(positionBuffer); BufferUtils.destroyDirectBuffer(colorBuffer); return checkError(gl3, "initBuffer"); }
Example #8
Source File: Gl_420_test_depth_conservative.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { boolean validated = true; ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, Mat4.SIZE, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return validated; }
Example #9
Source File: Gl_440_fbo_depth_stencil.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); BufferUtils.destroyDirectBuffer(elementBuffer); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); int[] uniformBufferOffset = {0}; gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0); int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); return true; }
Example #10
Source File: Gl_400_fbo_multisample.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); ByteBuffer vertexBuffer = GLBuffers.newDirectByteBuffer(vertexSize); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); for (int i = 0; i < vertexCount; i++) { vertexData[i].toBb(vertexBuffer, i); } vertexBuffer.rewind(); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }
Example #11
Source File: Gl_420_draw_image_space_rendering.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }
Example #12
Source File: Gl_330_query_occlusion.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean begin(GL gl) { GL3 gl3 = (GL3) gl; boolean validated = true; IntBuffer queryCounter = GLBuffers.newDirectIntBuffer(1); gl3.glGetQueryiv(GL_ANY_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, queryCounter); assert (queryCounter.get(0) > 0); if (validated) { validated = initProgram(gl3); } if (validated) { validated = initBuffer(gl3); } if (validated) { validated = initVertexArray(gl3); } if (validated) { validated = initQuery(gl3); } return validated && checkError(gl3, "begin"); }
Example #13
Source File: Gl_450_direct_state_access.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL4 gl4) { gl4.glCreateFramebuffers(Framebuffer.MAX, framebufferName); gl4.glNamedFramebufferTexture(framebufferName.get(Framebuffer.RENDER), GL_COLOR_ATTACHMENT0, textureName.get(Texture.MULTISAMPLE), 0); gl4.glNamedFramebufferTexture(framebufferName.get(Framebuffer.RESOLVE), GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0); if (gl4.glCheckNamedFramebufferStatus(framebufferName.get(Framebuffer.RENDER), GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { return false; } if (gl4.glCheckNamedFramebufferStatus(framebufferName.get(Framebuffer.RESOLVE), GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { return false; } IntBuffer params = GLBuffers.newDirectIntBuffer(1); gl4.glGetNamedFramebufferParameteriv(framebufferName.get(Framebuffer.RENDER), GL_SAMPLES, params); int samples = params.get(0); BufferUtils.destroyDirectBuffer(params); return samples == 4; }
Example #14
Source File: Gl_420_texture_compressed.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, Mat4.SIZE, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }
Example #15
Source File: Gl_330_query_occlusion.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 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(positionBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return checkError(gl3, "initBuffer"); }
Example #16
Source File: Gl_420_sampler_fetch.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, Mat4.SIZE, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }
Example #17
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 #18
Source File: Gl_320_primitive_front_face.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL3 gl3) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); // Generate a buffer object 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 #19
Source File: Gl_420_texture_array.java From jogl-samples with MIT License | 6 votes |
private boolean initSampler(GL4 gl4) { FloatBuffer borderColor = GLBuffers.newDirectFloatBuffer(4); gl4.glGenSamplers(1, samplerName); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); gl4.glSamplerParameterfv(samplerName.get(0), GL_TEXTURE_BORDER_COLOR, borderColor); gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_MIN_LOD, -1000.f); gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_MAX_LOD, 1000.f); gl4.glSamplerParameterf(samplerName.get(0), GL_TEXTURE_LOD_BIAS, 0.0f); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_COMPARE_MODE, GL_NONE); gl4.glSamplerParameteri(samplerName.get(0), GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); BufferUtils.destroyDirectBuffer(borderColor); return checkError(gl4, "initSampler"); }
Example #20
Source File: Es_300_draw_elements.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL3ES3 gl3es3) { FloatBuffer positionBuffer = GLBuffers.newDirectFloatBuffer(positionData); IntBuffer elementBuffer = GLBuffers.newDirectIntBuffer(elementData); gl3es3.glGenBuffers(Buffer.MAX, bufferName); gl3es3.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl3es3.glBufferData(GL_ARRAY_BUFFER, positionSize, positionBuffer, GL_STATIC_DRAW); gl3es3.glBindBuffer(GL_ARRAY_BUFFER, 0); gl3es3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl3es3.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl3es3.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(positionBuffer); BufferUtils.destroyDirectBuffer(elementBuffer); return checkError(gl3es3, "initBuffer"); }
Example #21
Source File: Gl_320_texture_offset.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL3 gl3) { IntBuffer elementBuffer = GLBuffers.newDirectIntBuffer(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 true; }
Example #22
Source File: Gl_420_transform_feedback_instanced.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { IntBuffer elementBuffer = GLBuffers.newDirectIntBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.TRANSFORM_ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.TRANSFORM_VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.FEEDBACK_VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, 2 * 4 * Float.BYTES * elementCount, null, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return true; }
Example #23
Source File: Gl_400_transform_feedback_stream.java From jogl-samples with MIT License | 6 votes |
private boolean initArrayBuffer(GL4 gl4) { IntBuffer elementBuffer = GLBuffers.newDirectIntBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.TRANSFORM_ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.TRANSFORM_ARRAY)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.FEEDBACK)); gl4.glBufferData(GL_ARRAY_BUFFER, 2 * Vec4.SIZE * elementCount, null, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return checkError(gl4, "initArrayBuffer"); }
Example #24
Source File: Gl_400_fbo_layered.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return checkError(gl4, "initBuffer"); }
Example #25
Source File: Gl_410_program_binary.java From jogl-samples with MIT License | 6 votes |
private boolean initBuffer(GL4 gl4) { IntBuffer elementBuffer = GLBuffers.newDirectIntBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); return checkError(gl4, "initBuffer"); }
Example #26
Source File: Gl_420_fbo.java From jogl-samples with MIT License | 5 votes |
private boolean initBuffer(GL4 gl4) { ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); IntBuffer uniformBufferOffset = GLBuffers.newDirectIntBuffer(1); gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); gl4.glGetIntegerv( GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset); int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset.get(0)); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); BufferUtils.destroyDirectBuffer(elementBuffer); BufferUtils.destroyDirectBuffer(vertexBuffer); BufferUtils.destroyDirectBuffer(uniformBufferOffset); return true; }
Example #27
Source File: Gl_450_clip_control.java From jogl-samples with MIT License | 5 votes |
private boolean initBuffer(GL4 gl4) { boolean validated = true; gl4.glGenBuffers(Buffer.MAX, bufferName); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT)); ShortBuffer elementBuffer = GLBuffers.newDirectShortBuffer(elementData); gl4.glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementSize, elementBuffer, GL_STATIC_DRAW); BufferUtils.destroyDirectBuffer(elementBuffer); gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); gl4.glBindBuffer(GL_ARRAY_BUFFER, bufferName.get(Buffer.VERTEX)); FloatBuffer vertexBuffer = GLBuffers.newDirectFloatBuffer(vertexData); gl4.glBufferData(GL_ARRAY_BUFFER, vertexSize, vertexBuffer, GL_STATIC_DRAW); BufferUtils.destroyDirectBuffer(vertexBuffer); gl4.glBindBuffer(GL_ARRAY_BUFFER, 0); int[] uniformBufferOffset = {0}; gl4.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, uniformBufferOffset, 0); int uniformBlockSize = Math.max(Mat4.SIZE, uniformBufferOffset[0]); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); gl4.glBufferData(GL_UNIFORM_BUFFER, uniformBlockSize, null, GL_DYNAMIC_DRAW); gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0); return validated; }
Example #28
Source File: Gl_320_fbo_depth_multisample.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 #29
Source File: Gl_330_sampler_object.java From jogl-samples with MIT License | 5 votes |
private boolean initSampler(GL3 gl3) { FloatBuffer borderColor = GLBuffers.newDirectFloatBuffer(new float[]{0.0f, 0.0f, 0.0f, 0.0f}); gl3.glGenSamplers(Sampler.MAX, samplerName); gl3.glSamplerParameteri(samplerName.get(Sampler.A), GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); gl3.glSamplerParameteri(samplerName.get(Sampler.A), GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glSamplerParameteri(samplerName.get(Sampler.A), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl3.glSamplerParameteri(samplerName.get(Sampler.A), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gl3.glSamplerParameteri(samplerName.get(Sampler.A), GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); gl3.glSamplerParameterfv(samplerName.get(Sampler.A), GL_TEXTURE_BORDER_COLOR, borderColor); gl3.glSamplerParameterf(samplerName.get(Sampler.A), GL_TEXTURE_MIN_LOD, -1000.f); gl3.glSamplerParameterf(samplerName.get(Sampler.A), GL_TEXTURE_MAX_LOD, 1000.f); gl3.glSamplerParameterf(samplerName.get(Sampler.A), GL_TEXTURE_LOD_BIAS, 3.0f); gl3.glSamplerParameteri(samplerName.get(Sampler.A), GL_TEXTURE_COMPARE_MODE, GL_NONE); gl3.glSamplerParameteri(samplerName.get(Sampler.A), GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); gl3.glSamplerParameteri(samplerName.get(Sampler.B), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glSamplerParameteri(samplerName.get(Sampler.B), GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glSamplerParameteri(samplerName.get(Sampler.B), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl3.glSamplerParameteri(samplerName.get(Sampler.B), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gl3.glSamplerParameteri(samplerName.get(Sampler.B), GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); gl3.glSamplerParameterfv(samplerName.get(Sampler.B), GL_TEXTURE_BORDER_COLOR, borderColor); gl3.glSamplerParameterf(samplerName.get(Sampler.B), GL_TEXTURE_MIN_LOD, -1000.f); gl3.glSamplerParameterf(samplerName.get(Sampler.B), GL_TEXTURE_MAX_LOD, 1000.f); gl3.glSamplerParameterf(samplerName.get(Sampler.B), GL_TEXTURE_LOD_BIAS, 3.0f); gl3.glSamplerParameteri(samplerName.get(Sampler.B), GL_TEXTURE_COMPARE_MODE, GL_NONE); gl3.glSamplerParameteri(samplerName.get(Sampler.B), GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); BufferUtils.destroyDirectBuffer(borderColor); return true; }
Example #30
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"); }