Java Code Examples for com.jogamp.opengl.GL4#glDrawArraysInstancedBaseInstance()
The following examples show how to use
com.jogamp.opengl.GL4#glDrawArraysInstancedBaseInstance() .
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_texture_fetch_dependent.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.DIFFUSE)); gl4.glActiveTexture(GL_TEXTURE1); gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.INDIRECTION)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); return true; }
Example 2
Source File: Gl_420_draw_image_space_rendering.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl4.glBindSampler(0, samplerName.get(0)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); return true; }
Example 3
Source File: Gl_500_shader_invocation_nv.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glClearBufferfv(GL_COLOR, 0, white); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.CONSTANT, bufferName.get(Buffer.CONSTANT)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 6 * vertexCount, 1, 0); return true; }
Example 4
Source File: Gl_440_atomic_counter.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bufferName.get(Buffer.ATOMIC_COUNTER)); int[] data = {0}; IntBuffer dataBuffer = GLBuffers.newDirectIntBuffer(data); gl4.glClearBufferSubData(GL_ATOMIC_COUNTER_BUFFER, GL_R8UI, 0, Integer.BYTES, GL_RGBA, GL_UNSIGNED_INT, dataBuffer); BufferUtils.destroyDirectBuffer(dataBuffer); gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, bufferName.get(Buffer.ATOMIC_COUNTER)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); return true; }
Example 5
Source File: Gl_430_texture_copy.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { Mat4 model = new Mat4(1.0f); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); pointer.asFloatBuffer().put(mvp.toFa_()); gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl4.glViewportIndexedfv(0, new float[]{0, 0, windowSize.x, windowSize.y}, 0); gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COPY)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, vertexCount, 1, 0); return true; }
Example 6
Source File: Gl_430_draw_without_vertex_attrib.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspectiveFov_((float) Math.PI * 0.25f, windowSize.x, windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); projection.mul(viewMat4()).mul(model).toDbb(pointer); // Make sure the uniform buffer is uploaded gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0.0f).put(1, 0.0f).put(2, 0.0f).put(3, 1.0f)); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, bufferName.get(Buffer.VERTEX)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 6, 1, 0); return true; }
Example 7
Source File: Gl_430_image_store.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glDrawBuffer(GL_BACK); gl4.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.5f, 1.0f, 1.0f}, 0); // Renderer to image { gl4.glDrawBuffer(GL_NONE); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SAVE)); gl4.glBindImageTexture(Semantic.Image.DIFFUSE, textureName.get(0), 0, false, 0, GL_WRITE_ONLY, GL_RGBA8); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); } // Read from image { gl4.glDrawBuffer(GL_BACK); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.READ)); gl4.glBindImageTexture(Semantic.Image.DIFFUSE, textureName.get(0), 0, false, 0, GL_READ_ONLY, GL_RGBA8); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); } return true; }
Example 8
Source File: Gl_430_interface_matching.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); { gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl4.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); pointer.asFloatBuffer().put(mvp.toFa_()); // Make sure the uniform buffer is uploaded gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl4.glViewportIndexedfv(0, new float[]{0, 0, windowSize.x, windowSize.y}, 0); gl4.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.0f, 0.0f, 0.0f}, 0); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glPatchParameteri(GL_PATCH_VERTICES, vertexCount); assert (!validate(gl4, programName[Program.VERT])); gl4.glDrawArraysInstancedBaseInstance(GL_PATCHES, 0, vertexCount, 1, 0); return true; }
Example 9
Source File: Gl_440_interface_matching.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); { gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(new Mat4(1.0f)).toFa_()); // Make sure the uniform buffer is uploaded gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl4.glViewportIndexedfv(0, new float[]{0, 0, windowSize.x, windowSize.y}, 0); gl4.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.0f, 0.0f, 0.0f}, 0); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glPatchParameteri(GL_PATCH_VERTICES, vertexCount); assert (!validate(gl4, programName[Program.VERT])); gl4.glDrawArraysInstancedBaseInstance(GL_PATCHES, 0, vertexCount, 1, 0); return true; }
Example 10
Source File: Gl_430_fbo_without_attachment.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glBindSampler(0, samplerName.get(0)); // Render gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.RENDER)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl4.glBindImageTexture(Semantic.Image.DIFFUSE, textureName.get(Texture.COLORBUFFER), 0, false, 0, GL_WRITE_ONLY, GL_RGBA8); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); // Splash gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); return true; }
Example 11
Source File: Gl_420_texture_cube.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl4.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Transform.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 1000.0f); Mat4 view = viewMat4(); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(view).mul(model); Mat4 mv = view.mul(model); Transform transform = new Transform(mvp, mv, new Vec3(0.0f, 0.0f, -cameraDistance())); transform.toDbb(pointer); // Make sure the uniform buffer is uploaded gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1.0f).put(1, 1.0f).put(2, 1.0f).put(3, 1.0f)); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textureName.get(0)); gl4.glBindSampler(0, samplerName.get(0)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, vertexCount, 1, 0); return true; }
Example 12
Source File: Gl_420_memory_barrier.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; // Bind shared objects gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindSampler(0, samplerName.get(0)); gl4.glBindVertexArray(vertexArrayName.get(0)); // Update a colorbuffer bound as a framebuffer attachement and as a texture gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.UPDATE)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, frameIndex != 0 ? textureName.get(Texture.COLORBUFFER) : textureName.get(Texture.DIFFUSE)); gl4.glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT | GL_TEXTURE_FETCH_BARRIER_BIT); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, vertexCount, 1, 0); // Blit to framebuffer gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.BLIT)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl4.glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, vertexCount, 1, 0); frameIndex = (frameIndex + 1) % 256; return true; }
Example 13
Source File: Gl_420_primitive_line_aa.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl4.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspectiveFov_((float) Math.PI * 0.25f, windowSize.x, windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); projection.mul(viewMat4()).mul(model).toDbb(pointer); // Make sure the uniform buffer is uploaded gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } ////////////////////////////// // Render multisampled texture //glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.MULTISAMPLE)); //glEnable(GL_MULTISAMPLE); gl4.glViewportIndexedf(0, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 0.5f).put(2, 0).put(3, 1)); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.MULTISAMPLE)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.MULTISAMPLE)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glDrawArraysInstancedBaseInstance(GL_LINE_LOOP, 0, vertexData.length, 3, 0); ////////////////////////// // Resolving multisampling gl4.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferName.get(Framebuffer.MULTISAMPLE)); gl4.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferName.get(Framebuffer.COLOR)); gl4.glBlitFramebuffer( 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, GL_COLOR_BUFFER_BIT, GL_NEAREST); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); ////////////////////////////////////// // Render resolved multisample texture gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); //glDisable(GL_MULTISAMPLE); gl4.glActiveTexture(GL_TEXTURE0); //glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, TextureName[texture::MULTISAMPLE]); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLOR)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.SPLASH)); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 6, 1, 0); return true; }
Example 14
Source File: Gl_500_texture_cube_arb.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, windowSize.x * 0.5f / windowSize.y, 0.1f, 1000.0f); Mat4 view = viewMat4(); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(view).mul(model); Mat4 mv = view.mul(model); Transform t = new Transform(mvp, mv, new Vec3(0.0f, 0.0f, -cameraDistance())); transformPointer.asFloatBuffer().put(t.toFa_()); } gl4.glClearBufferfv(GL_COLOR, 0, white); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindTextures(Semantic.Sampler.DIFFUSE, 1, textureName); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindVertexArray(vertexArrayName.get(0)); // Left side: seamless cubemap filtering gl4.glViewportIndexedf(0, 0, 0, windowSize.x * 0.5f, windowSize.y); samplerName.position(Sampler.SEAMLESS); gl4.glBindSamplers(Semantic.Sampler.DIFFUSE, 1, samplerName); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, vertexCount, 1, 0); // Right side: per face cubemap filtering gl4.glViewportIndexedf(0, windowSize.x * 0.5f, 0, windowSize.x * 0.5f, windowSize.y); samplerName.position(Sampler.NON_SEAMLESS); gl4.glBindSamplers(Semantic.Sampler.DIFFUSE, 1, samplerName); samplerName.rewind(); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, vertexCount, 1, 0); return true; }
Example 15
Source File: Gl_500_conservative_raster_nv.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { ByteBuffer pointer = gl4.glMapNamedBufferRange(bufferName.get(Buffer.TRANSFORM), 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl4.glUnmapNamedBuffer(bufferName.get(Buffer.TRANSFORM)); } gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl4.glViewportIndexedf(0, 0, 0, windowSize.x / 16.0f, windowSize.y / 16.0f); gl4.glClearBufferfv(GL_COLOR, 0, whiteColor); // Bind rendering objects gl4.glViewportIndexedf(0, 0, 0, windowSize.x / 16.0f, windowSize.y / 16.0f); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.TEXTURE)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.TEXTURE)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.MATERIAL, bufferName.get(Buffer.MATERIAL0)); //glSubpixelPrecisionBiasNV(-8, -8); gl4.glEnable(GL_CONSERVATIVE_RASTERIZATION_NV); gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.MATERIAL, bufferName.get(Buffer.MATERIAL1)); gl4.glDisable(GL_CONSERVATIVE_RASTERIZATION_NV); gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.SPLASH)); gl4.glBindTextureUnit(0, textureName.get(Texture.COLORBUFFER)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); return true; }
Example 16
Source File: Gl_430_fbo_invalidate.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl4.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspectiveFov_((float) Math.PI * 0.25f, windowSize.x, windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); projection.mul(viewMat4()).mul(model).toDbb(pointer); // Make sure the uniform buffer is uploaded gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } ////////////////////////////// // Render multisampled texture gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.MULTISAMPLE)); gl4.glViewportIndexedf(0, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1.0f).put(1, 0.5f).put(2, 0.0f).put(3, 1.0f)); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.MULTISAMPLE)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.MULTISAMPLE)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glEnable(GL_MULTISAMPLE); { gl4.glDrawArraysInstancedBaseInstance(GL_LINE_LOOP, 0, vertexData.length / 2, 3, 0); } gl4.glDisable(GL_MULTISAMPLE); ////////////////////////// // Resolving multisampling gl4.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferName.get(Framebuffer.MULTISAMPLE)); gl4.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferName.get(Framebuffer.COLOR)); gl4.glBlitFramebuffer( 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, GL_COLOR_BUFFER_BIT, GL_NEAREST); int[] attachments = {GL_COLOR_ATTACHMENT0}; gl4.glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 1, attachments, 0); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); ////////////////////////////////////// // Render resolved multisample texture gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); //glDisable(GL_MULTISAMPLE); gl4.glActiveTexture(GL_TEXTURE0); //glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, TextureName[texture::MULTISAMPLE]); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLOR)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.SPLASH)); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 6, 1, 0); return true; }
Example 17
Source File: Gl_500_shader_group_nv.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { ByteBuffer pointer = gl4.glMapNamedBufferRange(bufferName.get(Buffer.TRANSFORM), 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl4.glUnmapNamedBuffer(bufferName.get(Buffer.TRANSFORM)); } gl4.glEnable(GL_DEPTH_TEST); gl4.glDepthFunc(GL_LESS); gl4.glClearTexImage(textureName.get(Texture.COLORBUFFER), 0, GL_RGBA, GL_UNSIGNED_BYTE, clearColorBuffer); gl4.glClearTexImage(textureName.get(Texture.RENDERBUFFER), 0, GL_DEPTH_COMPONENT, GL_FLOAT, clearRenderBuffer); gl4.glClearTexImage(textureName.get(Texture.INVOCATION_COUNT), 0, GL_RED_INTEGER, GL_UNSIGNED_INT, clearInvocationCount); gl4.glViewportIndexedf(0, 0, 0, windowSize.x * FRAMEBUFFER_SCALE, windowSize.y * FRAMEBUFFER_SCALE); gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.TEXTURE)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.TEXTURE)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glBindImageTexture(0, textureName.get(Texture.INVOCATION_COUNT), 0, false, 0, GL_WRITE_ONLY, GL_R32UI); gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 5, 0, 0); gl4.glDisable(GL_DEPTH_TEST); gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.SPLASH)); gl4.glBindImageTexture(0, textureName.get(Texture.INVOCATION_COUNT), 0, false, 0, GL_READ_ONLY, GL_R32UI); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); return true; }
Example 18
Source File: Gl_440_fbo_without_attachment.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName[Buffer.TRANSFORM]); ByteBuffer pointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspectiveFov_((float) Math.PI * 0.25f, windowSize.x, windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } // Render FloatBuffer clearBuffer = GLBuffers.newDirectFloatBuffer(new float[]{1.0f, 0.5f, 0.0f, 1.0f}); gl4.glClearTexImage(textureName[Texture.COLORBUFFER], 0, GL_RGBA, GL_FLOAT, clearBuffer); BufferUtils.destroyDirectBuffer(clearBuffer); gl4.glViewportIndexedf(0, 0, 0, windowSize.x * supersampling, windowSize.y * supersampling); gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName[0]); gl4.glBindSampler(0, samplerName[Pipeline.RENDER]); gl4.glBindVertexArray(vertexArrayName[Pipeline.RENDER]); gl4.glBindProgramPipeline(pipelineName[Pipeline.RENDER]); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName[Texture.DIFFUSE]); gl4.glBindImageTexture(Semantic.Image.DIFFUSE, textureName[Texture.COLORBUFFER], 0, false, 0, GL_WRITE_ONLY, GL_RGBA8); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName[Buffer.TRANSFORM]); gl4.glBindBufferBase(GL_SHADER_STORAGE_BUFFER, Semantic.Storage.VERTEX, bufferName[Buffer.VERTEX]); gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0); // Splash gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glBindSampler(0, samplerName[Pipeline.SPLASH]); gl4.glBindVertexArray(vertexArrayName[Pipeline.SPLASH]); gl4.glBindProgramPipeline(pipelineName[Pipeline.SPLASH]); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName[Texture.COLORBUFFER]); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); return true; }
Example 19
Source File: Gl_420_fbo.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; { gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl4.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); //glm::mat4 Projection = glm::perspectiveFov(glm::pi<float>() * 0.25f, 640.f, 480.f, 0.1f, 100.0f); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); projection.mul(viewMat4()).mul(model).toDbb(pointer); // Make sure the uniform buffer is uploaded gl4.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl4.glEnable(GL_DEPTH_TEST); gl4.glDepthFunc(GL_LESS); gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y); gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0, 1)); gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 0.5f).put(2, 0).put(3, 1)); // Bind rendering objects gl4.glBindProgramPipeline(pipelineName.get(Pipeline.TEXTURE)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.TEXTURE)); gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0, 0); gl4.glDisable(GL_DEPTH_TEST); gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH)); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindVertexArray(vertexArrayName.get(Pipeline.SPLASH)); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0); return true; }
Example 20
Source File: Gl_410_primitive_tessellation2.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL4 gl4 = (GL4) gl; gl4.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); gl4.glProgramUniformMatrix4fv(programName[Program.VERT], uniformMvp, 1, false, mvp.toFa_(), 0); gl4.glViewportIndexedfv(0, viewportBuffer.put(0, 0).put(1, 0).put(2, windowSize.x).put(3, windowSize.y)); gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 0)); gl4.glBindProgramPipeline(pipelineName.get(0)); gl4.glBindVertexArray(vertexArrayName.get(0)); gl4.glPatchParameteri(GL_PATCH_VERTICES, vertexCount); gl4.glDrawArraysInstancedBaseInstance(GL_PATCHES, 0, vertexCount, 1, 0); return true; }