JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestGLMesaBug658NEWT.java
Go to the documentation of this file.
1package com.jogamp.opengl.test.junit.jogl.acore;
2
3import com.jogamp.opengl.GL;
4import com.jogamp.opengl.GL2GL3;
5import com.jogamp.opengl.GLAutoDrawable;
6import com.jogamp.opengl.GLCapabilities;
7import com.jogamp.opengl.GLContext;
8import com.jogamp.opengl.GLEventListener;
9import com.jogamp.opengl.GLProfile;
10
11import org.junit.Assert;
12import org.junit.Test;
13import org.junit.FixMethodOrder;
14import org.junit.runners.MethodSorters;
15
16import com.jogamp.newt.opengl.GLWindow;
17import com.jogamp.opengl.JoglVersion;
18import com.jogamp.opengl.test.junit.util.UITestCase;
19
20/**
21 * The 3.1 compatibility context on Mesa >= 9.0 seems to be broken.
22 * <p>
23 * This bug lies within Mesa3D (any renderer) and is fixed in
24 * commit ??? (not yet).
25 * </p>
26 * <p>
27 * Mesa3D Version 9.0 still exposes this bug,
28 * where 9.?.? has it fixed w/ above commit.
29 * </p>
30 * <https://jogamp.org/bugzilla/show_bug.cgi?id=658>
31 */
32@FixMethodOrder(MethodSorters.NAME_ASCENDING)
33public class TestGLMesaBug658NEWT extends UITestCase {
34
35 @Test
37 System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false).toString());
38 }
39
40 @Test
42 testGLNPolygonModeFailureImpl(GLProfile.GL2);
43 }
44
45 @Test
47 testGLNPolygonModeFailureImpl(GLProfile.GL3bc);
48 }
49
50 @Test
52 testGLNPolygonModeFailureImpl(GLProfile.GL3);
53 }
54
55 private void testGLNPolygonModeFailureImpl(final String profile) {
56 if(!GLProfile.isAvailable(profile)) { System.err.println(profile+" n/a"); return; }
57
58 final GLProfile pro = GLProfile.get(profile);
59 final GLCapabilities caps = new GLCapabilities(pro);
60 final GLWindow window = GLWindow.create(caps);
61
62 window.setSize(640, 480);
63 window.addGLEventListener(new GLEventListener() {
64 public void reshape(
65 final GLAutoDrawable drawable,
66 final int x,
67 final int y,
68 final int width,
69 final int height)
70 {
71 // Nothing.
72 }
73
74 public void init(
75 final GLAutoDrawable drawable)
76 {
77 final GLContext context = drawable.getContext();
78 System.err.println("CTX: "+context.getGLVersion());
79
80 final GL2GL3 gl = drawable.getGL().getGL2GL3();
81 System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
82 System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
83 System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
84 System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString());
85
86 if( gl.isGL2() || gl.isGLES2() ) { // compatibility profile || ES2
88 } else {
90 }
91
92 final int e = gl.glGetError();
93 Assert.assertTrue(e == GL.GL_NO_ERROR); // // FIXME On Mesa 9.0.1 w/ GL 3.1 -> GL.GL_INVALID_OPERATION ?
94 }
95
96 public void dispose(
97 final GLAutoDrawable drawable)
98 {
99 // Nothing.
100 }
101
102 public void display(
103 final GLAutoDrawable drawable)
104 {
105 // Nothing.
106 }
107 });
108
109 try {
110 window.setVisible(true);
111 } finally {
112 window.destroy();
113 }
114 }
115
116 @Test
118 testGLNBindArrayAttributeFailsImpl(GLProfile.GL2);
119 }
120
121 @Test
123 testGLNBindArrayAttributeFailsImpl(GLProfile.GL3bc);
124 }
125
126 @Test
128 testGLNBindArrayAttributeFailsImpl(GLProfile.GL3);
129 }
130
131 private void testGLNBindArrayAttributeFailsImpl(final String profile) {
132 if(!GLProfile.isAvailable(profile)) { System.err.println(profile+ " n/a"); return; }
133
134 final GLProfile pro = GLProfile.get(profile);
135 final GLCapabilities caps = new GLCapabilities(pro);
136 final GLWindow window = GLWindow.create(caps);
137
138 window.setSize(640, 480);
139 window.addGLEventListener(new GLEventListener() {
140 public void reshape(
141 final GLAutoDrawable drawable,
142 final int x,
143 final int y,
144 final int width,
145 final int height)
146 {
147 // Nothing.
148 }
149
150 public void init(
151 final GLAutoDrawable drawable)
152 {
153 final GLContext context = drawable.getContext();
154 System.err.println("CTX: "+context.getGLVersion());
155
156 final GL2GL3 gl = drawable.getGL().getGL2GL3();
157 System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
158 System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
159 System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
160 System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString());
161
162 final int[] name = new int[] { 0 };
163 gl.glGenBuffers(1, name, 0);
164 Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR);
165
166 gl.glBindBuffer(GL.GL_ARRAY_BUFFER, name[0]);
167 Assert.assertTrue(gl.glGetError() == 0);
169 Assert.assertTrue(gl.glGetError() == 0);
170
171 Assert.assertTrue(gl.getBoundBuffer(GL.GL_ARRAY_BUFFER) == name[0]);
173 Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR);
174 gl.glVertexAttribPointer(1, 4, GL.GL_FLOAT, false, 0, 0L);
175 Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); // FIXME On Mesa 9.0.1 w/ GL 3.1 -> GL.GL_INVALID_OPERATION ?
176 }
177
178 public void dispose(
179 final GLAutoDrawable drawable)
180 {
181 // Nothing.
182 }
183
184 public void display(
185 final GLAutoDrawable drawable)
186 {
187 // Nothing.
188 }
189 });
190
191 try {
192 window.setVisible(true);
193 } finally {
194 window.destroy();
195 }
196 }
197
198 public static void main(final String args[]) {
199 org.junit.runner.JUnitCore.main(TestGLMesaBug658NEWT.class.getName());
200 }
201
202}
203
Specifies a set of OpenGL capabilities.
Abstraction for an OpenGL rendering context.
Definition: GLContext.java:74
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
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 GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL3bc
The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.
Definition: GLProfile.java:573
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition: GLProfile.java:579
final StringBuilder toString(StringBuilder sb)
static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, final boolean withCapabilitiesInfo)
The 3.1 compatibility context on Mesa >= 9.0 seems to be broken.
void glVertexAttribPointer(int index, int size, int type, boolean normalized, int stride, long pointer_buffer_offset)
Entry point to C language function: void {@native glVertexAttribPointer}(GLuint index,...
void glEnableVertexAttribArray(int index)
Entry point to C language function: void {@native glEnableVertexAttribArray}(GLuint index) Part of...
static final int GL_FILL
GL_VERSION_1_1, GL_VERSION_1_0, GL_NV_polygon_mode Alias for: GL_FILL_NV Define "GL_FILL" with expre...
Definition: GL2GL3.java:573
void glPolygonMode(int face, int mode)
Entry point to C language function: void {@native glPolygonMode}(GLenum face, GLenum mode) Part of...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GLContext getContext()
Returns the context associated with this drawable.
int getBoundBuffer(int target)
boolean isGL2()
Indicates whether this GL object conforms to the OpenGL ≤ 3.0 profile.
GLContext getContext()
Returns the GLContext associated which this GL object.
GL2GL3 getGL2GL3()
Casts this object to the GL2GL3 interface.
boolean isGLES2()
Indicates whether this GL object conforms to the OpenGL ES ≥ 2.0 profile.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void glGenBuffers(int n, IntBuffer buffers)
Entry point to C language function: void {@native glGenBuffers}(GLsizei n, GLuint * buffers) Part ...
static final int GL_STATIC_DRAW
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_STATI...
Definition: GL.java:673
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_FLOAT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FLOAT" with expressio...
Definition: GL.java:786
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_FRONT_AND_BACK
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FRONT_AND_BACK" with ...
Definition: GL.java:619
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_FRONT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FRONT" with expressio...
Definition: GL.java:597
void glBindBuffer(int target, int buffer)
Entry point to C language function: void {@native glBindBuffer}(GLenum target, GLuint buffer) Part...
void glBufferData(int target, long size, Buffer data, int usage)
Entry point to C language function: void {@native glBufferData}(GLenum target, GLsizeiptr size,...
static final int GL_ARRAY_BUFFER
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_ARRAY...
Definition: GL.java:633