Java Code Examples for com.jogamp.opengl.GL4#glMinSampleShading()

The following examples show how to use com.jogamp.opengl.GL4#glMinSampleShading() . 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_direct_state_access_ext.java    From jogl-samples with MIT License 6 votes vote down vote up
private void renderFBO(GL4 gl4) {
    //glEnable(GL_SAMPLE_MASK);
    //glSampleMaski(0, 0xFF);

    gl4.glEnable(GL_MULTISAMPLE);
    gl4.glEnable(GL_SAMPLE_SHADING);
    gl4.glMinSampleShading(4 / 4.0f);

    gl4.glViewportIndexedf(0, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y);
    gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1.0f).put(1, 1.0f).put(2, 1.0f).put(3, 1.0f));

    gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
            uniformBlockSize);
    gl4.glBindSampler(0, samplerName.get(0));
    gl4.glBindTextureUnit(0, textureName.get(Texture.TEXTURE));
    gl4.glBindVertexArray(vertexArrayName.get(0));

    gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);

    gl4.glDisable(GL_MULTISAMPLE);
}
 
Example 2
Source File: Gl_450_direct_state_access.java    From jogl-samples with MIT License 6 votes vote down vote up
private void renderFBO(GL4 gl4) {

        gl4.glEnable(GL_MULTISAMPLE);
        gl4.glEnable(GL_SAMPLE_SHADING);
        gl4.glMinSampleShading(4 / 4.0f);

        gl4.glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
        gl4.glViewportIndexedf(0, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y);

        gl4.glClearNamedFramebufferfv(framebufferName.get(Framebuffer.RENDER), GL_COLOR, 0, clearColor);

        gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
        gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
                uniformBlockSize);
        gl4.glBindSamplers(0, 1, samplerName);
        gl4.glBindTextureUnit(0, textureName.get(Texture.TEXTURE));
        gl4.glBindVertexArray(vertexArrayName.get(0));

        gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);

        gl4.glDisable(GL_MULTISAMPLE);
    }
 
Example 3
Source File: Gl_450_texture_derivative.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
protected boolean begin(GL gl) {

    GL4 gl4 = (GL4) gl;

    boolean validated = gl4.isExtensionAvailable("GL_ARB_derivative_control");

    if (validated) {
        validated = initBuffer(gl4);
    }
    if (validated) {
        validated = initTexture(gl4);
    }
    if (validated) {
        validated = initProgram(gl4);
    }
    if (validated) {
        validated = initVertexArray(gl4);
    }

    gl4.glEnable(GL_SAMPLE_SHADING);
    gl4.glMinSampleShading(0.0f);

    return validated;
}
 
Example 4
Source File: Gl_500_direct_state_access_gtc.java    From jogl-samples with MIT License 6 votes vote down vote up
private void renderFBO(GL4 gl4) {

        gl4.glEnable(GL_MULTISAMPLE);
        gl4.glEnable(GL_SAMPLE_SHADING);
        gl4.glMinSampleShading(4.0f);

        gl4.glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
        gl4.glViewportIndexedf(0, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y);
        FloatBuffer clear = GLBuffers.newDirectFloatBuffer(new float[]{0.0f, 0.5f, 1.0f, 1.0f});
        gl4.glClearNamedFramebufferfv(framebufferName.get(Framebuffer.RENDER), GL_COLOR, 0, clear);

        gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
        gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
                uniformBlockSize);
        gl4.glBindSamplers(0, 1, samplerName);
        gl4.glBindTextureUnit(0, textureName.get(Texture.TEXTURE));
        gl4.glBindVertexArray(vertexArrayName.get(0));

        gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);

        gl4.glDisable(GL_MULTISAMPLE);
    }
 
Example 5
Source File: Gl_400_fbo_multisample.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
    gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0);

    gl4.glUseProgram(programName);
    gl4.glUniform1i(uniformDiffuse, 0);

    // Pass 1, render the scene in a multisampled framebuffer
    gl4.glEnable(GL_MULTISAMPLE);
    gl4.glEnable(GL_SAMPLE_SHADING);
    gl4.glMinSampleShading(4 / 2.0f);

    float[] min = {0};
    gl4.glGetFloatv(GL_MIN_SAMPLE_SHADING_VALUE, min, 0);
    //glEnable(GL_SAMPLE_MASK);
    //glSampleMaski(0, 0xFF);
    renderFBO(gl4, framebufferName.get(Framebuffer.RENDER));
    gl4.glDisable(GL_MULTISAMPLE);

    // Resolved multisampling
    gl4.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
    gl4.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE));
    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);

    // Pass 2, render the colorbuffer from the multisampled framebuffer
    gl4.glViewport(0, 0, windowSize.x, windowSize.y);
    renderFB(gl4, textureName.get(Texture.COLOR));

    return true;
}