JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
MSAATool.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.opengl.demos.graph;
29
30import com.jogamp.opengl.GL;
31import com.jogamp.opengl.GL2ES2;
32import com.jogamp.opengl.GL2GL3;
33import com.jogamp.opengl.GLAutoDrawable;
34import com.jogamp.opengl.GLCapabilitiesImmutable;
35
36public class MSAATool {
37 public static boolean glIsEnabled(final GL gl, final int name) {
38 boolean isEnabled = false;
39 try {
40 isEnabled = gl.glIsEnabled(name);
41 final int glerr = gl.glGetError();
42 if(GL.GL_NO_ERROR != glerr) {
43 System.err.println("glIsEnabled(0x"+Integer.toHexString(name)+") -> error 0x"+Integer.toHexString(glerr));
44 }
45 } catch (final Exception e) {
46 System.err.println("Caught exception: "+e.getMessage());
47 // e.printStackTrace();
48 }
49 return isEnabled;
50 }
51 public static void dump(final GLAutoDrawable drawable) {
52 final float[] vf = new float[] { 0f };
53 final byte[] vb = new byte[] { 0 };
54 final int[] vi = new int[] { 0, 0 };
55
56 System.out.println("GL MSAA SETUP:");
57 final GL2ES2 gl = drawable.getGL().getGL2ES2();
59 System.out.println(" Caps realised "+caps);
60 System.out.println(" Caps sample buffers "+caps.getSampleBuffers()+", samples "+caps.getNumSamples());
61
62 System.out.println(" GL MULTISAMPLE "+glIsEnabled(gl, GL.GL_MULTISAMPLE));
63 // sample buffers min 0, same as GLX_SAMPLE_BUFFERS_ARB or WGL_SAMPLE_BUFFERS_ARB
65 // samples min 0
66 gl.glGetIntegerv(GL.GL_SAMPLES, vi, 1);
67 System.out.println(" GL SAMPLE_BUFFERS "+vi[0]+", SAMPLES "+vi[1]);
68
69 System.out.println("GL CSAA SETUP:");
70 // default FALSE
71 System.out.println(" GL SAMPLE COVERAGE "+glIsEnabled(gl, GL.GL_SAMPLE_COVERAGE));
72 // default FALSE
73 System.out.println(" GL SAMPLE_ALPHA_TO_COVERAGE "+glIsEnabled(gl, GL.GL_SAMPLE_ALPHA_TO_COVERAGE));
74 // default FALSE
75 System.out.println(" GL SAMPLE_ALPHA_TO_ONE "+glIsEnabled(gl, GL.GL_SAMPLE_ALPHA_TO_ONE));
76 // default FALSE, value 1, invert false
79 System.out.println(" GL SAMPLE_COVERAGE "+glIsEnabled(gl, GL.GL_SAMPLE_COVERAGE) +
80 ": SAMPLE_COVERAGE_VALUE "+vf[0]+
81 ", SAMPLE_COVERAGE_INVERT "+vb[0]);
82 dumpBlend(gl);
83 }
84 public static void dumpBlend(final GL gl) {
85 final int[] vi = new int[] { 0, 0, 0, 0 };
86 gl.glGetIntegerv(GL.GL_BLEND, vi, 0);
90 final boolean blendEnabled = vi[0] == GL.GL_TRUE;
91 System.out.println("GL_BLEND "+blendEnabled+"/"+glIsEnabled(gl, GL.GL_BLEND) +
92 " GL_SRC_ALPHA 0x"+Integer.toHexString(vi[1])+
93 " GL_SRC_RGB 0x"+Integer.toHexString(vi[2])+
94 " GL_DST_RGB 0x"+Integer.toHexString(vi[3]));
95 }
96}
static void dump(final GLAutoDrawable drawable)
Definition: MSAATool.java:51
static boolean glIsEnabled(final GL gl, final int name)
Definition: MSAATool.java:37
static void dumpBlend(final GL gl)
Definition: MSAATool.java:84
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
Specifies an immutable set of OpenGL capabilities.
boolean getSampleBuffers()
Returns whether sample buffers for full-scene antialiasing (FSAA) should be allocated for this drawab...
int getNumSamples()
Returns the number of sample buffers to be allocated if sample buffers are enabled,...
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
void glGetFloatv(int pname, FloatBuffer data)
Entry point to C language function: void {@native glGetFloatv}(GLenum pname, GLfloat * data) Part ...
void glGetIntegerv(int pname, IntBuffer data)
Entry point to C language function: void {@native glGetIntegerv}(GLenum pname, GLint * data) Part ...
static final int GL_MULTISAMPLE
Common in ES1, GL2 and GL3.
Definition: GL.java:1249
static final int GL_SAMPLE_BUFFERS
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_3DFX_multisample, GL_ARB_multisample,...
Definition: GL.java:339
void glGetBooleanv(int pname, ByteBuffer data)
Entry point to C language function: void {@native glGetBooleanv}(GLenum pname, GLboolean * data) P...
static final int GL_BLEND_SRC_ALPHA
GL_ES_VERSION_2_0, GL_VERSION_1_4, GL_OES_blend_func_separate, GL_EXT_blend_func_separate Alias for: ...
Definition: GL.java:435
boolean glIsEnabled(int cap)
Entry point to C language function: GLboolean {@native glIsEnabled}(GLenum cap) Part of GL_NV_vert...
static final int GL_SAMPLE_COVERAGE_INVERT
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_ARB_multisample Alias for: GL_SAMPLE_COVERAG...
Definition: GL.java:180
static final int GL_SAMPLE_COVERAGE
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_ARB_multisample Alias for: GL_SAMPLE_COVERAG...
Definition: GL.java:326
static final int GL_BLEND_SRC_RGB
GL_ES_VERSION_2_0, GL_VERSION_1_4, GL_EXT_blend_func_separate, GL_OES_blend_func_separate Alias for: ...
Definition: GL.java:313
static final int GL_NO_ERROR
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_NO_ERROR" with expres...
Definition: GL.java:481
int glGetError()
Entry point to C language function: GLenum {@native glGetError}() Part of GL_ES_VERSION_2_0,...
static final int GL_BLEND_DST_RGB
GL_ES_VERSION_2_0, GL_VERSION_1_4, GL_EXT_blend_func_separate, GL_OES_blend_func_separate Alias for: ...
Definition: GL.java:702
static final int GL_SAMPLES
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_3DFX_multisample, GL_ARB_multisample,...
Definition: GL.java:689
static final int GL_SAMPLE_ALPHA_TO_ONE
Common in ES1, GL2 and GL3.
Definition: GL.java:1267
static final int GL_SAMPLE_ALPHA_TO_COVERAGE
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_ARB_multisample Alias for: GL_SAMPLE_ALPHA_T...
Definition: GL.java:758
static final int GL_SAMPLE_COVERAGE_VALUE
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_ARB_multisample Alias for: GL_SAMPLE_COVERAG...
Definition: GL.java:303
static final int GL_BLEND
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_BLEND" with expressio...
Definition: GL.java:704
static final int GL_TRUE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRUE" with expression...
Definition: GL.java:308