JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestGLSLShaderState02NEWT.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.GLContext;
47import com.jogamp.opengl.GLDrawable;
48import com.jogamp.opengl.GLProfile;
49import com.jogamp.opengl.GLUniformData;
50import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
51
52import org.junit.Assert;
53import org.junit.Test;
54import org.junit.FixMethodOrder;
55import org.junit.runners.MethodSorters;
56
57/**
58 * Testing different vertex attribute (VA) data sets on one shader
59 * and shader state in general.
60 */
61@FixMethodOrder(MethodSorters.NAME_ASCENDING)
63 static long durationPerTest = 10; // ms
64
65 static final int vertices0_loc = 0; // FIXME: AMD needs this to be location 0 ? hu ?
66 static final int colors0_loc = 5;
67
68 @Test(timeout=240000)
69 public void test01ShaderStatePerformanceDouble() throws InterruptedException {
70 // preset ..
71 if(true) {
72 System.err.println("CCC01: GLProfile.initSingleton(); START");
74 System.err.println("CCC01: GLProfile.initSingleton(); DONE ");
75 }
76
77 System.err.println("CCC01: Win + Ctx creation incl 1st makeCurrent.");
78 final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
79 new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
80 final GLDrawable drawable = winctx.context.getGLDrawable();
81 final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
82 System.err.println(winctx.context);
83 gl.setSwapInterval(0);
84
85 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
86
87 // test code ..
88 final ShaderState st = new ShaderState();
89
90 final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader",
91 "shader/bin", "RedSquareShader", true);
92 final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
93 "shader/bin", "RedSquareShader", true);
94 final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
95 "shader/bin", "RedSquareShader2", true);
96 rsVp0.defaultShaderCustomization(gl, true, true);
97 rsFp0.defaultShaderCustomization(gl, true, true);
98 rsFp1.defaultShaderCustomization(gl, true, true);
99
100 final ShaderProgram sp1 = new ShaderProgram();
101 sp1.add(rsVp0);
102 sp1.add(rsFp1);
103 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
104 Assert.assertTrue(0 == sp1.program());
105 Assert.assertTrue(sp1.init(gl));
106 Assert.assertTrue(0 != sp1.program());
107 Assert.assertTrue(sp1.link(gl, System.err));
108
109 final ShaderProgram sp0 = new ShaderProgram();
110 sp0.add(rsVp0);
111 sp0.add(rsFp0);
112
113 Assert.assertTrue(sp0.init(gl));
114 Assert.assertTrue(sp0.link(gl, System.err));
115
116 st.attachShaderProgram(gl, sp0, true);
117
118 // setup mgl_PMVMatrix
119 final PMVMatrix pmvMatrix = new PMVMatrix();
120 final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
121 st.ownUniform(pmvMatrixUniform);
122 st.uniform(gl, pmvMatrixUniform);
123
124 // Allocate Vertex Array0
126 vertices0.enableBuffer(gl, false);
127
128 // Allocate Vertex Array1
130 vertices1.enableBuffer(gl, false);
131
132 // Allocate Color Array0
134 colors0.enableBuffer(gl, false);
135
136 // Allocate Color Array1
138 colors1.enableBuffer(gl, false);
139
140 // misc GL setup
141 gl.glClearColor(0, 0, 0, 1);
143
144 // reshape
146 pmvMatrix.glLoadIdentity();
147 pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float) drawable.getSurfaceWidth() / (float) drawable.getSurfaceHeight(), 1.0F, 100.0F);
149 pmvMatrix.glLoadIdentity();
150 pmvMatrix.glTranslatef(0, 0, -10);
151 st.uniform(gl, pmvMatrixUniform);
152 gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
153
154 gl.setSwapInterval(0);
155
156 // validation ..
157 st.attachShaderProgram(gl, sp0, true);
158 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
159 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);
160 st.attachShaderProgram(gl, sp1, true);
161 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
162 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);
163
164 // warmup ..
165 for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) {
166 // SP0
167 st.attachShaderProgram(gl, sp0, true);
168 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
169 // SP1
170 st.attachShaderProgram(gl, sp1, true);
171 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
172 }
173
174 // measure ..
175 final long t0 = System.currentTimeMillis();
176 int frames;
177
178 for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames+=4) {
179 // SP0
180 st.attachShaderProgram(gl, sp0, true);
181 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
182 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
183 // SP1
184 st.attachShaderProgram(gl, sp1, true);
185 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
186 GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
187 }
188
189 final long t1 = System.currentTimeMillis();
190 final long dt = t1 - t0;
191 final double fps = ( frames * 1000.0 ) / dt;
192 final String fpsS = String.valueOf(fps);
193 final int fpsSp = fpsS.indexOf('.');
194 System.err.println("testShaderState01PerformanceDouble: "+dt/1000.0 +"s: "+ frames + "f, " + fpsS.substring(0, fpsSp+2) + " fps, "+dt/frames+" ms/f");
195
196 // cleanup
197 st.destroy(gl);
199 }
200
201 @Test
202 public void test11ShaderStateValidationSP1Linked() throws InterruptedException {
203 test1XShaderStateValidation(true);
204 }
205 @Test
206 public void test12ShaderStateValidationSP1Unlinked() throws InterruptedException {
207 test1XShaderStateValidation(false);
208 }
209
210 private void test1XShaderStateValidation(final boolean linkSP1) throws InterruptedException {
211 // preset ..
212 if(true) {
213 System.err.println("CCC01: GLProfile.initSingleton(); START");
215 System.err.println("CCC01: GLProfile.initSingleton(); DONE ");
216 }
217
218 System.err.println("CCC01: Win + Ctx creation incl 1st makeCurrent.");
219 final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(
220 new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
221 final GLDrawable drawable = winctx.context.getGLDrawable();
222 final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
223 System.err.println(winctx.context);
224
225 if(false) {
226 /**
227 * Bug 1398 OSX: If 'test12ShaderStateValidationSP1Unlinked()'
228 * runs w/o CGLLockContext, a GLError occurs on glClear(..):
229 *
230com.jogamp.opengl.GLException: Thread[main,5,main] glGetError() returned the following error codes after a call to glClear(<int> 0x4100): Unknown glGetError() return value: ( 1286 0x506),
231 at com.jogamp.opengl.DebugGL4bc.writeGLError(DebugGL4bc.java:31781)
232 at com.jogamp.opengl.DebugGL4bc.glClear(DebugGL4bc.java:1240)
233 at com.jogamp.opengl.test.junit.jogl.glsl.GLSLMiscHelper.displayVCArrays(GLSLMiscHelper.java:91)
234 at com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT.test1XShaderStateValidation(TestGLSLShaderState02NEWT.java:351)
235 at com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT.test12ShaderStateValidationSP1Unlinked(TestGLSLShaderState02NEWT.java:207)
236 */
237 System.err.println("CCC01: swap - release");
238 winctx.drawable.swapBuffers();
239 winctx.context.release();
240 Thread.sleep(16);
241 System.err.println("CCC01: makeCurrent");
242 final int res = winctx.context.makeCurrent();
243 Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
244 }
245
246 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
247
248 // test code ..
249 final ShaderState st = new ShaderState();
250
251 final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader",
252 "shader/bin", "RedSquareShader", true);
253 final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
254 "shader/bin", "RedSquareShader", true);
255 final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader",
256 "shader/bin", "RedSquareShader2", true);
257 rsVp0.defaultShaderCustomization(gl, true, true);
258 rsFp0.defaultShaderCustomization(gl, true, true);
259 rsFp1.defaultShaderCustomization(gl, true, true);
260
261 final ShaderProgram sp1 = new ShaderProgram();
262 sp1.add(rsVp0);
263 sp1.add(rsFp1);
264 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
265 Assert.assertTrue(0 == sp1.program());
266 Assert.assertTrue(sp1.init(gl));
267 Assert.assertTrue(0 != sp1.program());
268 Assert.assertTrue(!sp1.inUse());
269 Assert.assertTrue(!sp1.linked());
270 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
271 if(linkSP1) {
272 Assert.assertTrue(sp1.link(gl, System.err));
273 Assert.assertTrue(sp1.linked());
274 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
275 }
276
277 final ShaderProgram sp0 = new ShaderProgram();
278 sp0.add(rsVp0);
279 sp0.add(rsFp0);
280 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
281
282 Assert.assertTrue(0 == sp0.program());
283 Assert.assertTrue(sp0.init(gl));
284 Assert.assertTrue(0 != sp0.program());
285 Assert.assertTrue(!sp0.inUse());
286 Assert.assertTrue(!sp0.linked());
287 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
288
289 st.attachShaderProgram(gl, sp0, false);
290 Assert.assertTrue(!sp0.inUse());
291 Assert.assertTrue(!sp0.linked());
292
293 // Allocate Vertex Array0
294 final GLArrayDataServer vertices0 = GLSLMiscHelper.createVertices(gl, st, 0, vertices0_loc, GLSLMiscHelper.vertices0);
295 System.err.println("vertices0: " + vertices0);
296 vertices0.enableBuffer(gl, false);
297 Assert.assertEquals(vertices0_loc, vertices0.getLocation());
298
299 // Allocate Color Array0
300 final GLArrayDataServer colors0 = GLSLMiscHelper.createColors(gl, st, 0, colors0_loc, GLSLMiscHelper.colors0);
301 System.err.println("colors0: " + colors0);
302 colors0.enableBuffer(gl, false);
303 Assert.assertEquals(colors0_loc, colors0.getLocation());
304
305 Assert.assertTrue(sp0.link(gl, System.err));
306 Assert.assertTrue(sp0.linked());
307 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
308
309 Assert.assertEquals(vertices0_loc, vertices0.getLocation());
310 Assert.assertEquals(vertices0_loc, st.getAttribLocation(gl, vertices0.getName()));
311 Assert.assertEquals(vertices0_loc, gl.glGetAttribLocation(st.shaderProgram().program(), vertices0.getName()));
312
313 Assert.assertEquals(colors0_loc, colors0.getLocation());
314 Assert.assertEquals(colors0_loc, st.getAttribLocation(gl, colors0.getName()));
315 Assert.assertEquals(colors0_loc, gl.glGetAttribLocation(st.shaderProgram().program(), colors0.getName()));
316
317 st.useProgram(gl, true);
318 Assert.assertTrue(sp0.inUse());
319 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
320
321 // setup mgl_PMVMatrix
322 final PMVMatrix pmvMatrix = new PMVMatrix();
323 final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
324 st.ownUniform(pmvMatrixUniform);
325 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
326
327 st.uniform(gl, pmvMatrixUniform);
328 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
329 Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix"));
330
331 // Allocate Vertex Array1
332 final GLArrayDataServer vertices1 = GLSLMiscHelper.createVertices(gl, st, 0, -1, GLSLMiscHelper.vertices1);
333 System.err.println("vertices1: " + vertices1);
334 vertices1.enableBuffer(gl, false);
335
336 // Allocate Color Array1
337 final GLArrayDataServer colors1 = GLSLMiscHelper.createColors(gl, st, 0, -1, GLSLMiscHelper.colors1);
338 System.err.println("colors1: " + colors1);
339 colors1.enableBuffer(gl, false);
340
341 // misc GL setup
342 gl.glClearColor(0, 0, 0, 1);
344 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
345
346 // reshape
347 pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
348 pmvMatrix.glLoadIdentity();
349 pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float) drawable.getSurfaceWidth() / (float) drawable.getSurfaceHeight(), 1.0F, 100.0F);
350 pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
351 pmvMatrix.glLoadIdentity();
352 pmvMatrix.glTranslatef(0, 0, -10);
353 st.uniform(gl, pmvMatrixUniform);
354 gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
355 Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
356
357 // display #1 vertices0 / colors0 (post-disable)
358 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, durationPerTest);
359
360 // display #2 vertices1 / colors1 (post-disable)
361 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, durationPerTest);
362
363 // display #3 vertices0 / colors0 (post-disable)
364 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest);
365
366 // display #4 vertices1 / colors1 (post-disable)
367 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 4, durationPerTest);
368
369 // SP1
370 st.attachShaderProgram(gl, sp1, true);
371 Assert.assertTrue(sp1.inUse());
372 Assert.assertTrue(sp1.linked());
373
374 if(!linkSP1) {
375 // all attribute locations shall be same now, due to impl. glBindAttributeLocation
376 Assert.assertEquals(vertices0_loc, vertices0.getLocation());
377 Assert.assertEquals(vertices0_loc, st.getAttribLocation(gl, vertices0.getName()));
378 Assert.assertEquals(vertices0_loc, gl.glGetAttribLocation(st.shaderProgram().program(), vertices0.getName()));
379
380 Assert.assertEquals(colors0_loc, colors0.getLocation());
381 Assert.assertEquals(colors0_loc, st.getAttribLocation(gl, colors0.getName()));
382 Assert.assertEquals(colors0_loc, gl.glGetAttribLocation(st.shaderProgram().program(), colors0.getName()));
383 }
384
385 // display #1 vertices0 / colors0 (post-disable)
386 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 10, durationPerTest);
387
388 // display #2 vertices1 / colors1 (post-disable)
389 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 20, durationPerTest);
390
391 // display #3 vertices0 / colors0 (post-disable)
392 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 30, durationPerTest);
393
394 // display #4 vertices1 / colors1 (post-disable)
395 GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 40, durationPerTest);
396
397 // cleanup
398 st.destroy(gl);
399
400 NEWTGLContext.destroyWindow(winctx);
401 }
402
403 public static void main(final String args[]) throws IOException {
404 System.err.println("main - start");
405 boolean wait = false;
406 for(int i=0; i<args.length; i++) {
407 if(args[i].equals("-time")) {
408 durationPerTest = MiscUtils.atoi(args[++i], (int)durationPerTest);
409 }
410 if(args[i].equals("-wait")) {
411 wait = true;
412 }
413 }
414 if(wait) {
415 while(-1 == System.in.read()) ;
417 try {
419 } catch (final Exception e) {
420 e.printStackTrace();
421 }
422 } else {
423 final String tstname = TestGLSLShaderState02NEWT.class.getName();
424 org.junit.runner.JUnitCore.main(tstname);
425 System.err.println("main - end");
426 }
427 }
428}
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.
Abstraction for an OpenGL rendering context.
Definition: GLContext.java:74
static final int CONTEXT_CURRENT
Indicates that the context was made current during the last call to makeCurrent, value {@value}.
Definition: GLContext.java:114
static final int CONTEXT_CURRENT_NEW
Indicates that a newly-created context was made current during the last call to makeCurrent,...
Definition: GLContext.java:116
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
static void initSingleton()
Static initialization of JOGL.
Definition: GLProfile.java:204
GLSL uniform data wrapper encapsulating data to be uploaded to the GPU as a uniform.
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.
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 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 boolean attachShaderProgram(final GL2ES2 gl, final ShaderProgram prog, final boolean enable)
Attach or switch a shader program.
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
int glGetAttribLocation(int program, String name)
Entry point to C language function: GLint {@native glGetAttribLocation}(GLuint program,...
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.