29package com.jogamp.opengl.test.junit.jogl.acore;
32import java.lang.reflect.InvocationTargetException;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLContext;
37import com.jogamp.opengl.GLProfile;
38import com.jogamp.opengl.awt.GLJPanel;
40import com.jogamp.opengl.util.Animator;
41import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
42import com.jogamp.opengl.test.junit.util.GLTestUtil;
43import com.jogamp.opengl.test.junit.util.MiscUtils;
44import com.jogamp.opengl.test.junit.util.UITestCase;
45import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
47import org.junit.Assert;
48import org.junit.BeforeClass;
50import org.junit.FixMethodOrder;
51import org.junit.runners.MethodSorters;
65@FixMethodOrder(MethodSorters.NAME_ASCENDING)
69 static int width, height;
75 Assert.assertNotNull(glp);
77 Assert.assertNotNull(caps);
81 setTestSupported(
false);
87 Assert.assertNotNull(glCanvas);
90 frame.setLocation(x, y);
91 frame.setSize(width, height);
92 frame.setTitle(
"AWT GLJPanel Shared Gears Test: "+x+
"/"+y+
" shared true");
98 final Frame f1 =
new Frame();
103 final GLJPanel c1 = createGLJPanel(f1, 0, 0, g1);
106 final Frame f2 =
new Frame();
109 final GLJPanel c2 = createGLJPanel(f2, f1.getX()+width,
114 final Frame f3 =
new Frame();
117 final GLJPanel c3 = createGLJPanel(f3, f1.getX()+0,
118 f1.getY()+height, g3);
122 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
130 Thread.sleep(1000/60*10);
135 Assert.assertTrue(
"Gears1 not initialized", g1.
waitForInit(
true));
140 Assert.assertTrue(
"Gears2 not initialized", g2.
waitForInit(
true));
145 Assert.assertTrue(
"Gears3 not initialized", g3.
waitForInit(
true));
158 Assert.assertTrue(
"Ctx1 is not shared", ctx1.
isShared());
159 Assert.assertTrue(
"Ctx2 is not shared", ctx2.
isShared());
160 Assert.assertTrue(
"Ctx3 is not shared", ctx3.
isShared());
161 Assert.assertEquals(
"Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
162 Assert.assertEquals(
"Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
163 Assert.assertEquals(
"Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
166 Assert.assertTrue(
"Gears1 is shared", !g1.usesSharedGears());
167 Assert.assertTrue(
"Gears2 is not shared", g2.usesSharedGears());
168 Assert.assertTrue(
"Gears3 is not shared", g3.usesSharedGears());
171 Thread.sleep(duration);
172 }
catch(
final Exception e) {
178 Assert.assertEquals(
false, animator.isAnimating());
180 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
186 }
catch (
final Throwable t) {
187 throw new RuntimeException(t);
198 final Frame f1 =
new Frame();
204 final GLJPanel c1 = createGLJPanel(f1, 0, 0, g1);
209 final Frame f2 =
new Frame();
213 final GLJPanel c2 = createGLJPanel(f2, f1.getX()+width, f1.getY()+0, g2);
217 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
224 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
229 final Frame f3 =
new Frame();
233 final GLJPanel c3 = createGLJPanel(f3, f1.getX()+0, f1.getY()+height, g3);
237 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
242 Thread.sleep(1000/60*10);
247 Assert.assertTrue(
"Gears1 not initialized", g1.
waitForInit(
true));
252 Assert.assertTrue(
"Gears2 not initialized", g2.
waitForInit(
true));
257 Assert.assertTrue(
"Gears3 not initialized", g3.
waitForInit(
true));
270 Assert.assertTrue(
"Ctx1 is not shared", ctx1.
isShared());
271 Assert.assertTrue(
"Ctx2 is not shared", ctx2.
isShared());
272 Assert.assertTrue(
"Ctx3 is not shared", ctx3.
isShared());
273 Assert.assertEquals(
"Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
274 Assert.assertEquals(
"Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
275 Assert.assertEquals(
"Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
278 Assert.assertTrue(
"Gears1 is shared", !g1.usesSharedGears());
279 Assert.assertTrue(
"Gears2 is not shared", g2.usesSharedGears());
280 Assert.assertTrue(
"Gears3 is not shared", g3.usesSharedGears());
283 Thread.sleep(duration);
284 }
catch(
final Exception e) {
290 Assert.assertEquals(
false, a1.isAnimating());
292 Assert.assertEquals(
false, a2.isAnimating());
294 Assert.assertEquals(
false, a3.isAnimating());
296 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
302 }
catch (
final Throwable t) {
303 throw new RuntimeException(t);
312 static long duration = 1000;
314 public static void main(
final String args[]) {
315 for(
int i=0; i<args.length; i++) {
316 if(args[i].equals(
"-time")) {
319 duration = Integer.parseInt(args[i]);
320 }
catch (
final Exception ex) { ex.printStackTrace(); }
Specifies a set of OpenGL capabilities.
Abstraction for an OpenGL rendering context.
final boolean isShared()
Returns true if this GLContext is shared, otherwise false.
final List< GLContext > getCreatedShares()
Returns a new list of created GLContext shared with this GLContext.
Specifies the the OpenGL profile.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
static final String GL2ES2
The intersection of the desktop GL3, GL2 and embedded ES2 profile.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
A lightweight Swing 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.
GLContext getContext()
Returns the context associated with this drawable.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Sharing the VBO of 3 GearsES2 instances, each in their own AWT GLJPanel.
GLJPanel createGLJPanel(final Frame frame, final int x, final int y, final GearsES2 gears)
void test02AsyncEachAnimator()
void test01SyncedOneAnimator()
static void main(final String args[])
void setValidateBuffers(final boolean v)
void setSharedGears(final GearsES2 shared)
boolean waitForInit(final boolean initialized)
void setSyncObjects(final Object sync)
static boolean waitForRealized(final java.awt.Component comp, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final java.awt.Component comp, final boolean visible, final Runnable waitAction)
static boolean waitForContextCreated(final GLAutoDrawable autoDrawable, final boolean created, final Runnable waitAction)
static void dumpSharedGLContext(final String prefix, final GLContext self)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.