JOGL v2.6.0-rc-20250706
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;
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;
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;
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
122 val[0]=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;
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; }
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; }
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; }
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; }
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; }
220 runTestGL(caps);
221 }
222
223 public static void main(final String args[]) {
224 org.junit.runner.JUnitCore.main(TestGLMesaBug651NEWT.class.getName());
225 }
226}
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void setTitle(final String title)
Definition: GLWindow.java:297
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
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
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
Specifies a set of OpenGL capabilities.
final GLRendererQuirks getRendererQuirks()
Returns the instance of GLRendererQuirks, allowing one to determine workarounds.
Definition: GLContext.java:290
final String getGLVersion()
Returns a valid OpenGL version string, ie
Definition: GLContext.java:769
Class holding OpenGL extension strings, commonly used by JOGL's implementation.
static final String NV_fbo_color_attachments
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
Definition: GLProfile.java:305
static final String GL3
The desktop OpenGL core profile 3.x, with x >= 1.
Definition: GLProfile.java:576
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition: GLProfile.java:585
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition: GLProfile.java:579
static final String GLES1
The embedded OpenGL profile ES 1.x, with x >= 0.
Definition: GLProfile.java:582
static final String GL4
The desktop OpenGL core profile 4.x, with x >= 0.
Definition: GLProfile.java:569
final StringBuilder toString(StringBuilder sb)
Some GL state values are broken w/ Mesa 9.0 w/ multiple different context.
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
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
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
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
boolean hasGLSL()
Indicates whether this GL object supports GLSL.
boolean hasBasicFBOSupport()
Returns true if basic FBO support is available, otherwise false.
GLProfile getGLProfile()
Returns the GLProfile associated with this GL object.
boolean isGL2ES2()
Indicates whether this GL object conforms to a GL2ES2 compatible profile.
boolean isExtensionAvailable(String glExtensionName)
Returns true if the specified OpenGL extension can be used successfully through this GL instance give...
GLContext getContext()
Returns the GLContext associated which this GL object.
boolean isFunctionAvailable(String glFunctionName)
Returns true if the specified OpenGL core- or extension-function can be used successfully through thi...
boolean hasFullFBOSupport()
Returns true if full FBO support is available, otherwise false.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void glGetIntegerv(int pname, IntBuffer data)
Entry point to C language function: void {@native glGetIntegerv}(GLenum pname, GLint * data) Part ...
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
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_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
String glGetString(int name)
Entry point to C language function: const GLubyte * {@native glGetString}(GLenum name) Part of GL_...
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
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
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
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