29package com.jogamp.opengl.test.junit.jogl.acore;
33import com.jogamp.newt.opengl.GLWindow;
35import com.jogamp.nativewindow.util.InsetsImmutable;
36import com.jogamp.opengl.GLCapabilities;
37import com.jogamp.opengl.GLContext;
38import com.jogamp.opengl.GLProfile;
40import com.jogamp.opengl.util.Animator;
41import com.jogamp.opengl.test.junit.util.NewtTestUtil;
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(glWindow);
89 glWindow.
setTitle(
"Shared Gears NEWT Test: "+x+
"/"+y+
" shared true");
90 glWindow.
setSize(width, height);
98 syncedOneAnimator(
true);
103 syncedOneAnimator(
false);
112 final GLWindow f1 = createGLWindow(0, 0, g1);
120 f2.setSharedAutoDrawable(f1);
128 f3.setSharedAutoDrawable(f1);
149 Assert.assertTrue(
"Gears1 not initialized", g1.
waitForInit(
true));
154 Assert.assertTrue(
"Gears2 not initialized", g2.
waitForInit(
true));
159 Assert.assertTrue(
"Gears3 not initialized", g3.
waitForInit(
true));
172 Assert.assertTrue(
"Ctx1 is not shared", ctx1.
isShared());
173 Assert.assertTrue(
"Ctx2 is not shared", ctx2.
isShared());
174 Assert.assertTrue(
"Ctx3 is not shared", ctx3.
isShared());
175 Assert.assertEquals(
"Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
176 Assert.assertEquals(
"Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
177 Assert.assertEquals(
"Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
178 Assert.assertEquals(
"Ctx1 Master Context is different", ctx1, ctx1.
getSharedMaster());
179 Assert.assertEquals(
"Ctx2 Master Context is different", ctx1, ctx2.
getSharedMaster());
180 Assert.assertEquals(
"Ctx3 Master Context is different", ctx1, ctx3.
getSharedMaster());
183 Assert.assertTrue(
"Gears1 is shared", !g1.usesSharedGears());
184 Assert.assertTrue(
"Gears2 is not shared", g2.usesSharedGears());
185 Assert.assertTrue(
"Gears3 is not shared", g3.usesSharedGears());
188 Thread.sleep(duration);
189 }
catch(
final Exception e) {
193 Assert.assertEquals(
false, animator.isAnimating());
195 if( destroyCleanOrder ) {
196 System.err.println(
"XXX Destroy in clean order NOW");
201 System.err.println(
"XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs.");
216 asyncEachAnimator(
true);
221 asyncEachAnimator(
false);
228 final GLWindow f1 = createGLWindow(0, 0, g1);
239 f2.setSharedAutoDrawable(f1);
249 f3.setSharedAutoDrawable(f1);
271 Assert.assertTrue(
"Gears1 not initialized", g1.
waitForInit(
true));
276 Assert.assertTrue(
"Gears2 not initialized", g2.
waitForInit(
true));
280 Assert.assertTrue(
"Gears3 not initialized", g3.
waitForInit(
true));
293 Assert.assertTrue(
"Ctx1 is not shared", ctx1.
isShared());
294 Assert.assertTrue(
"Ctx2 is not shared", ctx2.
isShared());
295 Assert.assertTrue(
"Ctx3 is not shared", ctx3.
isShared());
296 Assert.assertEquals(
"Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
297 Assert.assertEquals(
"Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
298 Assert.assertEquals(
"Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
299 Assert.assertEquals(
"Ctx1 Master Context is different", ctx1, ctx1.
getSharedMaster());
300 Assert.assertEquals(
"Ctx2 Master Context is different", ctx1, ctx2.
getSharedMaster());
301 Assert.assertEquals(
"Ctx3 Master Context is different", ctx1, ctx3.
getSharedMaster());
304 Assert.assertTrue(
"Gears1 is shared", !g1.usesSharedGears());
305 Assert.assertTrue(
"Gears2 is not shared", g2.usesSharedGears());
306 Assert.assertTrue(
"Gears3 is not shared", g3.usesSharedGears());
309 Thread.sleep(duration);
310 }
catch(
final Exception e) {
316 Assert.assertEquals(
false, a1.isAnimating());
318 Assert.assertEquals(
false, a2.isAnimating());
320 Assert.assertEquals(
false, a3.isAnimating());
322 if( destroyCleanOrder ) {
323 System.err.println(
"XXX Destroy in clean order NOW");
328 System.err.println(
"XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs.");
341 static long duration = 1000;
342 static boolean mainRun =
false;
344 public static void main(
final String args[]) {
346 for(
int i=0; i<args.length; i++) {
347 if(args[i].equals(
"-time")) {
350 duration = Integer.parseInt(args[i]);
351 }
catch (
final Exception ex) { ex.printStackTrace(); }
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
final void setTitle(final String title)
final int getX()
Returns the current x position of this window, relative to it's parent.
final int getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final InsetsImmutable getInsets()
Returns the insets defined as the width and height of the window decoration on the left,...
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
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 GLContext getSharedMaster()
Returns the shared master GLContext of this GLContext if shared, otherwise return null.
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.
Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
void asyncEachAnimator(final boolean destroyCleanOrder)
void syncedOneAnimator(final boolean destroyCleanOrder)
void test01SyncedOneAnimatorCleanDtorOrder()
void test11AsyncEachAnimatorCleanDtorOrder()
GLWindow createGLWindow(final int x, final int y, final GearsES2 gears)
static void main(final String args[])
void test12AsyncEachAnimatorDirtyDtorOrder()
void test02SyncedOneAnimatorDirtyDtorOrder()
void setSharedGears(final GearsES2 shared)
boolean waitForInit(final boolean initialized)
void setSyncObjects(final Object sync)
static boolean waitForContextCreated(final GLAutoDrawable autoDrawable, final boolean created, final Runnable waitAction)
static void dumpSharedGLContext(final String prefix, final GLContext self)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final Window win, final boolean visible, final Runnable waitAction)
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.
Immutable insets representing rectangular window decoration insets on all four edges in window units.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GLContext getContext()
Returns the context associated with this drawable.