Compare commits
10 Commits
cda5588558
...
7478e90cb5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7478e90cb5 | ||
|
|
90fc282c7c | ||
|
|
66ddcb0c98 | ||
|
|
94a468d932 | ||
|
|
58e8505660 | ||
|
|
1aad27e011 | ||
|
|
d83f672e31 | ||
|
|
3fefecbc9a | ||
|
|
a4a3d4c81e | ||
|
|
19a9ade24d |
20
.classpath
Normal file
20
.classpath
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/gluegen-rt-natives-linux-amd64.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gluegen-rt-natives-linux-i586.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gluegen-rt-natives-macosx-universal.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gluegen-rt-natives-windows-amd64.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gluegen-rt-natives-windows-i586.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gluegen-rt.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jogl-all-natives-linux-amd64.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jogl-all-natives-linux-i586.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jogl-all-natives-macosx-universal.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jogl-all-natives-windows-amd64.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jogl-all-natives-windows-i586.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jogl-all-noawt.jar"/>
|
||||
<classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/slf4j-simple-1.7.2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
.project
Normal file
17
.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>jogl-compute-shaders-fireworks</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -1,14 +1,21 @@
|
||||
package com.persesgames.jogl;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.media.opengl.DebugGL4;
|
||||
import javax.media.opengl.GL;
|
||||
import javax.media.opengl.GL2;
|
||||
import javax.media.opengl.GL2ES2;
|
||||
import javax.media.opengl.GL4;
|
||||
import javax.media.opengl.GLAutoDrawable;
|
||||
import javax.media.opengl.GLEventListener;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jogamp.newt.event.KeyEvent;
|
||||
import com.jogamp.newt.opengl.GLWindow;
|
||||
import com.persesgames.jogl.explosion.ExplosionComputeHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.media.opengl.*;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Date: 10/25/13
|
||||
@@ -17,9 +24,9 @@ import java.util.concurrent.TimeUnit;
|
||||
public class Renderer implements GLEventListener {
|
||||
private final static Logger logger = LoggerFactory.getLogger(Renderer.class);
|
||||
|
||||
private final static int MAX_ENTITIES_PER_COLOR = 2000000;
|
||||
//private final static int MAX_ENTITIES_PER_COLOR = 2000000;
|
||||
|
||||
private final Random random = new Random(System.nanoTime());
|
||||
//private final Random random = new Random(System.nanoTime());
|
||||
|
||||
private volatile boolean stopped = false;
|
||||
private volatile boolean dirty = true;
|
||||
@@ -33,7 +40,7 @@ public class Renderer implements GLEventListener {
|
||||
private boolean checkError = false;
|
||||
|
||||
private long lastLog = System.nanoTime();
|
||||
private long start = System.currentTimeMillis();
|
||||
//private long start = System.currentTimeMillis();
|
||||
private Timer timer = new Timer(TimeUnit.SECONDS, 1);
|
||||
|
||||
private ExplosionComputeHandler explosionComputeHandler;
|
||||
@@ -68,7 +75,7 @@ public class Renderer implements GLEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
stopped = keyboard.isPressed(KeyEvent.VK_ESCAPE);
|
||||
stopped |= keyboard.isPressed(KeyEvent.VK_ESCAPE);
|
||||
}
|
||||
|
||||
Renderer.this.glWindow.destroy();
|
||||
@@ -95,10 +102,10 @@ public class Renderer implements GLEventListener {
|
||||
gl.glGetIntegerv(GL2.GL_MAX_VERTEX_ATTRIBS, result, 0);
|
||||
logger.info("GL_MAX_VERTEX_ATTRIBS=" + result[0]);
|
||||
|
||||
gl.glGetIntegerv(GL4.GL_MAX_COMPUTE_WORK_GROUP_SIZE, result, 0);
|
||||
glGetIntegerIndexed(gl, GL4.GL_MAX_COMPUTE_WORK_GROUP_SIZE, result);
|
||||
logger.info("GL_MAX_COMPUTE_WORK_GROUP_SIZE= {},{},{}", result[0], result[1], result[2]);
|
||||
|
||||
gl.glGetIntegerv(GL4.GL_MAX_COMPUTE_WORK_GROUP_COUNT, result, 0);
|
||||
glGetIntegerIndexed(gl, GL4.GL_MAX_COMPUTE_WORK_GROUP_COUNT, result);
|
||||
logger.info("GL_MAX_COMPUTE_WORK_GROUP_COUNT= {},{},{}", result[0], result[1], result[2]);
|
||||
|
||||
explosionComputeHandler = new ExplosionComputeHandler(gl);
|
||||
@@ -109,9 +116,16 @@ public class Renderer implements GLEventListener {
|
||||
timer.stop("init");
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/39004898/get-maximum-workgroup-size-for-compute-shaders
|
||||
private static void glGetIntegerIndexed(GL4 gl, int target, int[] data) {
|
||||
for(int i = 0; i < data.length; i++) {
|
||||
gl.glGetIntegeri_v(target, i, data, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(GLAutoDrawable drawable) {
|
||||
stop();
|
||||
explosionComputeHandler.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.persesgames.jogl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Date: 1/4/14
|
||||
* Time: 8:00 PM
|
||||
@@ -17,7 +17,7 @@ public class Timer {
|
||||
private Map<String, Long> start = new HashMap<>();
|
||||
private Map<String, Long> times = new HashMap<>();
|
||||
private Map<String, Long> calls = new HashMap<>();
|
||||
private long nanoStart = System.nanoTime();
|
||||
//private long nanoStart = System.nanoTime();
|
||||
|
||||
private final TimeUnit unit;
|
||||
private final int units;
|
||||
@@ -93,7 +93,7 @@ public class Timer {
|
||||
if (System.nanoTime() > (lastLog + unit.toNanos(units))) {
|
||||
|
||||
for (String timer : times.keySet()) {
|
||||
logger.info("Timer '{}' calls '{}' time '{}ms' time/call '{}ms'", timer, getCalls(timer), (getTime(timer) / 1000000d), (getTime(timer) / 1000000d) / (double)getCalls(timer));
|
||||
logger.info("Timer '{}' calls '{}' time '{}ms' time/call '{}ms'", timer, getCalls(timer), (getTime(timer) / 1000000d), (getTime(timer) / 1000000d) / getCalls(timer));
|
||||
}
|
||||
|
||||
reset();
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.io.InputStream;
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
public static String loadAsText(Class cls, String name) {
|
||||
public static String loadAsText(Class<?> cls, String name) {
|
||||
byte [] buffer = new byte[1024];
|
||||
int nr;
|
||||
try (InputStream in = cls.getResourceAsStream(name); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
package com.persesgames.jogl.explosion;
|
||||
|
||||
import com.jogamp.common.nio.Buffers;
|
||||
import com.persesgames.jogl.shader.ComputeProgram;
|
||||
import com.persesgames.jogl.shader.ShaderProgram;
|
||||
import com.persesgames.jogl.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.media.opengl.GL;
|
||||
import javax.media.opengl.GL2ES2;
|
||||
import javax.media.opengl.GL4;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Random;
|
||||
|
||||
import com.jogamp.common.nio.Buffers;
|
||||
import com.persesgames.jogl.Util;
|
||||
import com.persesgames.jogl.shader.ComputeProgram;
|
||||
import com.persesgames.jogl.shader.ShaderProgram;
|
||||
|
||||
/**
|
||||
* Date: 1/15/14
|
||||
* Time: 8:23 PM
|
||||
*/
|
||||
public class ExplosionComputeHandler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(ExplosionComputeHandler.class);
|
||||
//private final static Logger logger = LoggerFactory.getLogger(ExplosionComputeHandler.class);
|
||||
|
||||
private final static int EXPLOSION_PARTICLES = 256;
|
||||
private final static int MAX_EXPLOSION_PARTICLES = 250000;
|
||||
|
||||
@@ -16,7 +16,7 @@ varying vec4 varying_Color;
|
||||
void main(void) {
|
||||
mat4 uniform_Projection = mat4(1);
|
||||
|
||||
gl_PointSize = 15f;
|
||||
gl_PointSize = 15.0f;
|
||||
gl_Position = uniform_Projection * attribute_Position; //vec4(attribute_Position.x, attribute_Position.y, 0, 1);
|
||||
varying_Color = attribute_Color;
|
||||
}
|
||||
|
||||
@@ -2,24 +2,6 @@ package com.persesgames.jogl.shader;
|
||||
|
||||
import javax.media.opengl.GL4;
|
||||
|
||||
/*-----------------------------------------------------+
|
||||
| App |
|
||||
| pPPAPPp |
|
||||
| APP PPa |
|
||||
| APA pPP PapA PapA |
|
||||
| PPA APA pP P pP P |
|
||||
| APPPPPPPA PPp Ap Ap Ap Ap |
|
||||
| apPPA aPP P P |
|
||||
| APA pPP p p |
|
||||
| pPP PPA |
|
||||
| PPp PPPp |
|
||||
| |
|
||||
| Created by: App Software |
|
||||
| Email: info@appsoftware.nl |
|
||||
| Web: http://www.appsoftware.nl/ |
|
||||
| |
|
||||
+-----------------------------------------------------*/
|
||||
|
||||
public class ComputeProgram extends Program {
|
||||
|
||||
private GL4 gl4;
|
||||
|
||||
@@ -1,30 +1,9 @@
|
||||
package com.persesgames.jogl.shader;
|
||||
|
||||
import com.persesgames.jogl.Renderer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.media.opengl.GL2ES2;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/*-----------------------------------------------------+
|
||||
| App |
|
||||
| pPPAPPp |
|
||||
| APP PPa |
|
||||
| APA pPP PapA PapA |
|
||||
| PPA APA pP P pP P |
|
||||
| APPPPPPPA PPp Ap Ap Ap Ap |
|
||||
| apPPA aPP P P |
|
||||
| APA pPP p p |
|
||||
| pPP PPA |
|
||||
| PPp PPPp |
|
||||
| |
|
||||
| Created by: App Software |
|
||||
| Email: info@appsoftware.nl |
|
||||
| Web: http://www.appsoftware.nl/ |
|
||||
| |
|
||||
+-----------------------------------------------------*/
|
||||
import javax.media.opengl.GL2ES2;
|
||||
|
||||
public abstract class Program {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user