aboutsummaryrefslogtreecommitdiffstats
path: root/src/demos/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-02 21:27:14 +0200
committerSven Gothel <[email protected]>2023-09-02 21:27:14 +0200
commitef63d2e288fe47762d9cf743d11cd01f8d255349 (patch)
treead3c6a9b93b3c46fe190b12f87f78ef053977f7d /src/demos/com/jogamp/opengl
parentd891e70a99dfcebc205f97ed42b91111710c5176 (diff)
GraphUI Demos: Proper use of CommandlineOptions
Diffstat (limited to 'src/demos/com/jogamp/opengl')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java7
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java7
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java7
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java31
4 files changed, 18 insertions, 34 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
index 51326d663..e0ffb9663 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo00.java
@@ -62,12 +62,7 @@ public class UISceneDemo00 {
static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.VBAA_RENDERING_BIT);
public static void main(final String[] args) throws IOException {
- if( 0 != args.length ) {
- final int[] idx = { 0 };
- for(idx[0]=0; idx[0]<args.length; ++idx[0]) {
- options.parse(args, idx);
- }
- }
+ options.parse(args);
System.err.println(options);
final GLProfile reqGLP = GLProfile.get(options.glProfileName);
System.err.println("GLProfile: "+reqGLP);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
index dbdc66b3b..8bdb3eb47 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01.java
@@ -68,12 +68,7 @@ public class UISceneDemo01 {
static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.VBAA_RENDERING_BIT);
public static void main(final String[] args) throws IOException {
- if( 0 != args.length ) {
- final int[] idx = { 0 };
- for(idx[0]=0; idx[0]<args.length; ++idx[0]) {
- options.parse(args, idx);
- }
- }
+ options.parse(args);
System.err.println(options);
final GLProfile reqGLP = GLProfile.get(options.glProfileName);
System.err.println("GLProfile: "+reqGLP);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
index f8b2f5757..4a564ef42 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo01b.java
@@ -69,12 +69,7 @@ public class UISceneDemo01b {
static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.VBAA_RENDERING_BIT);
public static void main(final String[] args) throws IOException {
- if( 0 != args.length ) {
- final int[] idx = { 0 };
- for(idx[0]=0; idx[0]<args.length; ++idx[0]) {
- options.parse(args, idx);
- }
- }
+ options.parse(args);
System.err.println(options);
final GLProfile reqGLP = GLProfile.get(options.glProfileName);
System.err.println("GLProfile: "+reqGLP);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java
index 51d8f38a1..449d6bd96 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo02.java
@@ -44,6 +44,7 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.graph.FontSetDemos;
+import com.jogamp.opengl.demos.util.CommandlineOptions;
import com.jogamp.opengl.demos.util.MiscUtils;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.Animator;
@@ -60,32 +61,30 @@ import com.jogamp.opengl.util.PMVMatrix;
* </p>
*/
public class UISceneDemo02 {
+ static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.VBAA_RENDERING_BIT);
static float req_total_dur_s = 6f; // [s]
public static void main(final String[] args) throws IOException {
- final int surface_width = 1280, surface_height = 720;
- final int renderModes = Region.VBAA_RENDERING_BIT;
- final GLProfile reqGLP = GLProfile.getGL2ES2();
boolean wait_to_start = false;
int autoSpeed = 0;
boolean keepRunning = false;
if( 0 != args.length ) {
- for(int i=0; i<args.length; i++) {
- if(args[i].equals("-keep")) {
- keepRunning = true;
- } else if(args[i].equals("-dur")) {
- ++i;
- req_total_dur_s = MiscUtils.atoi(args[i], (int)req_total_dur_s*1000) / 1000f;
- } else if(args[i].equals("-aspeed")) {
+ final int[] idx = { 0 };
+ for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
+ if( options.parse(args, idx) ) {
+ continue;
+ } else if(args[idx[0]].equals("-aspeed")) {
autoSpeed = 1;
req_total_dur_s = 1f;
keepRunning = true;
- } else if(args[i].equals("-wait")) {
+ } else if(args[idx[0]].equals("-wait")) {
wait_to_start = true;
}
}
}
+ System.err.println(options);
+ final GLProfile reqGLP = GLProfile.get(options.glProfileName);
//
// Resolution independent, no screen size
@@ -95,9 +94,9 @@ public class UISceneDemo02 {
System.err.println("Font: "+font.getFullFamilyName());
final Font fontStatus = FontFactory.get(IOUtil.getResource("fonts/freefont/FreeMono.ttf", FontSetDemos.class.getClassLoader(), FontSetDemos.class).getInputStream(), true);
- final Label destText = new Label(renderModes, font, "");
+ final Label destText = new Label(options.renderModes, font, "");
destText.setColor(0.1f, 0.1f, 0.1f, 1);
- final Label movingGlyph = new Label(renderModes, font, "");
+ final Label movingGlyph = new Label(options.renderModes, font, "");
movingGlyph.setColor(0.1f, 0.1f, 0.1f, 1);
final Scene scene = new Scene();
@@ -113,7 +112,7 @@ public class UISceneDemo02 {
System.out.println("Requested: " + caps);
final GLWindow window = GLWindow.create(caps);
- window.setSize(surface_width, surface_height);
+ window.setSize(options.surface_width, options.surface_height);
window.setTitle(UISceneDemo02.class.getSimpleName()+": "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight());
window.setVisible(true);
window.addGLEventListener(scene);
@@ -154,7 +153,7 @@ public class UISceneDemo02 {
final float statusLabelScale = sceneBox.getWidth() / fbox.getWidth();
System.err.println("StatusLabel Scale: " + statusLabelScale + " = " + sceneBox.getWidth() + " / " + fbox.getWidth() + ", " + fbox);
- statusLabel = new Label(renderModes, fontStatus, "Nothing there yet");
+ statusLabel = new Label(options.renderModes, fontStatus, "Nothing there yet");
statusLabel.setScale(statusLabelScale, statusLabelScale, 1f);
statusLabel.setColor(0.1f, 0.1f, 0.1f, 1.0f);
statusLabel.moveTo(sceneBox.getMinX(), sceneBox.getMinY() + statusLabelScale * (fontStatus.getMetrics().getLineGap() - fontStatus.getMetrics().getDescent()), 0f);
@@ -258,7 +257,7 @@ public class UISceneDemo02 {
final float dx = -1f * velocity_obj * dt_s; // [shapeUnit]
movingGlyph.move(dx, 0f, 0f);
final String text = String.format("%s, anim-duration %.1f s",
- scene.getStatusText(drawable, renderModes, 0, dpiV), req_total_dur_s);
+ scene.getStatusText(drawable, options.renderModes, 0, dpiV), req_total_dur_s);
statusLabel.setText(text);
return true;
});