29package com.jogamp.opengl.test.junit.jogl.acore;
31import com.jogamp.opengl.GLCapabilities;
32import com.jogamp.opengl.GLDrawableFactory;
33import com.jogamp.opengl.GLOffscreenAutoDrawable;
34import com.jogamp.opengl.GLProfile;
35import com.jogamp.opengl.awt.GLCanvas;
37import com.jogamp.opengl.util.Animator;
39import com.jogamp.opengl.test.junit.util.UITestCase;
40import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
41import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
44import java.lang.reflect.InvocationTargetException;
46import org.junit.Assert;
47import org.junit.Assume;
48import org.junit.BeforeClass;
50import org.junit.FixMethodOrder;
51import org.junit.runners.MethodSorters;
53@FixMethodOrder(MethodSorters.NAME_ASCENDING)
57 static int width, height;
65 Assert.assertNotNull(glp);
67 Assert.assertNotNull(caps);
71 setTestSupported(
false);
75 private void initShared() {
77 Assert.assertNotNull(sharedDrawable);
78 sharedGears =
new Gears();
79 Assert.assertNotNull(sharedGears);
85 private void releaseShared() {
86 Assert.assertNotNull(sharedDrawable);
91 throws InterruptedException, InvocationTargetException {
92 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
94 f.setTitle(
"Shared Gears AWT Test: "+f.getX()+
"/"+f.getY()+
" shared "+useShared);
99 protected GLCanvas runTestGL(
final Frame frame,
final Animator animator,
final int x,
final int y,
final boolean useShared,
final boolean vsync)
100 throws InterruptedException, InvocationTargetException
103 Assert.assertNotNull(glCanvas);
106 frame.setLocation(x, y);
107 frame.setSize(width, height);
115 animator.add(glCanvas);
117 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
119 frame.setVisible(
true);
127 public void test01() throws InterruptedException, InvocationTargetException {
129 final Frame f1 =
new Frame();
130 final Frame f2 =
new Frame();
131 final Frame f3 =
new Frame();
134 final GLCanvas glc1 = runTestGL(f1, animator, 0, 0,
true,
false);
135 final int x0 = f1.getX();
136 final int y0 = f1.getY();
138 final GLCanvas glc2 = runTestGL(f2, animator,
143 final GLCanvas glc3 = runTestGL(f3, animator,
148 setFrameTitle(f1,
true);
149 setFrameTitle(f2,
true);
150 setFrameTitle(f3,
false);
160 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
169 }
catch (
final Throwable t) {
170 throw new RuntimeException(t);
173 }
catch(
final Throwable throwable ) {
174 throwable.printStackTrace();
175 Assume.assumeNoException( throwable );
181 static long duration = 500;
183 public static void main(
final String args[]) {
184 for(
int i=0; i<args.length; i++) {
185 if(args[i].equals(
"-time")) {
188 duration = Integer.parseInt(args[i]);
189 }
catch (
final Exception ex) { ex.printStackTrace(); }
Specifies a set of OpenGL capabilities.
abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, int width, int height)
Creates a realized GLOffscreenAutoDrawable incl it's offscreen NativeSurface with the given capabilit...
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
Specifies the the OpenGL profile.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
A heavyweight AWT component which provides OpenGL rendering support.
final void setSharedAutoDrawable(final GLAutoDrawable sharedAutoDrawable)
Specifies an GLAutoDrawable, which OpenGL context shall be shared by this GLAutoDrawable's GLContext.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
void setFrameTitle(final Frame f, final boolean useShared)
GLCanvas runTestGL(final Frame frame, final Animator animator, final int x, final int y, final boolean useShared, final boolean vsync)
static void main(final String args[])
Gears.java author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel)
void setSharedGears(final Gears shared)
static boolean waitForRealized(final java.awt.Component comp, final boolean realized, final Runnable waitAction)
final long getTotalFPSDuration()
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Platform-independent GLAutoDrawable specialization, exposing offscreen functionality.