From 597d10f5a5f743a51cfe56f3c381fd80e941a394 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 9 Nov 2010 20:07:21 +0100 Subject: Adding simple static main test entry to provide standalone autobuild verification --- .../classes/javax/media/opengl/awt/GLCanvas.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src/jogl/classes/javax/media/opengl/awt') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index d2a20f467..22b25740c 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -45,12 +45,14 @@ import javax.media.nativewindow.*; import javax.media.nativewindow.awt.*; import com.jogamp.opengl.impl.*; +import com.jogamp.opengl.util.VersionInfo; import java.awt.Canvas; import java.awt.Color; import java.awt.Component; import java.awt.EventQueue; import java.awt.FontMetrics; +import java.awt.Frame; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; @@ -787,4 +789,57 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable { return config; } + + /** + * A most simple JOGL AWT test entry + */ + public static void main(String args[]) { + GLCapabilities caps = new GLCapabilities( GLProfile.getDefault() ); + Frame frame = new Frame("JOGL AWT Test"); + + GLCanvas glCanvas = new GLCanvas(caps); + frame.add(glCanvas); + frame.setSize(128, 128); + + glCanvas.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + String prefix = "JOGL AWT Test " + Thread.currentThread().getName(); + System.err.println(VersionInfo.getInfo(null, prefix, gl).toString()); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + + public void display(GLAutoDrawable drawable) { + } + + public void dispose(GLAutoDrawable drawable) { + } + }); + + final Frame _frame = frame; + final GLCanvas _glCanvas = glCanvas; + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + _frame.setVisible(true); + }}); + } catch (Throwable t) { + t.printStackTrace(); + } + glCanvas.display(); + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + _frame.setVisible(false); + _frame.remove(_glCanvas); + _frame.dispose(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + } + } + } -- cgit v1.2.3