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

The following examples show how to use com.jogamp.opengl.GL4#glEnable() . 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_400_primitive_instanced.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 = true;

    gl4.glEnable(GL_DEPTH_TEST);

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

    return validated && checkError(gl4, "begin");
}
 
Example 2
Source File: Gl_420_transform_feedback_instanced.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 = true;

    gl4.glEnable(GL_DEPTH_TEST);

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

    return validated;
}
 
Example 3
Source File: Gl_410_primitive_instanced.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 = true;

    if (validated) {
        validated = initProgram(gl4);
    }
    if (validated) {
        validated = initVertexBuffer(gl4);
    }
    if (validated) {
        validated = initVertexArray(gl4);
    }

    gl4.glEnable(GL_DEPTH_TEST);

    return validated;
}
 
Example 4
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 5
Source File: Gl_430_multi_draw_indirect.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
protected boolean begin(GL gl) {

    GL4 gl4 = (GL4) gl;

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

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

    viewport[0] = new Vec4i((int) (windowSize.x / 3.0f * 0.0f), 0, windowSize.x / 3, windowSize.y);
    viewport[1] = new Vec4i((int) (windowSize.x / 3.0f * 1.0f), 0, windowSize.x / 3, windowSize.y);
    viewport[2] = new Vec4i((int) (windowSize.x / 3.0f * 2.0f), 0, windowSize.x / 3, windowSize.y);

    gl4.glEnable(GL_DEPTH_TEST);
    gl4.glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);

    return validated;
}
 
Example 6
Source File: OpenGLUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static void setQuality(PGraphics pg, int quality) {
		//		pg.hint(p.DISABLE_DEPTH_SORT);
		GL4 gl = getGL4(pg);
//		GL gl = ((PJOGL)pg.beginPGL()).gl.getGL();
		switch ( quality ) {
			case GL_QUALITY_LOW :
//				p.hint(P.DISABLE_OPENGL_2X_SMOOTH);
				gl.glHint (GL4.GL_LINE_SMOOTH_HINT, GL4.GL_FASTEST);
				gl.glHint (GL4.GL_POINT, GL.GL_FASTEST);
				gl.glHint (GL4.GL_POLYGON_SMOOTH_HINT, GL.GL_FASTEST);
//				gl.glHint (GL.GL_POLYGON_SMOOTH_HINT, GL.GL_FASTEST);
				gl.glDisable(GL4.GL_LINE_SMOOTH);
				break;
			case GL_QUALITY_MEDIUM :
//				p.hint(P.ENABLE_OPENGL_2X_SMOOTH);
				gl.glHint (GL4.GL_LINE_SMOOTH_HINT, GL4.GL_FASTEST);
//				gl.glHint (GL4.GL_POINT_SMOOTH_HINT, GL4.GL_FASTEST);
				gl.glHint (GL4.GL_POLYGON_SMOOTH_HINT, GL4.GL_FASTEST);
				gl.glDisable(GL4.GL_LINE_SMOOTH);
				break;
			case GL_QUALITY_HIGH :
				gl.glHint (GL4.GL_LINE_SMOOTH_HINT, GL4.GL_NICEST);
//				gl.glHint (GL4.GL_POINT_SMOOTH_HINT, GL4.GL_NICEST);
				gl.glHint (GL4.GL_POLYGON_SMOOTH, GL4.GL_NICEST);
				gl.glEnable (GL4.GL_LINE_SMOOTH);
				break;
		}
	}
 
Example 7
Source File: Gl_420_image_store.java    From jogl-samples with MIT License 5 votes vote down vote up
@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, clearColor.put(0, 0).put(1, 0.5f).put(2, 1).put(3, 1));

    // 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
    {
        int border = 8;
        gl4.glEnable(GL_SCISSOR_TEST);
        gl4.glScissorIndexed(0, border, border, (windowSize.x - 2) * border, (windowSize.y - 2) * border);

        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);

        gl4.glDisable(GL_SCISSOR_TEST);
    }

    return true;
}
 
Example 8
Source File: Gl_400_texture_derivative.java    From jogl-samples with MIT License 4 votes vote down vote up
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    Vec2i framebufferSize = new Vec2i(windowSize.x / FRAMEBUFFER_SIZE, windowSize.y / FRAMEBUFFER_SIZE);

    // Update of the uniform buffer
    {
        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);

        pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_());

        // Make sure the uniform buffer is uploaded
        gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
    }

    gl4.glEnable(GL_DEPTH_TEST);
    gl4.glDepthFunc(GL_LESS);

    gl4.glViewport(0, 0, framebufferSize.x, framebufferSize.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, 0).put(1, 0).put(2, 0).put(3, 1));

    gl4.glUseProgram(programName[Program.TEXTURE]);
    gl4.glUniform1i(uniformDiffuse[Program.TEXTURE], 0);
    gl4.glUniformBlockBinding(programName[Program.TEXTURE], uniformTransform,
            Semantic.Uniform.TRANSFORM0);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
    gl4.glBindVertexArray(vertexArrayName.get(Program.TEXTURE));
    gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));

    gl4.glEnable(GL_SCISSOR_TEST);
    {
        gl4.glScissor(0, 0, framebufferSize.x / 2, framebufferSize.y);
        gl4.glUniform1i(uniformUseGrad, 1);
        gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0);

        gl4.glScissor(framebufferSize.x / 2, 0, framebufferSize.x / 2, framebufferSize.y);
        gl4.glUniform1i(uniformUseGrad, 0);
        gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0);
    }
    gl4.glDisable(GL_SCISSOR_TEST);

    gl4.glDisable(GL_DEPTH_TEST);
    gl4.glViewport(0, 0, windowSize.x, windowSize.y);
    gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
    gl4.glUseProgram(programName[Program.SPLASH]);
    gl4.glUniform1i(uniformDiffuse[Program.SPLASH], 0);
    gl4.glUniform1f(uniformFramebufferSize, FRAMEBUFFER_SIZE);

    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindVertexArray(vertexArrayName.get(Program.SPLASH));
    gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));

    gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1);

    return true;
}
 
Example 9
Source File: Gl_400_transform_feedback_object.java    From jogl-samples with MIT License 4 votes vote down vote up
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    // Compute the MVP (Model View Projection matrix)
    {
        gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM0));
        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);
        Mat4 model = new Mat4(1.0f);

        pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_());

        gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
    }

    // Set the display viewport
    gl4.glViewport(0, 0, windowSize.x, windowSize.y);

    // Clear color buffer
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 1));

    // First draw, capture the attributes
    // Disable rasterisation, vertices processing only!
    gl4.glEnable(GL_RASTERIZER_DISCARD);

    gl4.glUseProgram(transformProgramName);

    gl4.glBindVertexArray(vertexArrayName.get(VertexArray.TRANSFORM_FEEDBACK));
    gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM0));

    gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedbackName.get(0));
    gl4.glBeginTransformFeedback(GL_TRIANGLES);
    gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
    gl4.glEndTransformFeedback();
    gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);

    gl4.glDisable(GL_RASTERIZER_DISCARD);

    // Second draw, reuse the captured attributes
    gl4.glUseProgram(feedbackProgramName);

    gl4.glBindVertexArray(vertexArrayName.get(VertexArray.FEEDBACK));
    gl4.glDrawTransformFeedback(GL_TRIANGLES, feedbackName.get(0));

    return true;
}
 
Example 10
Source File: Gl_500_conservative_raster_nv.java    From jogl-samples with MIT License 4 votes vote down vote up
@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 11
Source File: Gl_450_transform_feedback_arb.java    From jogl-samples with MIT License 4 votes vote down vote up
@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);

        uniformPointer.asFloatBuffer().put(mvp.toFa_());
    }

    // Set the display viewport
    gl4.glViewportIndexedf(0, 0.0f, 0.0f, windowSize.x, windowSize.y);

    // Clear color buffer
    gl4.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.0f, 0.0f, 1.0f}, 0);

    // First draw, capture the attributes
    // Disable rasterisation, vertices processing only!
    gl4.glEnable(GL_RASTERIZER_DISCARD);

    gl4.glBindProgramPipeline(pipelineName.get(Program.TRANSFORM));
    gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
    gl4.glBindVertexArray(vertexArrayName.get(Program.TRANSFORM));
    gl4.glBindVertexBuffer(Semantic.Buffer.STATIC, bufferName.get(Buffer.VERTEX), 0, Vec4.SIZE);

    gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedbackName.get(0));

    gl4.glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, 0, queryName.get(0));
    gl4.glBeginTransformFeedback(GL_TRIANGLES);
    {
        gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
    }
    gl4.glEndTransformFeedback();
    gl4.glEndQueryIndexed(GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, 0);

    gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);

    gl4.glDisable(GL_RASTERIZER_DISCARD);

    IntBuffer streamOverflow = GLBuffers.newDirectIntBuffer(1);
    gl4.glGetQueryObjectuiv(queryName.get(0), GL_QUERY_RESULT, streamOverflow);

    if (streamOverflow.get(0) == 0) {

        // Second draw, reuse the captured attributes
        gl4.glBindProgramPipeline(pipelineName.get(Program.FEEDBACK));
        gl4.glBindVertexArray(vertexArrayName.get(Program.FEEDBACK));
        gl4.glBindVertexBuffer(Semantic.Buffer.STATIC, bufferName.get(Buffer.FEEDBACK), 0, glf.Vertex_v4fc4f.SIZE);

        gl4.glDrawTransformFeedback(GL_TRIANGLES, feedbackName.get(0));
    }
    BufferUtils.destroyDirectBuffer(streamOverflow);
    
    return true;
}
 
Example 12
Source File: Gl_430_atomic_counter.java    From jogl-samples with MIT License 4 votes vote down vote up
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    // Setup blending
    gl4.glEnable(GL_BLEND);
    gl4.glBlendEquation(GL_FUNC_ADD);
    gl4.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    {
        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);
        Mat4 model = new Mat4(1.0f);
        Mat4 mvp = projection.mul(viewMat4()).mul(model);

        mvp.toDbb(pointer);

        gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
    }

    IntBuffer data = IntBuffer.wrap(new int[]{0});
    gl4.glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bufferName.get(Buffer.ATOMIC_COUNTER));
    gl4.glClearBufferSubData(GL_ATOMIC_COUNTER_BUFFER, GL_R8UI, 0, Integer.BYTES, GL_RGBA, GL_UNSIGNED_INT, data);

    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.glBindVertexArray(vertexArrayName.get(0));
    gl4.glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, bufferName.get(Buffer.ATOMIC_COUNTER));
    gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));

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

    return true;
}
 
Example 13
Source File: Gl_500_shader_group_nv.java    From jogl-samples with MIT License 4 votes vote down vote up
@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 14
Source File: Gl_430_debug.java    From jogl-samples with MIT License 4 votes vote down vote up
private boolean initDebug(GL4 gl4) {

        boolean validated = true;

        gl4.glEnable(GL_DEBUG_OUTPUT);
        gl4.glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
        gl4.glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, null, true);
//		gl4.glDebugMessageCallback(&test::debugOutput, this);

        gl4.glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Message test: Begin".getBytes(), 0);

        int[] messageId = {4};
        gl4.glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, null, FALSE);
        gl4.glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, GL_DONT_CARE, 0, null, true);
        gl4.glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, GL_DONT_CARE, 1, messageId, 0, false);
        String message1 = "Message 1";
        gl4.glDebugMessageInsert(
                GL_DEBUG_SOURCE_APPLICATION,
                GL_DEBUG_TYPE_OTHER, 1,
                GL_DEBUG_SEVERITY_MEDIUM,
                message1.length(), message1);
        String message2 = "Message 2";
        gl4.glDebugMessageInsert(
                GL_DEBUG_SOURCE_THIRD_PARTY,
                GL_DEBUG_TYPE_OTHER, 2,
                GL_DEBUG_SEVERITY_MEDIUM,
                message2.length(), message2);
        gl4.glDebugMessageInsert(
                GL_DEBUG_SOURCE_APPLICATION,
                GL_DEBUG_TYPE_OTHER, 2,
                GL_DEBUG_SEVERITY_MEDIUM,
                -1, "Message 3");
        gl4.glDebugMessageInsert(
                GL_DEBUG_SOURCE_APPLICATION,
                GL_DEBUG_TYPE_OTHER, messageId[0],
                GL_DEBUG_SEVERITY_MEDIUM,
                -1, "Message 4");

        gl4.glPopDebugGroup();

        return validated;
    }
 
Example 15
Source File: Gl_420_debug_output.java    From jogl-samples with MIT License 4 votes vote down vote up
private boolean initDebugOutput(GL4 gl4) {

        if (useJoglUtils) {
            glWindow.getContext().enableGLDebugMessage(true);
            glWindow.getContext().setGLDebugSynchronous(true);
        } else {
//        gl4.glDisable(GL_DEBUG_OUTPUT);
            gl4.glEnable(GL_DEBUG_OUTPUT);
            gl4.glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
        }
        // from the constructor.
        System.out.println("isGLDebugEnabled " + glWindow.getContext().isGLDebugEnabled());
        // from enableGLDebugMessage()
        System.out.println("isGLDebugMessageEnabled " + glWindow.getContext().isGLDebugMessageEnabled());
        // from setGLDebugSynchronous
        System.out.println("isGLDebugSynchronous " + glWindow.getContext().isGLDebugSynchronous());

        glWindow.getContext().addGLDebugListener(new GlDebugOutput());

        if (useJoglUtils) {
            glWindow.getContext().glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, null, 0, true);
        } else {
            gl4.glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, null, 0, true);
        }

        IntBuffer messageId = GLBuffers.newDirectIntBuffer(new int[]{4});
        if (useJoglUtils) {
            glWindow.getContext().glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER,
                    GL_DONT_CARE, 0, null, true);
            glWindow.getContext().glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER,
                    GL_DONT_CARE, 1, messageId, false);
        } else {
            gl4.glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, GL_DONT_CARE, 0, null, 0, true);
            gl4.glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER,
                    GL_DONT_CARE, 1, messageId, false);
        }

        String message1 = "Message 1";
        if (useJoglUtils) {
            glWindow.getContext().glDebugMessageInsert(
                    GL_DEBUG_SOURCE_APPLICATION,
                    GL_DEBUG_TYPE_OTHER, 1,
                    GL_DEBUG_SEVERITY_MEDIUM,
                    message1);
        } else {
            gl4.glDebugMessageInsert(
                    GL_DEBUG_SOURCE_APPLICATION,
                    GL_DEBUG_TYPE_OTHER, 1,
                    GL_DEBUG_SEVERITY_MEDIUM,
                    message1.length(), message1);
        }
        String message2 = "Message 2";
        if (useJoglUtils) {
            glWindow.getContext().glDebugMessageInsert(
                    GL_DEBUG_SOURCE_THIRD_PARTY,
                    GL_DEBUG_TYPE_OTHER, 2,
                    GL_DEBUG_SEVERITY_MEDIUM,
                    message2);
        } else {
            gl4.glDebugMessageInsert(
                    GL_DEBUG_SOURCE_THIRD_PARTY,
                    GL_DEBUG_TYPE_OTHER, 2,
                    GL_DEBUG_SEVERITY_MEDIUM,
                    message2.length(), message2);
        }
        if (useJoglUtils) {
            glWindow.getContext().glDebugMessageInsert(
                    GL_DEBUG_SOURCE_APPLICATION,
                    GL_DEBUG_TYPE_OTHER, 2,
                    GL_DEBUG_SEVERITY_MEDIUM,
                    "Message 3");
        } else {
            gl4.glDebugMessageInsert(
                    GL_DEBUG_SOURCE_APPLICATION,
                    GL_DEBUG_TYPE_OTHER, 2,
                    GL_DEBUG_SEVERITY_MEDIUM,
                    -1, "Message 3");
        }
        if (useJoglUtils) {
            glWindow.getContext().glDebugMessageInsert(
                    GL_DEBUG_SOURCE_APPLICATION,
                    GL_DEBUG_TYPE_OTHER, messageId.get(0),
                    GL_DEBUG_SEVERITY_MEDIUM,
                    "Message 4");
        } else {
            gl4.glDebugMessageInsert(
                    GL_DEBUG_SOURCE_APPLICATION,
                    GL_DEBUG_TYPE_OTHER, messageId.get(0),
                    GL_DEBUG_SEVERITY_MEDIUM,
                    -1, "Message 4");
        }

        BufferUtils.destroyDirectBuffer(messageId);

        return true;
    }
 
Example 16
Source File: Gl_420_transform_feedback_instanced.java    From jogl-samples with MIT License 4 votes vote down vote up
@Override
protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    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);

    gl4.glProgramUniformMatrix4fv(programName[Pipeline.TRANSFORM], transformUniformMvp, 1, false, mvp.toFa_(), 0);
    gl4.glProgramUniformMatrix4fv(programName[Pipeline.FEEDBACK], feedbackUniformMvp, 1, false, mvp.toFa_(), 0);

    gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y);

    gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0, 1.0f));
    gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0.0f).put(1, 0.0f).put(2, 0.0f).put(3, 1.0f));

    // First draw, capture the attributes
    // Disable rasterisation, vertices processing only!
    gl4.glEnable(GL_RASTERIZER_DISCARD);

    gl4.glBindProgramPipeline(pipelineName.get(Pipeline.TRANSFORM));
    gl4.glBindVertexArray(vertexArrayName.get(Pipeline.TRANSFORM));

    gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedbackName.get(0));
    gl4.glBeginTransformFeedback(GL_TRIANGLES);
    {
        gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0, 1, 0);
    }
    gl4.glEndTransformFeedback();

    gl4.glDisable(GL_RASTERIZER_DISCARD);

    // Second draw, reuse the captured attributes
    gl4.glBindProgramPipeline(pipelineName.get(Pipeline.FEEDBACK));
    gl4.glBindVertexArray(vertexArrayName.get(Pipeline.FEEDBACK));

    gl4.glDrawTransformFeedbackStreamInstanced(GL_TRIANGLE_STRIP, feedbackName.get(0), 0, 5);

    return true;
}
 
Example 17
Source File: Gl_400_texture_buffer_rgb.java    From jogl-samples with MIT License 3 votes vote down vote up
private boolean initTest(GL4 gl4) {

        boolean validated = true;
        gl4.glEnable(GL_DEPTH_TEST);

        return validated && checkError(gl4, "initTest");
    }
 
Example 18
Source File: Gl_420_test_depth_conservative.java    From jogl-samples with MIT License 2 votes vote down vote up
private boolean initTest(GL4 gl4) {

        gl4.glEnable(GL_DEPTH_TEST);

        return true;
    }
 
Example 19
Source File: Gl_400_program_subroutine.java    From jogl-samples with MIT License 2 votes vote down vote up
private boolean initTest(GL4 gl4) {

        gl4.glEnable(GL_DEPTH_TEST);

        return checkError(gl4, "initTest");
    }
 
Example 20
Source File: Gl_430_program_subroutine.java    From jogl-samples with MIT License 2 votes vote down vote up
private boolean initTest(GL4 gl4) {

        gl4.glEnable(GL_DEPTH_TEST);

        return checkError(gl4, "initTest");
    }