JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestGLSLShaderState01NEWT.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.test.junit.jogl.glsl;
29
30import com.jogamp.opengl.util.GLArrayDataServer;
31import com.jogamp.opengl.util.PMVMatrix;
32import com.jogamp.opengl.util.glsl.ShaderCode;
33import com.jogamp.opengl.util.glsl.ShaderProgram;
34import com.jogamp.opengl.util.glsl.ShaderState;
35import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
36import com.jogamp.opengl.test.junit.util.MiscUtils;
37import com.jogamp.opengl.test.junit.util.NEWTGLContext;
38import com.jogamp.opengl.test.junit.util.UITestCase;
39
40import java.io.IOException;
41
42import com.jogamp.math.FloatUtil;
43import com.jogamp.opengl.GL;
44import com.jogamp.opengl.GL2ES2;
45import com.jogamp.opengl.GLCapabilities;
46import com.jogamp.opengl.GLDrawable;
47import com.jogamp.opengl.GLProfile;
48import com.jogamp.opengl.GLUniformData;
49import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
50
51import org.junit.Assert;
52import org.junit.Test;
53import org.junit.FixMethodOrder;
54import org.junit.runners.MethodSorters;
55
56/**
57 * Testing different vertex attribute (VA) data sets on one shader
58 * and shader state in general.
59 */
60@FixMethodOrder(MethodSorters.NAME_ASCENDING)
62 static long durationPerTest = 10; // ms
63 static boolean firstUIActionOnProcess = false;
64
65 static final int vertices0_loc = 0; // FIXME: AMD needs this to be location 0 ? hu ?
66 static final int colors0_loc = 1;
67
68 @Test
69 public void test00NoShaderState_Validation() throws InterruptedException {
70 // preset ..
71 final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
72 new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
73 final GLDrawable drawable = winctx.context.getGLDrawable();
74 final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
75 System.err.println(winctx.context);
76
77 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
78
79 // test code ..
81 "shader", "shader/bin", "RedSquareShader", true);
83 "shader", "shader/bin", "RedSquareShader", true);
84 rsVp.defaultShaderCustomization(gl, true, true);
85 rsFp.defaultShaderCustomization(gl, true, true);
86
87 final ShaderProgram sp = new ShaderProgram();
88 Assert.assertTrue(0 == sp.program());
89
90 sp.add(gl, rsVp, System.err);
91 sp.add(gl, rsFp, System.err);
92
93 Assert.assertTrue(0 != sp.program());
94 Assert.assertTrue(!sp.inUse());
95 Assert.assertTrue(!sp.linked());
96 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
97
98 Assert.assertTrue( sp.link(gl, System.err) );
99 sp.useProgram(gl, true);
100
101 // Allocate Vertex Array0
102 final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, null, sp.program(), vertices0_loc, GLSLMiscHelper.vertices0);
103 System.err.println("vertices0: " + vertices0);
104 vertices0.enableBuffer(gl, false);
105 Assert.assertEquals(vertices0_loc, vertices0.getLocation());
106
107 // Allocate Color Array0
108 final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, null, sp.program(), colors0_loc, GLSLMiscHelper.colors0);
109 System.err.println("colors0: " + colors0);
110 colors0.enableBuffer(gl, false);
111 Assert.assertEquals(colors0_loc, colors0.getLocation());
112
113 Assert.assertTrue(sp.link(gl, System.err));
114 Assert.assertTrue(sp.linked());
115 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
116
117 Assert.assertEquals(vertices0_loc, vertices0.getLocation());
119
120 Assert.assertEquals(colors0_loc, colors0.getLocation());
122
123 sp.useProgram(gl, true);
124 Assert.assertTrue(sp.inUse());
125 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
126
127 // setup mgl_PMVMatrix
128 final PMVMatrix pmvMatrix = new PMVMatrix();
129 final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
130 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
131 pmvMatrixUniform.setLocation(gl, sp.program());
132 gl.glUniform(pmvMatrixUniform);
133
134 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
135
136 // Allocate Vertex Array1
137 final GLArrayDataServer vertices1 = GLSLMiscHelper.createVertices(gl, null, sp.program(), -1, GLSLMiscHelper.vertices1);
138 System.err.println("vertices1: " + vertices1);
139 vertices1.enableBuffer(gl, false);
141
142 // Allocate Color Array1
143 final GLArrayDataServer colors1 = GLSLMiscHelper.createColors(gl, null, sp.program(), -1, GLSLMiscHelper.colors1);
144 System.err.println("colors1: " + colors1);
145 colors1.enableBuffer(gl, false);
147
148 // misc GL setup
149 gl.glClearColor(0, 0, 0, 1);
151 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
152
153 // reshape
155 pmvMatrix.glLoadIdentity();
156 pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float) drawable.getSurfaceWidth() / (float) drawable.getSurfaceHeight(), 1.0F, 100.0F);
158 pmvMatrix.glLoadIdentity();
159 pmvMatrix.glTranslatef(0, 0, -10);
160 gl.glUniform(pmvMatrixUniform);
161
162 gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
163 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
164
165 // display #1 vertices0 / colors0 (post-disable)
166 GLSLMiscHelper.displayVCArrays(drawable, gl, null, true, vertices0, colors0, true, 1, durationPerTest);
167
168 // display #2 #1 vertices1 / colors1 (post-disable)
169 GLSLMiscHelper.displayVCArrays(drawable, gl, null, true, vertices1, colors1, true, 2, durationPerTest);
170
171 // display #3 vertices0 / colors0 (post-disable)
172 GLSLMiscHelper.displayVCArrays(drawable, gl, null, true, vertices0, colors0, true, 3, durationPerTest);
173
174 // cleanup
175 sp.useProgram(gl, false);
176 sp.destroy(gl);
177 vertices1.destroy(gl);
178 colors0.destroy(gl);
179 colors1.destroy(gl);
180
182 }
183
184 @Test
185 public void test01ShaderState_Validation() throws InterruptedException {
186 // preset ..
187 final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
188 new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
189 final GLDrawable drawable = winctx.context.getGLDrawable();
190 final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
191 System.err.println(winctx.context);
192
193 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
194
195 // test code ..
196 final ShaderState st = new ShaderState();
197
198 final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader",
199 "shader/bin", "RedSquareShader", true);
200 final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
201 "shader/bin", "RedSquareShader", true);
202 rsVp.defaultShaderCustomization(gl, true, true);
203 rsFp.defaultShaderCustomization(gl, true, true);
204
205 final ShaderProgram sp = new ShaderProgram();
206 Assert.assertTrue(0 == sp.program());
207
208 sp.add(gl, rsVp, System.err);
209 sp.add(gl, rsFp, System.err);
210
211 Assert.assertTrue(0 != sp.program());
212 Assert.assertTrue(!sp.inUse());
213 Assert.assertTrue(!sp.linked());
214 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
215
216 st.attachShaderProgram(gl, sp, false);
217 Assert.assertTrue(!sp.inUse());
218 Assert.assertTrue(!sp.linked());
219
220 // Allocate Vertex Array0
221 final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, st, 0, vertices0_loc, GLSLMiscHelper.vertices0);
222 System.err.println("vertices0: " + vertices0);
223 vertices0.enableBuffer(gl, false);
224 Assert.assertEquals(vertices0_loc, vertices0.getLocation());
225
226 // Allocate Color Array0
227 final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, st, 0, colors0_loc, GLSLMiscHelper.colors0);
228 System.err.println("colors0: " + colors0);
229 colors0.enableBuffer(gl, false);
230 Assert.assertEquals(colors0_loc, colors0.getLocation());
231
232 Assert.assertTrue(sp.link(gl, System.err));
233 Assert.assertTrue(sp.linked());
234 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
235
236 Assert.assertEquals(vertices0_loc, vertices0.getLocation());
238
239 Assert.assertEquals(colors0_loc, colors0.getLocation());
241
242 st.useProgram(gl, true);
243 Assert.assertTrue(sp.inUse());
244 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
245
246 // setup mgl_PMVMatrix
247 final PMVMatrix pmvMatrix = new PMVMatrix();
248 final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
249 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
250 st.ownUniform(pmvMatrixUniform);
251
252 st.uniform(gl, pmvMatrixUniform);
253 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
254 Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix"));
255
256 // Allocate Vertex Array1
258 System.err.println("vertices1: " + vertices1);
259 vertices1.enableBuffer(gl, false);
261
262 // Allocate Color Array1
264 System.err.println("colors1: " + colors1);
265 colors1.enableBuffer(gl, false);
267
268 // misc GL setup
269 gl.glClearColor(0, 0, 0, 1);
271 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
272
273 // reshape
275 pmvMatrix.glLoadIdentity();
276 pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float) drawable.getSurfaceWidth() / (float) drawable.getSurfaceHeight(), 1.0F, 100.0F);
278 pmvMatrix.glLoadIdentity();
279 pmvMatrix.glTranslatef(0, 0, -10);
280 st.uniform(gl, pmvMatrixUniform);
281 gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
282 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
283
284 // display #1 vertices0 / colors0 (post-disable)
285 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, durationPerTest);
286
287 // display #2 #1 vertices1 / colors1 (post-disable)
288 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, durationPerTest);
289
290 // display #3 vertices0 / colors0 (post-disable)
291 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest);
292
293 // cleanup
294 st.destroy(gl);
295
297 }
298
299 @Test(timeout=240000)
300 public void test02ShaderState_PerformanceSingleKeepEnabled() throws InterruptedException {
301 testShaderState_PerformanceSingleImpl(false);
302 }
303 @Test(timeout=240000)
304 public void test03ShaderState_PerformanceSingleToggleEnable() throws InterruptedException {
305 testShaderState_PerformanceSingleImpl(true);
306 }
307
308 private void testShaderState_PerformanceSingleImpl(final boolean toggleEnable) throws InterruptedException {
309 // preset ..
310 final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
311 new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
312 final GLDrawable drawable = winctx.context.getGLDrawable();
313 final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
314 System.err.println(winctx.context);
315 gl.setSwapInterval(0);
316
317 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
318
319 // test code ..
320 final ShaderState st = new ShaderState();
321
322 final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader",
323 "shader/bin", "RedSquareShader", true);
324 final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
325 "shader/bin", "RedSquareShader", true);
326 rsVp.defaultShaderCustomization(gl, true, true);
327 rsFp.defaultShaderCustomization(gl, true, true);
328
329 final ShaderProgram sp = new ShaderProgram();
330 sp.add(rsVp);
331 sp.add(rsFp);
332
333 sp.init(gl);
334 Assert.assertTrue(sp.link(gl, System.err));
335
336 st.attachShaderProgram(gl, sp, true);
337
338 // setup mgl_PMVMatrix
339 final PMVMatrix pmvMatrix = new PMVMatrix();
340 final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
341 st.ownUniform(pmvMatrixUniform);
342 st.uniform(gl, pmvMatrixUniform);
343
344 // Allocate Vertex Array0
346 vertices0.enableBuffer(gl, toggleEnable ? false : true);
347
348 // Allocate Color Array0
350 colors0.enableBuffer(gl, toggleEnable ? false : true);
351
352 // misc GL setup
353 gl.glClearColor(0, 0, 0, 1);
355
356 // reshape
358 pmvMatrix.glLoadIdentity();
359 pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float) drawable.getSurfaceWidth() / (float) drawable.getSurfaceHeight(), 1.0F, 100.0F);
361 pmvMatrix.glLoadIdentity();
362 pmvMatrix.glTranslatef(0, 0, -10);
363 st.uniform(gl, pmvMatrixUniform);
364 gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
365
366 gl.setSwapInterval(0);
367
368 // validation ..
369 GLSLMiscHelper.displayVCArrays(drawable, gl, st, toggleEnable, vertices0, colors0, toggleEnable, 1, 0);
370
371 // warmup ..
372 for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames++) {
373 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, toggleEnable, vertices0, colors0, toggleEnable);
374 }
375
376 // measure ..
377 final long t0 = System.currentTimeMillis();
378 int frames;
379
380 for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames++) {
381 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, toggleEnable, vertices0, colors0, toggleEnable);
382 }
383 final long t1 = System.currentTimeMillis();
384 final long dt = t1 - t0;
385 final double fps = ( frames * 1000.0 ) / dt;
386 final String fpsS = String.valueOf(fps);
387 final int fpsSp = fpsS.indexOf('.');
388 System.err.println("testShaderState00PerformanceSingle toggleEnable "+toggleEnable+": "+dt/1000.0 +"s: "+ frames + "f, " + fpsS.substring(0, fpsSp+2) + " fps, "+dt/frames+" ms/f");
389
390 // cleanup
391 st.destroy(gl);
392
393 NEWTGLContext.destroyWindow(winctx);
394 }
395
396 @Test(timeout=240000)
397 public void test04ShaderState_PerformanceDouble() throws InterruptedException {
398 // preset ..
399 final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
400 new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
401 final GLDrawable drawable = winctx.context.getGLDrawable();
402 final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
403 System.err.println(winctx.context);
404 gl.setSwapInterval(0);
405
406 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
407
408 // test code ..
409 final ShaderState st = new ShaderState();
410
411 final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader",
412 "shader/bin", "RedSquareShader", true);
413 final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
414 "shader/bin", "RedSquareShader", true);
415 rsVp.defaultShaderCustomization(gl, true, true);
416 rsFp.defaultShaderCustomization(gl, true, true);
417
418 final ShaderProgram sp = new ShaderProgram();
419 sp.add(rsVp);
420 sp.add(rsFp);
421
422 sp.init(gl);
423 Assert.assertTrue(sp.link(gl, System.err));
424
425 st.attachShaderProgram(gl, sp, true);
426
427 // setup mgl_PMVMatrix
428 final PMVMatrix pmvMatrix = new PMVMatrix();
429 final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
430 st.ownUniform(pmvMatrixUniform);
431 st.uniform(gl, pmvMatrixUniform);
432
433 // Allocate Vertex Array0
435 vertices0.enableBuffer(gl, false);
436
437 // Allocate Vertex Array1
439 vertices1.enableBuffer(gl, false);
440
441 // Allocate Color Array0
443 colors0.enableBuffer(gl, false);
444
445 // Allocate Color Array1
447 colors1.enableBuffer(gl, false);
448
449 // misc GL setup
450 gl.glClearColor(0, 0, 0, 1);
452
453 // reshape
455 pmvMatrix.glLoadIdentity();
456 pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float) drawable.getSurfaceWidth() / (float) drawable.getSurfaceHeight(), 1.0F, 100.0F);
458 pmvMatrix.glLoadIdentity();
459 pmvMatrix.glTranslatef(0, 0, -10);
460 st.uniform(gl, pmvMatrixUniform);
461 gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
462
463 gl.setSwapInterval(0);
464
465 // validation ..
466 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
467 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);
468
469 // warmup ..
470 for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) {
471 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
472 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
473 }
474
475 // measure ..
476 final long t0 = System.currentTimeMillis();
477 int frames;
478
479 for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames+=2) {
480 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
481 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
482 }
483 final long t1 = System.currentTimeMillis();
484 final long dt = t1 - t0;
485 final double fps = ( frames * 1000.0 ) / dt;
486 final String fpsS = String.valueOf(fps);
487 final int fpsSp = fpsS.indexOf('.');
488 System.err.println("testShaderState01PerformanceDouble: "+dt/1000.0 +"s: "+ frames + "f, " + fpsS.substring(0, fpsSp+2) + " fps, "+dt/frames+" ms/f");
489
490 // cleanup
491 st.destroy(gl);
492
494 }
495
496 public static void main(final String args[]) throws IOException {
497 System.err.println("main - start");
498 boolean wait = false;
499 for(int i=0; i<args.length; i++) {
500 if(args[i].equals("-time")) {
501 durationPerTest = MiscUtils.atoi(args[++i], (int)durationPerTest);
502 } else if(args[i].equals("-wait")) {
503 wait = true;
504 } else if(args[i].equals("-firstUIAction")) {
505 firstUIActionOnProcess = true;
506 }
507 }
508 if(wait) {
509 while(-1 == System.in.read()) ;
511 try {
513 } catch (final Exception e) {
514 e.printStackTrace();
515 }
516 } else {
517 final String tstname = TestGLSLShaderState01NEWT.class.getName();
518 org.junit.runner.JUnitCore.main(tstname);
519 }
520 System.err.println("main - end");
521 }
522}
Basic Float math utility functions.
Definition: FloatUtil.java:83
static final float QUARTER_PI
The value PI/4, i.e.
final SyncMatrices4f getSyncPMv()
Returns SyncMatrices4f of 2 matrices within one FloatBuffer: P and Mv.
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
Definition: GLProfile.java:913
GLSL uniform data wrapper encapsulating data to be uploaded to the GPU as a uniform.
int setLocation(final int location)
Sets the given location of the shader uniform.
static void validateGLArrayDataServerState(final GL2ES2 gl, final ShaderState st, final GLArrayDataServer data)
static GLArrayDataServer createColors(final GL2ES2 gl, final ShaderState st, final int shaderProgram, final int location, final float[] colors)
static GLArrayDataServer createVertices(final GL2ES2 gl, final ShaderState st, final int shaderProgram, final int location, final float[] vertices)
static void displayVCArrays(final GLDrawable drawable, final GL2ES2 gl, final ShaderState st, final boolean preEnable, final GLArrayDataServer vertices, final GLArrayDataServer colors, final boolean postDisable, final int num, final long postDelay)
static void displayVCArraysNoChecks(final GLDrawable drawable, final GL2ES2 gl, final boolean preEnable, final GLArrayDataServer vertices, final GLArrayDataServer colors, final boolean postDisable)
Testing different vertex attribute (VA) data sets on one shader and shader state in general.
static int atoi(final String str, final int def)
Definition: MiscUtils.java:57
static WindowContext createWindow(final GLCapabilities caps, final int width, final int height, final boolean debugGL)
static void destroyWindow(final WindowContext winctx)
void enableBuffer(final GL gl, final boolean enable)
Enables the buffer if enable is true, and transfers the data if required.
final int getLocation()
Returns the shader attribute location for this name, -1 if not yet determined.
PMVMatrix implements a subset of the fixed function pipeline GLMatrixFunc using PMVMatrix4f.
Definition: PMVMatrix.java:62
final void glTranslatef(final float x, final float y, final float z)
Translate the current matrix.
Definition: PMVMatrix.java:379
final void glMatrixMode(final int matrixName)
Sets the current matrix mode.
Definition: PMVMatrix.java:218
final void gluPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Multiply the current matrix with the perspective/frustum matrix.
Definition: PMVMatrix.java:499
final void glLoadIdentity()
Load the current matrix with the identity matrix.
Definition: PMVMatrix.java:325
Convenient shader code class to use and instantiate vertex or fragment programs.
Definition: ShaderCode.java:75
final int defaultShaderCustomization(final GL2ES2 gl, final boolean preludeVersion, final boolean addDefaultPrecision)
Default customization of this shader source code.
static ShaderCode create(final GL2ES2 gl, final int type, final int count, final Class<?> context, final String[] sourceFiles, final boolean mutableStringBuilder)
Creates a complete ShaderCode object while reading all shader source of sourceFiles,...
int program()
Returns the shader program name, which is non zero if valid.
synchronized final boolean init(final GL2ES2 gl)
Creates the empty GL program object using GL2ES2#glCreateProgram(), if not already created.
synchronized void destroy(final GL2ES2 gl)
Detaches all shader codes and deletes the program.
synchronized void useProgram(final GL2ES2 gl, boolean on)
synchronized boolean link(final GL2ES2 gl, final PrintStream verboseOut)
Links the shader code to the program.
synchronized void add(final ShaderCode shaderCode)
Adds a new shader to this program.
ShaderState allows to sharing data between shader programs, while updating the attribute and uniform ...
synchronized void useProgram(final GL2ES2 gl, final boolean on)
Turns the shader program on or off.
synchronized boolean attachShaderProgram(final GL2ES2 gl, final ShaderProgram prog, final boolean enable)
Attach or switch a shader program.
GLUniformData getUniform(final String name)
Get the uniform data, previously set.
synchronized void destroy(final GL2ES2 gl)
Calls release(gl, true, true, true).
boolean uniform(final GL2ES2 gl, final GLUniformData data)
Set the uniform data, if it's location is valid, i.e.
void ownUniform(final GLUniformData uniform)
Bind the GLUniform lifecycle to this ShaderState.
static final int GL_VERTEX_SHADER
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_EXT_vertex_shader, GL_ARB_vertex_shader Alias for: GL_VERTEX_SH...
Definition: GL2ES2.java:39
void glUniform(GLUniformData data)
static final int GL_FRAGMENT_SHADER
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_ATI_fragment_shader, GL_ARB_fragment_shader Alias for: GL_FRAGM...
Definition: GL2ES2.java:541
GL getGL()
Casts this object to the GL interface.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
void setSwapInterval(int interval)
Set the swap interval of the current context and attached onscreen GLDrawable.
An abstraction for an OpenGL rendering target.
Definition: GLDrawable.java:51
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
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,...
void glClearColor(float red, float green, float blue, float alpha)
Entry point to C language function: void {@native glClearColor}(GLfloat red, GLfloat green,...
void glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
static final int GL_DEPTH_TEST
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expr...
Definition: GL.java:43
void glViewport(int x, int y, int width, int height)
Entry point to C language function: void {@native glViewport}(GLint x, GLint y, GLsizei width,...
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_PROJECTION
Matrix mode projection.
static final int GL_MODELVIEW
Matrix mode modelview.