JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TextureSequenceCubeES2.java
Go to the documentation of this file.
1/**
2 * Copyright 2012-2023 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.demos.es2;
29
30import java.nio.FloatBuffer;
31
32import com.jogamp.opengl.GL;
33import com.jogamp.opengl.GL2ES2;
34import com.jogamp.opengl.GLAutoDrawable;
35import com.jogamp.opengl.GLES2;
36import com.jogamp.opengl.GLEventListener;
37import com.jogamp.opengl.GLException;
38import com.jogamp.opengl.GLProfile;
39import com.jogamp.opengl.GLUniformData;
40import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
41import com.jogamp.common.os.Platform;
42import com.jogamp.math.FloatUtil;
43import com.jogamp.newt.Window;
44import com.jogamp.newt.event.MouseAdapter;
45import com.jogamp.newt.event.MouseEvent;
46import com.jogamp.newt.event.MouseListener;
47import com.jogamp.opengl.GLExtensions;
48import com.jogamp.opengl.util.GLArrayDataServer;
49import com.jogamp.opengl.util.PMVMatrix;
50import com.jogamp.opengl.util.glsl.ShaderCode;
51import com.jogamp.opengl.util.glsl.ShaderProgram;
52import com.jogamp.opengl.util.glsl.ShaderState;
53import com.jogamp.opengl.util.texture.Texture;
54import com.jogamp.opengl.util.texture.TextureCoords;
55import com.jogamp.opengl.util.texture.TextureSequence;
56import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame;
57
58public class TextureSequenceCubeES2 implements GLEventListener {
59 public TextureSequenceCubeES2 (final TextureSequence texSource, final boolean innerCube, final float zoom0, final float rotx, final float roty) {
60 this.texSeq = texSource;
61 this.innerCube = innerCube;
62 this.zoom = zoom0;
63 this.view_rotx = rotx;
64 this.view_roty = roty;
65 }
66
67 private TextureSequence texSeq;
70 private GLUniformData pmvMatrixUniform;
71 // private TextureCoords[] textureCoords = null;
72 private float nearPlaneNormalized;
73 // private float zoom0=-5.0f, zoom=zoom0;
74 // private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
75 public float zoom=-2.3f;
76 private float view_rotx = 0.0f, view_roty = 0.0f;
77 private final float view_rotz = 0.0f;
78 int[] vboNames = new int[4];
79 boolean innerCube;
80
81 private final MouseListener mouseAction = new MouseAdapter() {
82 int lx = 0;
83 int ly = 0;
84 boolean first = false;
85
86 @Override
87 public void mousePressed(final MouseEvent e) {
88 first = true;
89 }
90 @Override
91 public void mouseMoved(final MouseEvent e) {
92 first = false;
93 }
94 @Override
95 public void mouseDragged(final MouseEvent e) {
96 int width, height;
97 final Object source = e.getSource();
98 Window window = null;
99 if(source instanceof Window) {
100 window = (Window) source;
101 width=window.getSurfaceWidth();
102 height=window.getSurfaceHeight();
103 } else if (source instanceof GLAutoDrawable) {
104 final GLAutoDrawable glad = (GLAutoDrawable) source;
105 width = glad.getSurfaceWidth();
106 height = glad.getSurfaceHeight();
107 } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
108 final java.awt.Component comp = (java.awt.Component) source;
109 width=comp.getWidth(); // FIXME HiDPI: May need to convert window units -> pixel units!
110 height=comp.getHeight();
111 } else {
112 throw new RuntimeException("Event source neither Window nor Component: "+source);
113 }
114 if(e.getPointerCount()==2) {
115 // 2 pointers zoom ..
116 if(first) {
117 lx = Math.abs(e.getY(0)-e.getY(1));
118 first=false;
119 return;
120 }
121 final int nv = Math.abs(e.getY(0)-e.getY(1));
122 final int dy = nv - lx;
123
124 {
125 final float o = zoom;
126 final float d = 40f*Math.signum(dy)/height;
127 zoom += d;
128 System.err.println("zoom.d: "+o+" + "+d+" -> "+zoom);
129 }
130
131 lx = nv;
132 } else {
133 // 1 pointer rotate
134 if(first) {
135 lx = e.getX();
136 ly = e.getY();
137 first=false;
138 return;
139 }
140 final int nx = e.getX();
141 final int ny = e.getY();
142 view_roty += 360f * ( (float)( nx - lx ) / (float)width );
143 view_rotx += 360f * ( (float)( ny - ly ) / (float)height );
144 lx = nx;
145 ly = ny;
146 }
147 }
148 @Override
149 public void mouseWheelMoved(final MouseEvent e) {
150 // System.err.println("XXX "+e);
151 if( !e.isShiftDown() ) {
152 final float o = zoom;
153 final float d = e.getRotation()[1]/10f; // vertical: wheel
154 zoom += d;
155 System.err.println("zoom.w: "+o+" + "+d+" -> "+zoom);
156 }
157 }
158 };
159
160 static final String shaderBasename = "texsequence_xxx";
161 static final String myTextureLookupName = "myTexture2D";
162
163 private void initShader(final GL2ES2 gl) {
164 // Create & Compile the shader objects
165 final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
166 "shader", "shader/bin", shaderBasename, true);
167 final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
168 "shader", "shader/bin", shaderBasename, true);
169
170 boolean preludeGLSLVersion = true;
173 throw new GLException(GLExtensions.OES_EGL_image_external+" requested but not available");
174 }
175 if( Platform.OSType.ANDROID == Platform.getOSType() && gl.isGLES3() ) {
176 // Bug on Nexus 10, ES3 - Android 4.3, where
177 // GL_OES_EGL_image_external extension directive leads to a failure _with_ '#version 300 es' !
178 // P0003: Extension 'GL_OES_EGL_image_external' not supported
179 preludeGLSLVersion = false;
180 }
181 }
182 rsVp.defaultShaderCustomization(gl, preludeGLSLVersion, true);
183
184 int rsFpPos = preludeGLSLVersion ? rsFp.addGLSLVersion(gl) : 0;
185 rsFpPos = rsFp.insertShaderSource(0, rsFpPos, texSeq.getRequiredExtensionsShaderStub());
186 rsFp.addDefaultShaderPrecision(gl, rsFpPos);
187
188 final String texLookupFuncName = texSeq.setTextureLookupFunctionName(myTextureLookupName);
189 rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);
190
191 // Inject TextureSequence shader details
192 final StringBuilder sFpIns = new StringBuilder();
193 sFpIns.append("uniform ").append(texSeq.getTextureSampler2DType()).append(" mgl_ActiveTexture;\n");
194 sFpIns.append(texSeq.getTextureLookupFragmentShaderImpl());
195 rsFp.insertShaderSource(0, "TEXTURE-SEQUENCE-CODE-BEGIN", 0, sFpIns);
196
197 // Create & Link the shader program
198 final ShaderProgram sp = new ShaderProgram();
199 sp.add(rsVp);
200 sp.add(rsFp);
201 if(!sp.link(gl, System.err)) {
202 throw new GLException("Couldn't link program: "+sp);
203 }
204
205 // Let's manage all our states using ShaderState.
206 st = new ShaderState();
207 st.attachShaderProgram(gl, sp, false);
208 }
209
210 GLArrayDataServer interleavedVBO, cubeIndicesVBO;
211
212 @Override
213 public void init(final GLAutoDrawable drawable) {
214 final GL2ES2 gl = drawable.getGL().getGL2ES2();
215 final TextureFrame frame = texSeq.getLastTexture();
216 if( null == frame ) {
217 return;
218 }
219 final Texture tex= frame.getTexture();
220
221 initShader(gl);
222
223 // Push the 1st uniform down the path
224 st.useProgram(gl, true);
225
226 pmvMatrix = new PMVMatrix();
227 reshapePMV(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
228 pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv()); // P, Mv
229 if(!st.uniform(gl, pmvMatrixUniform)) {
230 throw new GLException("Error setting PMVMatrix in shader: "+st);
231 }
232 if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", texSeq.getTextureUnit()))) {
233 throw new GLException("Error setting mgl_ActiveTexture in shader: "+st);
234 }
235
236
237 // calculate centered tex coords w/ aspect ratio
238 final float[] fixedCubeTexCoords = new float[s_cubeTexCoords.length];
239 {
240 final float aspect = tex.getAspectRatio();
241 final TextureCoords tc = tex.getImageTexCoords();
242 System.err.println("XXX0: aspect: "+aspect);
243 System.err.println("XXX0: y-flip: "+tex.getMustFlipVertically());
244 System.err.println("XXX0: "+tc);
245 final float tc_x1 = Math.max(tc.left(), tc.right());
246 final float tc_y1 = Math.max(tc.bottom(), tc.top());
247 final float ss=1f, ts=aspect; // scale tex-coord
248 final float dy = ( 1f - aspect ) / 2f ;
249 for(int i=0; i<s_cubeTexCoords.length; i+=2) {
250 final float tx = s_cubeTexCoords[i+0];
251 final float ty = s_cubeTexCoords[i+1];
252 if(tx!=0) {
253 fixedCubeTexCoords[i+0] = tc_x1 * ss;
254 }
255 if(ty==0 && !tex.getMustFlipVertically() || ty!=0 && tex.getMustFlipVertically()) {
256 fixedCubeTexCoords[i+1] = 0f + dy;
257 } else {
258 fixedCubeTexCoords[i+1] = tc_y1 * ts + dy;
259 }
260 }
261 }
262
263 interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*6*4, GL.GL_STATIC_DRAW);
264 {
265 interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
266 interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
267 //interleavedVBO.addGLSLSubArray("mgl_Normal", 3, GL.GL_ARRAY_BUFFER);
268 interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
269
270 final FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer();
271
272 for(int i=0; i<6*4; i++) {
273 ib.put(s_cubeVertices, i*3, 3);
274 ib.put(s_cubeColors, i*4, 4);
275 //ib.put(s_cubeNormals, i*3, 3);
276 ib.put(fixedCubeTexCoords, i*2, 2);
277 }
278 }
279 interleavedVBO.seal(gl, true);
280 interleavedVBO.enableBuffer(gl, false);
281 st.ownAttribute(interleavedVBO, true);
282
284 for(int i=0; i<6*6; i++) {
285 cubeIndicesVBO.puts(s_cubeIndices[i]);
286 }
287 cubeIndicesVBO.seal(gl, true);
288 cubeIndicesVBO.enableBuffer(gl, false);
289 st.ownAttribute(cubeIndicesVBO, true);
290
291
293
294 st.useProgram(gl, false);
295
296 final Object upstreamWidget = drawable.getUpstreamWidget();
297 if (upstreamWidget instanceof Window) {
298 final Window window = (Window) upstreamWidget;
299 window.addMouseListener(mouseAction);
300 } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) {
301 final java.awt.Component comp = (java.awt.Component) upstreamWidget;
302 new com.jogamp.newt.event.awt.AWTMouseAdapter(mouseAction, drawable).addTo(comp);
303 }
304
305 // Let's show the completed shader state ..
306 System.out.println("iVBO: "+interleavedVBO);
307 System.out.println(st);
308 }
309
310 @Override
311 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
312 final GL2ES2 gl = drawable.getGL().getGL2ES2();
313
314 gl.glViewport(0, 0, width, height);
315
316 if(!innerCube) {
317 // lights on
318 } else {
319 // lights off
320 }
321 // gl.glEnable(GL.GL_CULL_FACE);
322 // gl.glDisable(GL.GL_DITHER);
323
324 if(null != st) {
325 reshapePMV(width, height);
326 st.useProgram(gl, true);
327 st.uniform(gl, pmvMatrixUniform);
328 st.useProgram(gl, false);
329 }
330 }
331
332
333 private void reshapePMV(final int width, final int height) {
334 if(null != pmvMatrix) {
337 if(!innerCube) {
338 pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float)width / (float)height, 1f, 10.0f);
339 nearPlaneNormalized = 1f/(100f-1f);
340 } else {
341 pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 10.0f);
342 nearPlaneNormalized = 0f;
343 }
344 System.err.println("XXX0: Perspective nearPlaneNormalized: "+nearPlaneNormalized);
345
346 pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
349 }
350 }
351
352
353 @Override
354 public void dispose(final GLAutoDrawable drawable) {
355 final GL2ES2 gl = drawable.getGL().getGL2ES2();
356
357 texSeq = null;
358 pmvMatrixUniform = null;
359 pmvMatrix=null;
360 if( null != st ) {
361 st.destroy(gl);
362 st=null;
363 }
364 }
365
366 @Override
367 public void display(final GLAutoDrawable drawable) {
368 final GL2ES2 gl = drawable.getGL().getGL2ES2();
369
370 if(innerCube) {
371 // Clear background to white
372 gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f);
373 } else {
374 // Clear background to blue
375 gl.glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
376 }
378
379 if( null == st ) {
380 return;
381 }
382
383 st.useProgram(gl, true);
384
388 pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
389 pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
390 pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
391 st.uniform(gl, pmvMatrixUniform);
392 interleavedVBO.enableBuffer(gl, true);
393 Texture tex = null;
394 if(null!=texSeq) {
395 final TextureSequence.TextureFrame texFrame = texSeq.getNextTexture(gl);
396 if(null != texFrame) {
397 tex = texFrame.getTexture();
399 tex.enable(gl);
400 tex.bind(gl);
401 }
402 }
403 cubeIndicesVBO.bindBuffer(gl, true); // keeps VBO binding
404 gl.glDrawElements(GL.GL_TRIANGLES, cubeIndicesVBO.getElemCount() * cubeIndicesVBO.getCompsPerElem(), GL.GL_UNSIGNED_SHORT, 0);
405 cubeIndicesVBO.bindBuffer(gl, false);
406
407 if(null != tex) {
408 tex.disable(gl);
409 }
410 interleavedVBO.enableBuffer(gl, false);
411 st.useProgram(gl, false);
412 }
413
414 static final float[] light_position = { -50.f, 50.f, 50.f, 0.f };
415 static final float[] light_ambient = { 0.125f, 0.125f, 0.125f, 1.f };
416 static final float[] light_diffuse = { 1.0f, 1.0f, 1.0f, 1.f };
417 static final float[] material_spec = { 1.0f, 1.0f, 1.0f, 0.f };
418 static final float[] zero_vec4 = { 0.0f, 0.0f, 0.0f, 0.f };
419
420 private static final float[] s_cubeVertices = /* f b t b r l */
421 {
422 -1f, 1f, 1f, 1f, -1f, 1f, 1f, 1f, 1f, -1f, -1f, 1f,
423
424 -1f, 1f, -1f, 1f, -1f, -1f, 1f, 1f, -1f, -1f, -1f, -1f,
425
426 -1f, -1f, 1f, 1f, -1f, -1f, 1f, -1f, 1f, -1f, -1f, -1f,
427
428 -1f, 1f, 1f, 1f, 1f, -1f, 1f, 1f, 1f, -1f, 1f, -1f,
429
430 1f, -1f, 1f, 1f, 1f, -1f, 1f, 1f, 1f, 1f, -1f, -1f,
431
432 -1f, -1f, 1f, -1f, 1f, -1f, -1f, 1f, 1f, -1f, -1f, -1f
433 };
434
435 private static final float[] s_cubeTexCoords =
436 { // LT RB RT LB
437 0f, 1f, 1f, 0f, 1f, 1f, 0f, 0f,
438
439 0f, 1f, 1f, 0f, 1f, 1f, 0f, 0f,
440
441 0f, 1f, 1f, 0f, 1f, 1f, 0f, 0f,
442
443 0f, 1f, 1f, 0f, 1f, 1f, 0f, 0f,
444
445 0f, 0f, 1f, 1f, 0f, 1f, 1f, 0f,
446
447 0f, 0f, 1f, 1f, 0f, 1f, 1f, 0f,
448 };
449
450 private static final float[] s_cubeColors =
451 {
452 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f,
453
454 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
455 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
456
457 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
458 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
459
460 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f,
461 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f,
462
463 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f,
464 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f,
465
466 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f,
467 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f
468 };
469
470 /*
471 private static final float[] s_cubeNormals =
472 {
473 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f,
474
475 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f,
476
477 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f,
478
479 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f,
480
481 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f,
482
483 -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f
484 };*/
485 private static final short[] s_cubeIndices =
486 {
487 0, 3, 1, 2, 0, 1, /* front */
488 6, 5, 4, 5, 7, 4, /* back */
489 8, 11, 9, 10, 8, 9, /* top */
490 15, 12, 13, 12, 14, 13, /* bottom */
491 16, 19, 17, 18, 16, 17, /* right */
492 23, 20, 21, 20, 22, 21 /* left */
493 };
494}
495
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.
final boolean isShiftDown()
getModifiers() contains SHIFT_MASK.
Pointer event of type PointerType.
Definition: MouseEvent.java:74
final int getPointerCount()
See details for multiple-pointer events.
final int getY()
See details for multiple-pointer events.
final float[] getRotation()
Returns a 3-component float array filled with the values of the rotational axis in the following orde...
final int getX()
See details for multiple-pointer events.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Class holding OpenGL extension strings, commonly used by JOGL's implementation.
static final String OES_EGL_image_external
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
GLSL uniform data wrapper encapsulating data to be uploaded to the GPU as a uniform.
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Called by the drawable during the first repaint after the component has been resized.
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
TextureSequenceCubeES2(final TextureSequence texSource, final boolean innerCube, final float zoom0, final float rotx, final float roty)
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
static GLArrayDataServer createGLSLInterleaved(final int compsPerElement, final int dataType, final boolean normalized, final int initialElementCount, final int vboUsage)
Create a VBO for GLSL interleaved array data starting with a new created Buffer object with initialEl...
static GLArrayDataServer createData(final int compsPerElement, final int dataType, final int stride, final Buffer buffer, final int vboUsage, final int vboTarget)
Create a VBO data object for any target w/o render pipeline association, ie GL#GL_ELEMENT_ARRAY_BUFFE...
GLArrayDataWrapper addGLSLSubArray(final String name, final int comps, final int vboTarget)
Configure a segment of this GLSL interleaved array (see createGLSLInterleaved(int,...
Buffer getBuffer()
The Buffer holding the data, may be null if a GPU buffer without client bound data.
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 glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)
Multiply the current matrix with the orthogonal matrix.
Definition: PMVMatrix.java:469
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 glRotatef(final float ang_deg, final float x, final float y, final float z)
Rotate the current matrix.
Definition: PMVMatrix.java:413
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.
final int addGLSLVersion(final GL2ES2 gl)
Add GLSL version at the head 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 replaceInShaderSource(final String oldName, final String newName)
Replaces oldName with newName in all shader sources.
final int addDefaultShaderPrecision(final GL2ES2 gl, int pos)
Adds default precision to source code at given position if required, i.e.
int insertShaderSource(final int shaderIdx, final String tag, final int fromIndex, final CharSequence data)
Adds data after the line containing tag.
ShaderState allows to sharing data between shader programs, while updating the attribute and uniform ...
void ownAttribute(final GLArrayData attribute, final boolean own)
Binds or unbinds the GLArrayData lifecycle to this ShaderState.
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.
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.
Specifies texture coordinates for a rectangular area of a texture.
Texture holder interface, maybe specialized by implementation to associated related data.
Represents an OpenGL texture object.
Definition: Texture.java:173
TextureCoords getImageTexCoords()
Returns the set of texture coordinates corresponding to the entire image.
Definition: Texture.java:480
void bind(final GL gl)
Binds this texture to the given GL context.
Definition: Texture.java:377
boolean getMustFlipVertically()
Indicates whether this texture's texture coordinates must be flipped vertically in order to properly ...
Definition: Texture.java:536
void disable(final GL gl)
Disables this texture's target (e.g., GL_TEXTURE_2D) in the given GL state.
Definition: Texture.java:357
float getAspectRatio()
Returns the original aspect ratio of the image, defined as (image width) / (image height),...
Definition: Texture.java:468
void enable(final GL gl)
Enables this texture's target (e.g., GL_TEXTURE_2D) in the given GL context's state.
Definition: Texture.java:330
int getSurfaceWidth()
Returns the width of the client area excluding insets (window decorations) in pixel units.
int getSurfaceHeight()
Returns the height of the client area excluding insets (window decorations) in pixel units.
Specifying NEWT's Window functionality:
Definition: Window.java:115
void addMouseListener(MouseListener l)
Appends the given MouseListener to the end of the list.
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
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
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
Object getUpstreamWidget()
Method may return the upstream UI toolkit object holding this GLAutoDrawable instance,...
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
boolean isExtensionAvailable(String glExtensionName)
Returns true if the specified OpenGL extension can be used successfully through this GL instance give...
boolean isGLES3()
Indicates whether this GL object conforms to the OpenGL ES ≥ 3.0 profile.
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_TEXTURE_EXTERNAL_OES
GL_OES_EGL_image_external Define "GL_TEXTURE_EXTERNAL_OES" with expression '0x8D65',...
Definition: GLES2.java:57
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
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_TRIANGLES
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRIANGLES" with expre...
Definition: GL.java:145
void glDrawElements(int mode, int count, int type, long indices_buffer_offset)
Entry point to C language function: void {@native glDrawElements}(GLenum mode, GLsizei count,...
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_UNSIGNED_SHORT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_SHORT" with ...
Definition: GL.java:346
static final int GL_COLOR_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_COLOR_BUFFER_BIT" wit...
Definition: GL.java:390
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 glActiveTexture(int texture)
Entry point to C language function: void {@native glActiveTexture}(GLenum texture) Part of GL_ES_V...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
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,...
static final int GL_TEXTURE0
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_ARB_multitexture Alias for: GL_TEXTURE0_ARB ...
Definition: GL.java:71
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" wit...
Definition: GL.java:738
static final int GL_ELEMENT_ARRAY_BUFFER
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_ELEME...
Definition: GL.java:318
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
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.
Protocol for texture sequences, like animations, movies, etc.
TextureFrame getLastTexture()
Returns the last updated texture.
int getTextureTarget()
Returns the texture target used by implementation.
String getTextureLookupFragmentShaderImpl()
Returns the complete texture2D lookup function code of type.
String getTextureSampler2DType()
Returns either sampler2D or samplerExternalOES depending on getLastTexture().
String setTextureLookupFunctionName(String texLookupFuncName)
Set the desired shader code's texture lookup function name.
int getTextureUnit()
Return the texture unit used to render the current frame.
TextureFrame getNextTexture(GL gl)
Returns the next texture to be rendered.
String getRequiredExtensionsShaderStub()
In case a shader extension is required, based on the implementation and the runtime GL profile,...