diff options
author | Sven Gothel <[email protected]> | 2023-08-13 02:39:59 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-08-13 02:39:59 +0200 |
commit | 059a7b860ec703ac4c416241f6edc165ad313dcc (patch) | |
tree | 90310234cbe3ed56c81072c341e308a290856c64 /src/demos | |
parent | 52b745ed2196d3e00102e8fccace25f41386a016 (diff) |
Demos: Add main() to GearsES2, .. allowing to be used for simple bringup tests
Diffstat (limited to 'src/demos')
3 files changed, 166 insertions, 12 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java index 194397a37..1f0bdacdd 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/GearsES2.java @@ -20,41 +20,49 @@ */ package com.jogamp.opengl.demos.es2; +import java.nio.FloatBuffer; + import com.jogamp.common.nio.Buffers; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.nativewindow.NativeWindow; import com.jogamp.newt.Window; import com.jogamp.newt.event.GestureHandler; +import com.jogamp.newt.event.GestureHandler.GestureEvent; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.PinchToZoomGesture; -import com.jogamp.newt.event.GestureHandler.GestureEvent; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.GL; +import com.jogamp.opengl.GL2ES2; +import com.jogamp.opengl.GLAnimatorControl; +import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLRendererQuirks; +import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.demos.GearsObject; +import com.jogamp.opengl.demos.graph.ui.util.GraphUIDemoArgs; +import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.opengl.math.Matrix4f; import com.jogamp.opengl.math.Quaternion; import com.jogamp.opengl.math.Vec3f; +import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.CustomGLEventListener; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.TileRendererBase; +import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; import com.jogamp.opengl.util.stereo.EyeParameter; -import com.jogamp.opengl.util.stereo.ViewerPose; import com.jogamp.opengl.util.stereo.StereoGLEventListener; - -import java.nio.FloatBuffer; - -import com.jogamp.nativewindow.NativeWindow; -import com.jogamp.opengl.GL; -import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GLAnimatorControl; -import com.jogamp.opengl.GLAutoDrawable; -import com.jogamp.opengl.GLUniformData; -import com.jogamp.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.opengl.util.stereo.ViewerPose; /** * GearsES2.java <BR> @@ -688,4 +696,46 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen // System.err.println("rotXY.1: "+view_rotx+"/"+view_roty+", source "+e); } } + + public static void main(final String[] args) { + final GraphUIDemoArgs options = new GraphUIDemoArgs(1280, 720, 0); + + System.err.println(options); + System.err.println(VersionUtil.getPlatformInfo()); + // System.err.println(JoglVersion.getAllAvailableCapabilitiesInfo(dpy.getGraphicsDevice(), null).toString()); + + final GLProfile glp = GLProfile.get(options.glProfileName); + System.err.println("GLProfile: "+glp); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(4); + if( options.sceneMSAASamples > 0 ) { + caps.setSampleBuffers(true); + caps.setNumSamples(options.sceneMSAASamples); + } + System.out.println("Requested: " + caps); + + final GLWindow window = GLWindow.create(caps); + if( 0 == options.sceneMSAASamples ) { + window.setCapabilitiesChooser(new NonFSAAGLCapsChooser(false)); + } + window.setSize(options.surface_width, options.surface_height); + window.setTitle(GearsES2.class.getSimpleName()); + + window.addGLEventListener(new GearsES2(1)); + + final Animator animator = new Animator(0 /* w/o AWT */); + animator.setUpdateFPSFrames(5*60, null); + animator.add(window); + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowDestroyed(final WindowEvent e) { + animator.stop(); + } + }); + + window.setVisible(true); + animator.start(); + } + } diff --git a/src/demos/com/jogamp/opengl/demos/es2/LandscapeES2.java b/src/demos/com/jogamp/opengl/demos/es2/LandscapeES2.java index 0a42ae302..c975b79b8 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/LandscapeES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/LandscapeES2.java @@ -27,17 +27,26 @@ */ package com.jogamp.opengl.demos.es2; +import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; import java.nio.FloatBuffer; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; +import com.jogamp.opengl.demos.graph.ui.util.GraphUIDemoArgs; /** * LandscapeES2 @@ -72,6 +81,7 @@ public class LandscapeES2 implements GLEventListener { public void setVerbose(final boolean v) { verbose = v; } + @Override public void init(final GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" LandscapeES2.init ..."); final GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -123,6 +133,7 @@ public class LandscapeES2 implements GLEventListener { System.err.println(Thread.currentThread()+" LandscapeES2.init FIN"); } + @Override public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { System.err.println(Thread.currentThread()+" LandscapeES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); @@ -139,6 +150,7 @@ public class LandscapeES2 implements GLEventListener { shaderState.useProgram(gl, false); } + @Override public void dispose(final GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" LandscapeES2.dispose ... "); final GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -149,6 +161,7 @@ public class LandscapeES2 implements GLEventListener { System.err.println(Thread.currentThread()+" LandscapeES2.dispose FIN"); } + @Override public void display(final GLAutoDrawable drawable) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); // Shader fills complete framebuffer regardless of DEPTH, no Clear required. @@ -184,4 +197,45 @@ public class LandscapeES2 implements GLEventListener { public void setConfinedFixedCenter(final boolean v) { confinedFixedCenter = v; } + + public static void main(final String[] args) { + final GraphUIDemoArgs options = new GraphUIDemoArgs(1280, 720, 0); + + System.err.println(options); + System.err.println(VersionUtil.getPlatformInfo()); + // System.err.println(JoglVersion.getAllAvailableCapabilitiesInfo(dpy.getGraphicsDevice(), null).toString()); + + final GLProfile glp = GLProfile.get(options.glProfileName); + System.err.println("GLProfile: "+glp); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(4); + if( options.sceneMSAASamples > 0 ) { + caps.setSampleBuffers(true); + caps.setNumSamples(options.sceneMSAASamples); + } + System.out.println("Requested: " + caps); + + final GLWindow window = GLWindow.create(caps); + if( 0 == options.sceneMSAASamples ) { + window.setCapabilitiesChooser(new NonFSAAGLCapsChooser(false)); + } + window.setSize(options.surface_width, options.surface_height); + window.setTitle(LandscapeES2.class.getSimpleName()); + + window.addGLEventListener(new LandscapeES2(1)); + + final Animator animator = new Animator(0 /* w/o AWT */); + animator.setUpdateFPSFrames(5*60, null); + animator.add(window); + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowDestroyed(final WindowEvent e) { + animator.stop(); + } + }); + + window.setVisible(true); + animator.start(); + } } diff --git a/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java index 68152ad58..2dcebf91d 100644 --- a/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java +++ b/src/demos/com/jogamp/opengl/demos/es2/PointsDemoES2.java @@ -30,8 +30,14 @@ package com.jogamp.opengl.demos.es2; import java.nio.FloatBuffer; import com.jogamp.common.nio.Buffers; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; @@ -41,10 +47,13 @@ import com.jogamp.opengl.GL2ES1; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GL2GL3; import com.jogamp.opengl.GLAutoDrawable; +import com.jogamp.opengl.GLCapabilities; +import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.opengl.demos.PointsDemo; +import com.jogamp.opengl.demos.graph.ui.util.GraphUIDemoArgs; public class PointsDemoES2 extends PointsDemo { ShaderState st; @@ -211,4 +220,45 @@ public class PointsDemoES2 extends PointsDemo { st = null; pmvMatrix = null; } + + public static void main(final String[] args) { + final GraphUIDemoArgs options = new GraphUIDemoArgs(1280, 720, 0); + + System.err.println(options); + System.err.println(VersionUtil.getPlatformInfo()); + // System.err.println(JoglVersion.getAllAvailableCapabilitiesInfo(dpy.getGraphicsDevice(), null).toString()); + + final GLProfile glp = GLProfile.get(options.glProfileName); + System.err.println("GLProfile: "+glp); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(4); + if( options.sceneMSAASamples > 0 ) { + caps.setSampleBuffers(true); + caps.setNumSamples(options.sceneMSAASamples); + } + System.out.println("Requested: " + caps); + + final GLWindow window = GLWindow.create(caps); + if( 0 == options.sceneMSAASamples ) { + window.setCapabilitiesChooser(new NonFSAAGLCapsChooser(false)); + } + window.setSize(options.surface_width, options.surface_height); + window.setTitle(PointsDemoES2.class.getSimpleName()); + + window.addGLEventListener(new PointsDemoES2(1)); + + final Animator animator = new Animator(0 /* w/o AWT */); + animator.setUpdateFPSFrames(5*60, null); + animator.add(window); + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowDestroyed(final WindowEvent e) { + animator.stop(); + } + }); + + window.setVisible(true); + animator.start(); + } } |