JOGL: src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java Source File

JOGL v2.6.0-rc-20250712 JOGL, High-Performance Graphics Binding for Java™ (public API).

TestGLMesaBug651NEWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2012 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 */
28
29package com.jogamp.opengl.test.junit.jogl.acore;
30
31import com.jogamp.newt.opengl.GLWindow;
32import com.jogamp.opengl.GLExtensions;
33import com.jogamp.opengl.test.junit.util.UITestCase;
34
35import com.jogamp.opengl.GL;
36import com.jogamp.opengl.GL2ES2;
37import com.jogamp.opengl.GL2ES3;
38import com.jogamp.opengl.GL2GL3;
39import com.jogamp.opengl.GLAutoDrawable;
40import com.jogamp.opengl.GLCapabilities;
41import com.jogamp.opengl.GLEventListener;
42import com.jogamp.opengl.GLProfile;
43
44import org.junit.Assert;
45import org.junit.BeforeClass;
46import org.junit.AfterClass;
47import org.junit.Test;
48import org.junit.FixMethodOrder;
49import org.junit.runners.MethodSorters;
50
51/**
52 * Some GL state values are broken w/ Mesa 9.0 w/ multiple different context.
53 * <p>
54 * This bug lies within Mesa3D (any renderer) and is fixed in
55 * commit 8dc79ae7d73cf6711c2182ff9a5d37ef6c989d23.
56 * </p>
57 * <p>
58 * Mesa3D Version 9.0 still exposes this bug,
59 * where 9.0.1 has it fixed w/ above commit.
60 * </p>
61 * <https://jogamp.org/bugzilla/show_bug.cgi?id=651>
62 */
63@FixMethodOrder(MethodSorters.NAME_ASCENDING)
64public class TestGLMesaBug651NEWT extends UITestCase {
65 static int width, height;
66
67 @BeforeClass
68 public static void initClass() {
69 width = 512;
70 height = 512;
71 }
72
73 @AfterClass
74 public static void releaseClass() {
75 }
76
77 static class UnitTester implements GLEventListener {
78 @Override
79 public void init(final GLAutoDrawable drawable) {
80 final GL gl = drawable.getGL();
81 System.err.println("GL UnitTester");
82 System.err.println(" GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
83 System.err.println(" GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
84 System.err.println(" GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
85 System.err.println(" GL GLSL: "+gl.hasGLSL()+", has-compiler-func: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")+", "+gl.getContext().getGLSLVersionNumber());
86 System.err.println(" GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport());
87 System.err.println(" GL Profile: "+gl.getGLProfile());
88 System.err.println(" GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString());
89 System.err.println(" GL:" + gl + ", " + gl.getContext().getGLVersion());
90
91 final int _glerr = gl.glGetError(); // clear pre-error
92 System.err.println(" - pre GL-Error 0x"+Integer.toHexString(_glerr));
93
94 final int[] val = new int[1];
95 final int[] glerr = new int[] { GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR };
96 int i=0;
97
98 val[0]=0;
99 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0);
100 System.out.println(" - GL_MAX_TEXTURE_SIZE: " + val[0]);
101 glerr[i] = gl.glGetError(); // clear pre-error
102 System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
103 i++;
104
105 val[0]=0;
106 gl.glGetIntegerv(GL.GL_ACTIVE_TEXTURE, val, 0);
107 System.out.println(" - GL_ACTIVE_TEXTURE: " + val[0]);
108 glerr[i] = gl.glGetError(); // clear pre-error
109 System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
110 i++;
111
112 if(gl.isGL2ES2()) {
113 val[0]=0;
114 gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, val, 0);
115 System.out.println(" - GL_MAX_TEXTURE_IMAGE_UNITS: " + val[0]);
116 glerr[i] = gl.glGetError(); // clear pre-error
117 System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
118 }
119 i++;
120
121 if( gl.hasFullFBOSupport() || gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments) ) {
122 val[0]=0;
123 gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, val, 0);
124 System.out.println(" - GL_MAX_COLOR_ATTACHMENTS: " + val[0]);
125 glerr[i] = gl.glGetError(); // clear pre-error
126 System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
127 }
128 i++;
129
130 if( gl.hasFullFBOSupport() ) {
131 val[0]=0;
132 gl.glGetIntegerv(GL2ES3.GL_MAX_SAMPLES, val, 0);
133 System.out.println(" - GL_MAX_SAMPLES: " + val[0]);
134 glerr[i] = gl.glGetError(); // clear pre-error
135 System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i]));
136 }
137 i++;
138
139 boolean ok = true;
140 String res="";
141 for(int j=0; j<i; j++) {
142 switch(j) {
143 case 0: res += "GL_MAX_TEXTURE_SIZE"; break;
144 case 1: res += "GL_ACTIVE_TEXTURE"; break;
145 case 2: res += "GL_MAX_TEXTURE_IMAGE_UNITS"; break;
146 case 3: res += "GL_MAX_COLOR_ATTACHMENTS"; break;
147 case 4: res += "GL_MAX_SAMPLES"; break;
148 }
149 if(GL.GL_NO_ERROR == glerr[j]) {
150 res += " OK, ";
151 } else {
152 res += " ERROR, ";
153 ok = false;
154 }
155 }
156 Assert.assertTrue(res, ok);
157 }
158
159 @Override
160 public void dispose(final GLAutoDrawable drawable) {
161 }
162
163 @Override
164 public void display(final GLAutoDrawable drawable) {
165 }
166
167 @Override
168 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
169 }
170 }
171
172 protected void runTestGL(final GLCapabilities caps) throws InterruptedException {
173 final GLWindow glWindow = GLWindow.create(caps);
174 Assert.assertNotNull(glWindow);
175 glWindow.setTitle(getSimpleTestName("."));
176
177 final UnitTester demo = new UnitTester();
178
179 glWindow.addGLEventListener(demo);
180
181 glWindow.setSize(width, height);
182 glWindow.setVisible(true);
183 glWindow.display();
184
185 glWindow.destroy();
186 }
187
188 @Test
189 public void test01_ES1() throws InterruptedException {
190 if(!GLProfile.isAvailable(GLProfile.GLES1)) { System.err.println("GLES1 n/a"); return; }
191 final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
192 runTestGL(caps);
193 }
194
195 @Test
196 public void test02__ES2() throws InterruptedException {
197 if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
198 final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
199 runTestGL(caps);
200 }
201
202 @Test
203 public void test03_GL2() throws InterruptedException {
204 if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
205 final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
206 runTestGL(caps);
207 }
208
209 @Test
210 public void test04_GL3() throws InterruptedException {
211 if(!GLProfile.isAvailable(GLProfile.GL3)) { System.err.println("GL3 n/a"); return; }
212 final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL3));
213 runTestGL(caps);
214 }
215
216 @Test
217 public void test05_GL4() throws InterruptedException {
218 if(!GLProfile.isAvailable(GLProfile.GL4)) { System.err.println("GL4 n/a"); return; }
219 final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL4));
220 runTestGL(caps);
221 }
222
223 public static void main(final String args[]) {
224 org.junit.runner.JUnitCore.main(TestGLMesaBug651NEWT.class.getName());
225 }
226}
com.jogamp.newt.opengl.GLWindow
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
com.jogamp.newt.opengl.GLWindow.display
void display()
Definition: GLWindow.java:782
com.jogamp.newt.opengl.GLWindow.setTitle
final void setTitle(final String title)
Definition: GLWindow.java:297
com.jogamp.newt.opengl.GLWindow.setSize
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
Definition: GLWindow.java:625
com.jogamp.newt.opengl.GLWindow.setVisible
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
com.jogamp.newt.opengl.GLWindow.destroy
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
com.jogamp.newt.opengl.GLWindow.create
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Definition: GLWindow.java:169
com.jogamp.opengl.GLCapabilities
Specifies a set of OpenGL capabilities.
Definition: GLCapabilities.java:58
com.jogamp.opengl.GLContext.getRendererQuirks
final GLRendererQuirks getRendererQuirks()
Returns the instance of GLRendererQuirks, allowing one to determine workarounds.
Definition: GLContext.java:290
com.jogamp.opengl.GLContext.getGLVersion
final String getGLVersion()
Returns a valid OpenGL version string, ie
Definition: GLContext.java:769
com.jogamp.opengl.GLExtensions
Class holding OpenGL extension strings, commonly used by JOGL's implementation.
Definition: GLExtensions.java:33
com.jogamp.opengl.GLExtensions.NV_fbo_color_attachments
static final String NV_fbo_color_attachments
Definition: GLExtensions.java:52
com.jogamp.opengl.GLProfile
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
com.jogamp.opengl.GLProfile.isAvailable
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
Definition: GLProfile.java:305
com.jogamp.opengl.GLProfile.GL3
static final String GL3
The desktop OpenGL core profile 3.x, with x >= 1.
Definition: GLProfile.java:576
com.jogamp.opengl.GLProfile.GLES2
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition: GLProfile.java:585
com.jogamp.opengl.GLProfile.get
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
Definition: GLProfile.java:1000
com.jogamp.opengl.GLProfile.GL2
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition: GLProfile.java:579
com.jogamp.opengl.GLProfile.GLES1
static final String GLES1
The embedded OpenGL profile ES 1.x, with x >= 0.
Definition: GLProfile.java:582
com.jogamp.opengl.GLProfile.GL4
static final String GL4
The desktop OpenGL core profile 4.x, with x >= 0.
Definition: GLProfile.java:569
com.jogamp.opengl.GLRendererQuirks.toString
final StringBuilder toString(StringBuilder sb)
Definition: GLRendererQuirks.java:735
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT
Some GL state values are broken w/ Mesa 9.0 w/ multiple different context.
Definition: TestGLMesaBug651NEWT.java:64
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.releaseClass
static void releaseClass()
Definition: TestGLMesaBug651NEWT.java:74
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.test03_GL2
void test03_GL2()
Definition: TestGLMesaBug651NEWT.java:203
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.runTestGL
void runTestGL(final GLCapabilities caps)
Definition: TestGLMesaBug651NEWT.java:172
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.main
static void main(final String args[])
Definition: TestGLMesaBug651NEWT.java:223
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.test02__ES2
void test02__ES2()
Definition: TestGLMesaBug651NEWT.java:196
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.test04_GL3
void test04_GL3()
Definition: TestGLMesaBug651NEWT.java:210
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.test05_GL4
void test05_GL4()
Definition: TestGLMesaBug651NEWT.java:217
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.test01_ES1
void test01_ES1()
Definition: TestGLMesaBug651NEWT.java:189
com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT.initClass
static void initClass()
Definition: TestGLMesaBug651NEWT.java:68
com.jogamp.opengl.test.junit.util.UITestCase
Definition: UITestCase.java:62
com.jogamp.opengl.GL2ES2
Definition: GL2ES2.java:29
com.jogamp.opengl.GL2ES2.GL_MAX_COLOR_ATTACHMENTS
static final int GL_MAX_COLOR_ATTACHMENTS
GL_ES_VERSION_3_0, GL_ARB_framebuffer_object, GL_VERSION_3_0, GL_EXT_draw_buffers,...
Definition: GL2ES2.java:494
com.jogamp.opengl.GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS
static final int GL_MAX_TEXTURE_IMAGE_UNITS
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_NV_fragment_program, GL_ARB_fragment_program Alias for: GL_MAX_...
Definition: GL2ES2.java:437
com.jogamp.opengl.GL2ES2.GL_SHADING_LANGUAGE_VERSION
static final int GL_SHADING_LANGUAGE_VERSION
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_ARB_shading_language_100 Alias for: GL_SHADING_LANGUAGE_VERSION...
Definition: GL2ES2.java:234
com.jogamp.opengl.GL2ES3
Definition: GL2ES3.java:29
com.jogamp.opengl.GLAutoDrawable
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
Definition: GLAutoDrawable.java:146
com.jogamp.opengl.GLAutoDrawable.getGL
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
com.jogamp.opengl.GLAutoDrawable.addGLEventListener
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
com.jogamp.opengl.GLBase.hasGLSL
boolean hasGLSL()
Indicates whether this GL object supports GLSL.
com.jogamp.opengl.GLBase.hasBasicFBOSupport
boolean hasBasicFBOSupport()
Returns true if basic FBO support is available, otherwise false.
com.jogamp.opengl.GLBase.getGLProfile
GLProfile getGLProfile()
Returns the GLProfile associated with this GL object.
com.jogamp.opengl.GLBase.isGL2ES2
boolean isGL2ES2()
Indicates whether this GL object conforms to a GL2ES2 compatible profile.
com.jogamp.opengl.GLBase.isExtensionAvailable
boolean isExtensionAvailable(String glExtensionName)
Returns true if the specified OpenGL extension can be used successfully through this GL instance give...
com.jogamp.opengl.GLBase.getContext
GLContext getContext()
Returns the GLContext associated which this GL object.
com.jogamp.opengl.GLBase.isFunctionAvailable
boolean isFunctionAvailable(String glFunctionName)
Returns true if the specified OpenGL core- or extension-function can be used successfully through thi...
com.jogamp.opengl.GLBase.hasFullFBOSupport
boolean hasFullFBOSupport()
Returns true if full FBO support is available, otherwise false.
com.jogamp.opengl.GLEventListener
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
Definition: GLEventListener.java:47
com.jogamp.opengl.GL
Definition: GL.java:25
com.jogamp.opengl.GL.glGetIntegerv
void glGetIntegerv(int pname, IntBuffer data)
Entry point to C language function: void {@native glGetIntegerv}(GLenum pname, GLint * data) Part ...
com.jogamp.opengl.GL.GL_VERSION
static final int GL_VERSION
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_VERSION" with express...
Definition: GL.java:190
com.jogamp.opengl.GL.GL_NO_ERROR
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
com.jogamp.opengl.GL.glGetError
int glGetError()
Entry point to C language function: GLenum {@native glGetError}() Part of GL_ES_VERSION_2_0,...
com.jogamp.opengl.GL.GL_ACTIVE_TEXTURE
static final int GL_ACTIVE_TEXTURE
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_ARB_multitexture Alias for: GL_ACTIVE_TEXTUR...
Definition: GL.java:494
com.jogamp.opengl.GL.glGetString
String glGetString(int name)
Entry point to C language function: const GLubyte * {@native glGetString}(GLenum name) Part of GL_...
com.jogamp.opengl.GL.GL_RENDERER
static final int GL_RENDERER
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RENDERER" with expres...
Definition: GL.java:662
com.jogamp.opengl.GL.GL_VENDOR
static final int GL_VENDOR
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_VENDOR" with expressi...
Definition: GL.java:607
com.jogamp.opengl.GL.GL_MAX_TEXTURE_SIZE
static final int GL_MAX_TEXTURE_SIZE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_MAX_TEXTURE_SIZE" wit...
Definition: GL.java:244
com.jogamp.opengl.GL.GL_MAX_SAMPLES
static final int GL_MAX_SAMPLES
GL_ES_VERSION_3_0, GL_ARB_framebuffer_object, GL_VERSION_3_0, GL_NV_framebuffer_multisample,...
Definition: GL.java:63