JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
ElektronenMultiplizierer.java
Go to the documentation of this file.
1/**
2 * Copyright 2011 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.demos.es2;
30
31import static com.jogamp.opengl.GL.*;
32
33import java.nio.FloatBuffer;
34
35import com.jogamp.opengl.GL;
36import com.jogamp.opengl.GL2ES2;
37import com.jogamp.opengl.GLAutoDrawable;
38import com.jogamp.opengl.GLCapabilities;
39import com.jogamp.opengl.GLCapabilitiesImmutable;
40import com.jogamp.opengl.GLEventListener;
41import com.jogamp.opengl.GLProfile;
42import com.jogamp.opengl.GLUniformData;
43import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
44
45import com.jogamp.common.nio.Buffers;
46import com.jogamp.common.os.Clock;
47import com.jogamp.newt.event.KeyAdapter;
48import com.jogamp.newt.event.KeyEvent;
49import com.jogamp.newt.opengl.GLWindow;
50import com.jogamp.opengl.util.GLArrayDataServer;
51import com.jogamp.opengl.util.PMVMatrix;
52import com.jogamp.opengl.util.glsl.ShaderCode;
53import com.jogamp.opengl.util.glsl.ShaderProgram;
54import com.jogamp.opengl.util.glsl.ShaderState;
55
56/**
57 * <pre>
58 * __ __|_ ___________________________________________________________________________ ___|__ __
59 * // /\ _ /\ \\
60 * //____/ \__ __ _____ _____ _____ _____ _____ | | __ _____ _____ __ __/ \____\\
61 * \ \ / / __| | | __| _ | | _ | | | __| | | __| | /\ \ / /
62 * \____\/_/ | | | | | | | | | | | __| | | | | | | | | | |__ " \_\/____/
63 * /\ \ |_____|_____|_____|__|__|_|_|_|__| | | |_____|_____|_____|_____| _ / /\
64 * / \____\ http://jogamp.org |_| /____/ \
65 * \ / "' _________________________________________________________________________ `" \ /
66 * \/____. .____\/
67 * </pre>
68 *
69 * <p>
70 * JOGL2 port of my PC 4k intro competition entry for Revision 2011. Sure it got a little bigger
71 * while porting but the shader and control code remained more or less untouched. The intro renders
72 * a fullscreen billboard using a single fragment shader. The shader encapsulates basically two
73 * different routines: A sphere-tracing based raymarcher for a single fractal formula and a bitmap
74 * orbit trap julia+mandelbrot fractal renderer. Additionally an inline-processing analog-distortion
75 * filter is applied to all rendered fragments to make the overall look more interesting.
76 * </p>
77 *
78 * <p>
79 * The different intro parts are all parameter variations of the two routines in the fragment shader
80 * synched to the music: Parts 3+5 are obviously the mandelbrot and julia bitmap orbit traps, and parts
81 * 1,2,4 and 6 are pure fractal sphere tracing.
82 * </p>
83 *
84 * <p>
85 * During the development of the intro it turned out that perfectly raymarching every pixel of the orbit
86 * trapped julia+mandelbrot fractal was way to slow even on highend hardware. So I inserted a lowres
87 * intermediate FBO to be used by the bitmap based orbit trap routine wich was ofcourse way faster, but
88 * had the obvious upscaling artefacts. Maybe I'll produce a perfect quality version for very patient
89 * people with insane hardware :)
90 * </p>
91 *
92 * <p>
93 * Papers and articles you should be familiar with before trying to understand the code:
94 * </p>
95 *
96 * <p>
97 * <ul>
98 * <li>Distance rendering for fractals: http://www.iquilezles.org/www/articles/distancefractals/distancefractals.htm</li>
99 * <li>Geometric orbit traps: http://www.iquilezles.org/www/articles/ftrapsgeometric/ftrapsgeometric.htm</li>
100 * <li>Bitmap orbit traps: http://www.iquilezles.org/www/articles/ftrapsbitmap/ftrapsbitmap.htm</li>
101 * <li>Ambient occlusion techniques: http://www.iquilezles.org/www/articles/ao/ao.htm</li>
102 * <li>Sphere tracing: A geometric method for the antialiased ray tracing of implicit surfaces: http://graphics.cs.uiuc.edu/~jch/papers/zeno.pdf</li>
103 * <li>Rendering fractals with distance estimation function: http://www.iquilezles.org/www/articles/mandelbulb/mandelbulb.htm</li>
104 * </ul>
105 * </p>
106 *
107 * <p>
108 * <ul>
109 * <li>For an impression how this routine looks like see here: http://www.youtube.com/watch?v=lvC8maVHh8Q</li>
110 * <li>Original release from the Revision can be found here: http://www.pouet.net/prod.php?which=56860</li>
111 * </ul>
112 * </p>
113 *
114 * <p>
115 * http://www.youtube.com/user/DemoscenePassivist
116 * </p>
117 *
118 * @author Dominik Ströhlein (DemoscenePassivist)
119 */
121
122//BEGIN --- BaseGlobalEnvironment replacement ---
123
124 private final GLCapabilities mCaps;
125 // private final GLU mGlu;
126
127 private final String mCommandLineParameter_BaseRoutineClassName;
128 private final boolean mCommandLineParameter_MultiSampling;
129 private final int mCommandLineParameter_NumberOfSampleBuffers;
130 private final boolean mCommandLineParameter_AnisotropicFiltering;
131 private final float mCommandLineParameter_AnisotropyLevel;
132 private final boolean mCommandLineParameter_FrameCapture;
133 private final boolean mCommandLineParameter_FrameSkip;
134 private boolean mUsesFullScreenMode;
135 private int mFrameCounter;
136 private final int mCommandLineParameter_FrameRate;
137 private long mFrameSkipAverageFramerateTimeStart;
138 private long mFrameSkipAverageFramerateTimeEnd;
139 private boolean mFrameSkipManual;
140 // private int mSkippedFramesCounter;
141// private BaseMusic mBaseMusic;
142 boolean mMusicSyncStartTimeInitialized = false;
143
144 private ShaderState st;
145 private PMVMatrix pmvMatrix;
146 private GLUniformData pmvMatrixUniform;
147 private GLUniformData mScreenDimensionUniform;
148 private GLArrayDataServer vertices0;
149 // private GLArrayDataServer texCoords0;
150
151 public String getBaseRoutineClassName() { return mCommandLineParameter_BaseRoutineClassName; }
152 public boolean preferMultiSampling() { return mCommandLineParameter_MultiSampling; }
153 public int getNumberOfSamplingBuffers() { return mCommandLineParameter_NumberOfSampleBuffers; }
154 public boolean preferAnisotropicFiltering() { return mCommandLineParameter_AnisotropicFiltering; }
155 public float getAnisotropyLevel() { return mCommandLineParameter_AnisotropyLevel; }
156 public boolean wantsFrameCapture() { return mCommandLineParameter_FrameCapture; }
157 public int getDesiredFramerate() { return mCommandLineParameter_FrameRate; }
158 public boolean wantsFrameSkip() { return mCommandLineParameter_FrameSkip; }
159 public boolean usesFullScreenMode() { return mUsesFullScreenMode; }
160
161 class TimeShiftKeys extends KeyAdapter {
162 @Override
163 public void keyPressed(final KeyEvent e) {
164 if(KeyEvent.VK_RIGHT == e.getKeyCode()) {
165 skipFrames(120);
166 } else if(KeyEvent.VK_LEFT == e.getKeyCode()) {
167 skipFrames(-120);
168 }
169 }
170 }
171 TimeShiftKeys timeShiftKeys;
172
174 final String inBaseRoutineClassName,
175 final boolean inMultiSampling,
176 final int inNumberOfSampleBuffers,
177 final boolean inAnisotropicFiltering,
178 final float inAnisotropyLevel,
179 final boolean inFrameCapture,
180 final boolean inFrameSkip, final int desiredFrameRate, final int startFrame
181 ) {
182 // mGlu = new GLU();
183 mCommandLineParameter_BaseRoutineClassName = inBaseRoutineClassName;
184 mCommandLineParameter_MultiSampling = inMultiSampling;
185 mCommandLineParameter_NumberOfSampleBuffers = (inNumberOfSampleBuffers==-1) ? 2 : inNumberOfSampleBuffers;
186 mCommandLineParameter_AnisotropicFiltering = inAnisotropicFiltering;
187 mCommandLineParameter_AnisotropyLevel = (inAnisotropyLevel==-1.0f) ? 2.0f : inAnisotropyLevel;
188 mCommandLineParameter_FrameCapture = inFrameCapture;
189 mCommandLineParameter_FrameSkip = inFrameSkip;
190 mCommandLineParameter_FrameRate = desiredFrameRate;
192 if (preferMultiSampling()) {
193 // enable/configure multisampling support ...
194 mCaps.setSampleBuffers(true);
196 mCaps.setAccumAlphaBits(1);
197 mCaps.setAccumBlueBits(1);
198 mCaps.setAccumGreenBits(1);
199 mCaps.setAccumRedBits(1);
200 // turns out we need to have alpha, otherwise no AA will be visible
201 mCaps.setAlphaBits(1);
202 }
203
204 mFrameSkipAverageFramerateTimeStart = 0;
205 mFrameCounter = 0;
206 skipFrames(startFrame);
207 timeShiftKeys = new TimeShiftKeys();
208 }
209
211 this(null, false, -1, false, -1.0f, false, true, 30, 0);
212 }
213
214 /**
215 * skip frames by turning back start time
216 * @param frames positive or negative values
217 */
218 public void skipFrames(final int frames) {
219 final long dft = 1000000000/mCommandLineParameter_FrameRate;
220 mFrameSkipAverageFramerateTimeStart -= frames * dft ;
221 mFrameSkipManual = true;
222 }
223
225 return mCaps;
226 }
227
228 @Override
229 public void init(final GLAutoDrawable drawable) {
230 if(drawable instanceof GLWindow) {
231 final GLWindow glw = (GLWindow) drawable;
232 glw.addKeyListener(0, timeShiftKeys);
233 }
234 final GL2ES2 gl = drawable.getGL().getGL2ES2();
235 gl.setSwapInterval(1);
236
237 st = new ShaderState();
238 final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader",
239 "shader/bin", "default", true);
240 final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader",
241 "shader/bin", "elektronenmultiplizierer_development", true);
242 // "shader", "shader/bin", "elektronenmultiplizierer_port", true);
243 vp0.defaultShaderCustomization(gl, true, true);
244 fp0.defaultShaderCustomization(gl, true, true);
245
246 final ShaderProgram sp0 = new ShaderProgram();
247 sp0.add(gl, vp0, System.err);
248 sp0.add(gl, fp0, System.err);
249 st.attachShaderProgram(gl, sp0, true);
250
251 final float XRESf = drawable.getSurfaceWidth();
252 final float YRESf = drawable.getSurfaceHeight();
253
254 mScreenDimensionUniform = new GLUniformData("resolution", 2, Buffers.newDirectFloatBuffer(2));
255 final FloatBuffer mScreenDimensionV = (FloatBuffer) mScreenDimensionUniform.getBuffer();
256 mScreenDimensionV.put(0, XRESf);
257 mScreenDimensionV.put(1, YRESf);
258 st.ownUniform(mScreenDimensionUniform);
259 st.uniform(gl, mScreenDimensionUniform);
260
261 pmvMatrix = new PMVMatrix();
262 pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
263 st.ownUniform(pmvMatrixUniform);
264 st.uniform(gl, pmvMatrixUniform);
265
266 vertices0 = GLArrayDataServer.createGLSL("gca_Vertices", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
267 vertices0.putf(0); vertices0.putf(YRESf);
268 vertices0.putf(XRESf); vertices0.putf(YRESf);
269 vertices0.putf(0); vertices0.putf(0);
270 vertices0.putf(XRESf); vertices0.putf(0);
271 vertices0.seal(gl, true);
272 st.ownAttribute(vertices0, true);
273 vertices0.enableBuffer(gl, false);
274
275 /**
276 texCoords0 = GLArrayDataServer.createGLSL("gca_TexCoords", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
277 texCoords0.putf(0f); texCoords0.putf(1f);
278 texCoords0.putf(1f); texCoords0.putf(1f);
279 texCoords0.putf(0f); texCoords0.putf(0f);
280 texCoords0.putf(1f); texCoords0.putf(0f);
281 texCoords0.seal(gl, true);
282 st.ownAttribute(texCoords0, true);
283 texCoords0.enableBuffer(gl, false); */
284
285 //generate framebufferobject
286 final int[] result = new int[1];
287 gl.glGenTextures(1, result, 0);
288 mFrameBufferTextureID = result[0];
289 gl.glBindTexture(GL_TEXTURE_2D, mFrameBufferTextureID);
290 gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
291 gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
292 gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
293 gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 384, 384, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
294
295 //allocate the framebuffer object ...
296 gl.glGenFramebuffers(1, result, 0);
297 mFrameBufferObjectID = result[0];
298 gl.glBindFramebuffer(GL_FRAMEBUFFER, mFrameBufferObjectID);
299 gl.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mFrameBufferTextureID, 0);
300 gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
301 gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
302 st.uniform(gl, new GLUniformData("fb", 0));
303
304 // will be changed in display(..)
305 st.uniform(gl, new GLUniformData("en", 0));
306 st.uniform(gl, new GLUniformData("tm", 0.0f));
307 st.uniform(gl, new GLUniformData("br", 0.0f));
308 st.uniform(gl, new GLUniformData("et", 0.0f));
309
310 gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
311
312 // if NO music is used sync to mainloop start ...
313 // (add up current time due to possible turned back start time by skip frames)
314 mFrameSkipAverageFramerateTimeStart += Clock.currentNanos();
315
316// mBaseMusic = new BaseMusic(BaseGlobalEnvironment.getInstance().getMusicFileName());
317// mBaseMusic.init();
318// mBaseMusic.play();
319 }
320
321 @Override
322 public void display(final GLAutoDrawable drawable) {
323 if (wantsFrameSkip()) {
324 mFrameSkipAverageFramerateTimeEnd = Clock.currentNanos();
325 final double tDesiredFrameRate = getDesiredFramerate();
326 final double tSingleFrameTime = 1000000000.0f/tDesiredFrameRate;
327 final double tElapsedTime = mFrameSkipAverageFramerateTimeEnd - mFrameSkipAverageFramerateTimeStart;
328 final double mFrameCounterTargetValue = tElapsedTime/tSingleFrameTime;
329 final double mFrameCounterDifference = mFrameCounterTargetValue-mFrameCounter;
330 if (mFrameSkipManual || mFrameCounterDifference>2) {
331 mFrameCounter+=mFrameCounterDifference;
332 // mSkippedFramesCounter+=mFrameCounterDifference;
333 } else if (mFrameCounterDifference<-2) {
334 //hold framecounter advance ...
335 mFrameCounter--;
336 }
337 mFrameSkipManual = false;
338 }
339
340 final GL2ES2 gl = drawable.getGL().getGL2ES2();
341
342 final int XRES = drawable.getSurfaceWidth();
343 final int YRES = drawable.getSurfaceHeight();
344
345// if (!getBaseMusic().isOffline()) {
346// //if music IS used sync to first second of music ...
347// if (BaseRoutineRuntime.getInstance().getBaseMusic().getPositionInMilliseconds()>0 && !mMusicSyncStartTimeInitialized) {
348// BaseLogging.getInstance().info("Synching to BaseMusic ...");
349// mFrameSkipAverageFramerateTimeStart = (long)(Clock.currentNanos()-((double)BaseRoutineRuntime.getInstance().getBaseMusic().getPositionInMilliseconds()*1000000.0d));
350// mMusicSyncStartTimeInitialized = true;
351// }
352// }
353 //allow music DSP's to synchronize with framerate ...
354// mBaseMusic.synchonizeMusic();
355
356 //use this for offline rendering/capture ...
357 int MMTime_u_ms = (int)(((mFrameCounter)*44100.0f)/60.0f);
358 //use this for music synched rendering ...
359 //int MMTime_u_ms = (int)(BaseRoutineRuntime.getInstance().getBaseMusic().getPositionInMilliseconds()*(44100.0f/1000.0f));
360 //dedicated sync variable for each event ... kinda lame but who cares X-)
361 if (MMTime_u_ms>=522240 && !mSyncEvent_01) { mSyncEvent_01 = true; handleSyncEvent(MMTime_u_ms); }
362 if (MMTime_u_ms>=1305480 && !mSyncEvent_02) { mSyncEvent_02 = true; handleSyncEvent(MMTime_u_ms); }
363 if (MMTime_u_ms>=1827720 && !mSyncEvent_03) { mSyncEvent_03 = true; handleSyncEvent(MMTime_u_ms); }
364 if (MMTime_u_ms>=2349960 && !mSyncEvent_04) { mSyncEvent_04 = true; handleSyncEvent(MMTime_u_ms); }
365 if (MMTime_u_ms>=3394440 && !mSyncEvent_05) { mSyncEvent_05 = true; handleSyncEvent(MMTime_u_ms); }
366 if (MMTime_u_ms>=3916680 && !mSyncEvent_06) { mSyncEvent_06 = true; handleSyncEvent(MMTime_u_ms); }
367 if (MMTime_u_ms>=4438408 && !mSyncEvent_07) { mSyncEvent_07 = true; handleSyncEvent(MMTime_u_ms); }
368 if (MMTime_u_ms>=5482831 && !mSyncEvent_08) { mSyncEvent_08 = true; handleSyncEvent(MMTime_u_ms); }
369 //calculate current time based on 60fps reference framerate ...
370 MMTime_u_ms = (int)(((mFrameCounter)*44100.0f)/60.0f);
371 gl.glDisable(GL_CULL_FACE);
372 gl.glDisable(GL_DEPTH_TEST);
373
374 st.useProgram(gl, true);
375
376 vertices0.enableBuffer(gl, true);
377 // texCoords0.enableBuffer(gl, true);
378
380 pmvMatrix.glLoadIdentity();
381 pmvMatrix.glOrthof(0f, XRES, YRES, 0f, -1f, 1f);
383 pmvMatrix.glLoadIdentity();
384 st.uniform(gl, pmvMatrixUniform);
385
386 gl.glActiveTexture(GL_TEXTURE0);
387
388 //gogogo! O-)
389 float tBrightnessSync = 40.0f-((MMTime_u_ms-mSyncTime)/1000.0f);
390 if (tBrightnessSync<1) {
391 tBrightnessSync=1;
392 }
393 mEffectTime = (MMTime_u_ms-mEffectSyncTime)/100000.0f;
394
395 if (mSyncEventNumber==0 && mEffectTime<4.0f) {
396 //fadein and fullscreen rotate
397 tBrightnessSync = mEffectTime/4.0f;
398 } else if (mSyncEventNumber==8 && mEffectTime>12.0f) {
399 //fullscrenn mushroom transform
400 tBrightnessSync = 1.0f-((mEffectTime-12.0f)/3.5f);
401 }
402
403 if (mSyncEventNumber==0 || mSyncEventNumber==1) {
404 //zoomin from fog
405 mEffectNumber = 3;
406 mEffectTime *= 1.75;
407 final float tEffectTimeMax = 9.3f;
408 if (mEffectTime>=tEffectTimeMax) {
409 mEffectTime=tEffectTimeMax;
410 }
411 } else if(mSyncEventNumber==2 || mSyncEventNumber==3) {
412 //transform big after zoomin
413 mEffectNumber = 4;
414 mEffectTime *= 0.25f;
415 } else if(mSyncEventNumber==4) {
416 //mandelbrot orbit-trap zoomout
417 mEffectNumber = 1;
418 mEffectTime *= 0.0002f;
419 } else if(mSyncEventNumber==5 || mSyncEventNumber==6) {
420 //inside fractal
421 mEffectNumber = 5;
422 mEffectTime *= 0.02f;
423 } else if(mSyncEventNumber==7) {
424 //spiral orbit-trap
425 mEffectNumber = 0;
426 mEffectTime *= 0.02f;
427 } else if(mSyncEventNumber==8) {
428 //fadeout fractal
429 mEffectNumber = 6;
430 mEffectTime *= 0.364f;
431 }
432
433 gl.glBindFramebuffer(GL_FRAMEBUFFER, mFrameBufferObjectID);
434 // gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
435 final GLUniformData en = st.getUniform("en");
436 if(mSyncEventNumber==7) {
437 en.setData(2);
438 }
439 if(mSyncEventNumber==4) {
440 en.setData(7);
441 } else {
442 en.setData(0);
443 }
444 st.uniform(gl, en);
445
446 final GLUniformData et = st.getUniform("et");
447 st.uniform(gl, et.setData(9.1f));
448
449 st.uniform(gl, st.getUniform("tm").setData(MMTime_u_ms/40000.0f));
450 st.uniform(gl, st.getUniform("br").setData(tBrightnessSync));
451
453 //render to fbo only when using julia/mandel orbittrap ...
454 // gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
456 }
457 gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
458 st.uniform(gl, en.setData(mEffectNumber));
459 st.uniform(gl, et.setData(mEffectTime));
460
461 if( !gl.isGLcore() ) {
462 gl.glEnable(GL_TEXTURE_2D);
463 }
464 gl.glBindTexture(GL_TEXTURE_2D, mFrameBufferTextureID);
465
468
469 vertices0.enableBuffer(gl, false);
470 // texCoords0.enableBuffer(gl, false);
471 st.useProgram(gl, false);
472
473 //---
474 mFrameCounter++;
475 }
476
477 @Override
478 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
479 final GL2ES2 gl = drawable.getGL().getGL2ES2();
480
481 st.useProgram(gl, true);
482 vertices0.seal(false);
483 vertices0.rewind();
484 vertices0.putf(0); vertices0.putf(height);
485 vertices0.putf(width); vertices0.putf(height);
486 vertices0.putf(0); vertices0.putf(0);
487 vertices0.putf(width); vertices0.putf(0);
488 vertices0.seal(gl, true);
489 st.ownAttribute(vertices0, true);
490 vertices0.enableBuffer(gl, false);
491
492 final FloatBuffer mScreenDimensionV = (FloatBuffer) mScreenDimensionUniform.getBuffer();
493 mScreenDimensionV.put(0, width);
494 mScreenDimensionV.put(1, height);
495 st.uniform(gl, mScreenDimensionUniform);
496
497 st.useProgram(gl, false);
498 gl.glViewport(0, 0, width, height);
499 }
500
501 @Override
502 public void dispose(final GLAutoDrawable drawable) {
503 final GL2ES2 gl = drawable.getGL().getGL2ES2();
504 gl.glDeleteFramebuffers(1, new int[] { mFrameBufferObjectID }, 0);
505 gl.glDeleteTextures(1, new int[] { mFrameBufferTextureID }, 0);
506 st.destroy(gl);
507 if(drawable instanceof GLWindow) {
508 final GLWindow glw = (GLWindow) drawable;
509 glw.removeKeyListener(timeShiftKeys);
510 }
511 }
512
513// public BaseMusic getBaseMusic() {
514// return mBaseMusic;
515// }
516
517 public void resetFrameCounter() {
518 mFrameCounter = 0;
519 }
520
521//END --- BaseRoutineRuntime ---
522
524 protected int mFrameBufferObjectID;
525 protected int mSyncTime;
526 protected int mSyncEventNumber;
527 protected float mEffectTime;
528 protected int mEffectNumber;
529 protected int mEffectSyncTime;
530
531 protected boolean mSyncEvent_01;
532 protected boolean mSyncEvent_02;
533 protected boolean mSyncEvent_03;
534 protected boolean mSyncEvent_04;
535 protected boolean mSyncEvent_05;
536 protected boolean mSyncEvent_06;
537 protected boolean mSyncEvent_07;
538 protected boolean mSyncEvent_08;
539
540 public void handleSyncEvent(final int inMMTime_u_ms) {
541 mSyncTime = inMMTime_u_ms;
543 System.out.println("NEW SYNC EVENT! tSyncEventNumber="+mSyncEventNumber+" tSyncTime="+mSyncTime);
545 mEffectSyncTime = inMMTime_u_ms;
546 }
547 }
548
549}
final SyncMatrices4f getSyncPMv()
Returns SyncMatrices4f of 2 matrices within one FloatBuffer: P and Mv.
void setAlphaBits(final int alphaBits)
Sets the number of bits requested for the color buffer's alpha component.
static final short VK_RIGHT
Constant for the cursor- or numerical-pad right arrow key.
Definition: KeyEvent.java:817
final short getKeyCode()
Returns the virtual key code using a fixed mapping to the US keyboard layout.
Definition: KeyEvent.java:195
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
Definition: GLWindow.java:902
final void removeKeyListener(final KeyListener l)
Definition: GLWindow.java:912
Specifies a set of OpenGL capabilities.
void setAccumRedBits(final int accumRedBits)
Sets the number of bits requested for the accumulation buffer's red component.
void setAccumGreenBits(final int accumGreenBits)
Sets the number of bits requested for the accumulation buffer's green component.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
void setAccumBlueBits(final int accumBlueBits)
Sets the number of bits requested for the accumulation buffer's blue component.
void setAccumAlphaBits(final int accumAlphaBits)
Sets number of bits requested for accumulation buffer's alpha component.
void setSampleBuffers(final boolean enable)
Defaults to false.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static final String GL2ES2
The intersection of the desktop GL3, GL2 and embedded ES2 profile.
Definition: GLProfile.java:594
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
GLSL uniform data wrapper encapsulating data to be uploaded to the GPU as a uniform.
Buffer getBuffer()
Returns the data buffer.
GLUniformData setData(final int data)
ElektronenMultiplizierer(final String inBaseRoutineClassName, final boolean inMultiSampling, final int inNumberOfSampleBuffers, final boolean inAnisotropicFiltering, final float inAnisotropyLevel, final boolean inFrameCapture, final boolean inFrameSkip, final int desiredFrameRate, final int startFrame)
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 init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void skipFrames(final int frames)
skip frames by turning back start time
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void seal(final GL gl, final boolean seal)
Convenience method calling seal(boolean) and enableBuffer(GL, boolean).
void enableBuffer(final GL gl, final boolean enable)
Enables the buffer if enable is true, and transfers the data if required.
static GLArrayDataServer createGLSL(final String name, final int compsPerElement, final int dataType, final boolean normalized, final int initialElementCount, final int vboUsage)
Create a VBO, using a custom GLSL array attribute name and starting with a new created Buffer object ...
PMVMatrix implements a subset of the fixed function pipeline GLMatrixFunc using PMVMatrix4f.
Definition: PMVMatrix.java:62
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 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,...
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 ...
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.
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
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.
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.
boolean isGLcore()
Indicates whether this GL object uses a GL core profile.
Specifies an immutable set of OpenGL capabilities.
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.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, int level)
Entry point to C language function: void {@native glFramebufferTexture2D}(GLenum target,...
void glDrawArrays(int mode, int first, int count)
Entry point to C language function: void {@native glDrawArrays}(GLenum mode, GLint first,...
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
void glDeleteTextures(int n, IntBuffer textures)
Entry point to C language function: void {@native glDeleteTextures}(GLsizei n, const GLuint * textur...
void glBindTexture(int target, int texture)
Entry point to C language function: void {@native glBindTexture}(GLenum target, GLuint texture) Pa...
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
void glDisable(int cap)
Entry point to C language function: void {@native glDisable}(GLenum cap) Part of GL_ES_VERSION_2_0...
void glGenTextures(int n, IntBuffer textures)
Entry point to C language function: void {@native glGenTextures}(GLsizei n, GLuint * textures) Par...
void glGenFramebuffers(int n, IntBuffer framebuffers)
Entry point to C language function: void {@native glGenFramebuffers}(GLsizei n, GLuint * framebuffer...
void glDeleteFramebuffers(int n, IntBuffer framebuffers)
Entry point to C language function: void {@native glDeleteFramebuffers}(GLsizei n,...
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,...
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 glTexParameteri(int target, int pname, int param)
Entry point to C language function: void {@native glTexParameteri}(GLenum target,...
static final int GL_TRIANGLE_STRIP
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRIANGLE_STRIP" with ...
Definition: GL.java:760
void glBindFramebuffer(int target, int framebuffer)
Entry point to C language function: void {@native glBindFramebuffer}(GLenum target,...
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,...
void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, Buffer pixels)
Entry point to C language function: void {@native glTexImage2D}(GLenum target, GLint level,...
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
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.