summaryrefslogtreecommitdiffstats
path: root/src/demos/printext
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-05-19 22:39:11 +0000
committerKenneth Russel <[email protected]>2005-05-19 22:39:11 +0000
commit07ebb8442b61c1e016936546ce804194c5ebd943 (patch)
treeacee3f0d836637cfd46e2b050aec728985e2b4c0 /src/demos/printext
parentaf4e865d4d13687d5b31a15d0f4c5193dc62284d (diff)
Added PrintExt demo to print all GL extensions
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@77 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/printext')
-rwxr-xr-xsrc/demos/printext/PrintExt.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/demos/printext/PrintExt.java b/src/demos/printext/PrintExt.java
new file mode 100755
index 0000000..3edb3a0
--- /dev/null
+++ b/src/demos/printext/PrintExt.java
@@ -0,0 +1,69 @@
+/*
+ * Portions Copyright (C) 2003 Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+package demos.printext;
+
+import java.awt.*;
+import net.java.games.jogl.*;
+
+public class PrintExt {
+ public static void main(String[] args) {
+ Frame frame = new Frame();
+ GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
+ canvas.addGLEventListener(new Listener());
+ frame.setUndecorated(true);
+ frame.add(canvas);
+ frame.setSize(1, 1);
+ frame.setVisible(true);
+ }
+
+ static class Listener implements GLEventListener {
+ public void init(GLDrawable drawable) {
+ GL gl = drawable.getGL();
+ System.out.println("GL vendor: " + gl.glGetString(GL.GL_VENDOR));
+ System.out.println("GL version: " + gl.glGetString(GL.GL_VERSION));
+ System.out.println("GL renderer: " + gl.glGetString(GL.GL_RENDERER));
+ System.out.println("GL extensions:");
+ String[] extensions = gl.glGetString(GL.GL_EXTENSIONS).split(" ");
+ int i = 0;
+ while (i < extensions.length) {
+ System.out.print(" ");
+ String ext = extensions[i++];
+ System.out.print(ext);
+ if (i < extensions.length) {
+ for (int j = 0; j < (40 - ext.length()); j++) {
+ System.out.print(" ");
+ }
+ System.out.println(extensions[i++]);
+ } else {
+ System.out.println();
+ }
+ }
+ runExit();
+ }
+
+ public void display(GLDrawable drawable) {
+ }
+
+ public void reshape(GLDrawable drawable, int x, int y, int w, int h) {
+ }
+
+ public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+ }
+
+ private static void runExit() {
+ // Note: calling System.exit() synchronously inside the draw,
+ // reshape or init callbacks can lead to deadlocks on certain
+ // platforms (in particular, X11) because the JAWT's locking
+ // routines cause a global AWT lock to be grabbed. Run the
+ // exit routine in another thread.
+ new Thread(new Runnable() {
+ public void run() {
+ System.exit(0);
+ }
+ }).start();
+ }
+}