29package com.jogamp.opengl.test.junit.jogl.acore;
32import java.util.concurrent.atomic.AtomicBoolean;
34import com.jogamp.newt.opengl.GLWindow;
36import com.jogamp.nativewindow.util.InsetsImmutable;
37import com.jogamp.opengl.GLAnimatorControl;
38import com.jogamp.opengl.GLAutoDrawable;
39import com.jogamp.opengl.GLCapabilities;
40import com.jogamp.opengl.GLContext;
41import com.jogamp.opengl.GLProfile;
43import com.jogamp.opengl.util.Animator;
44import com.jogamp.opengl.test.junit.util.NewtTestUtil;
45import com.jogamp.opengl.test.junit.util.GLTestUtil;
46import com.jogamp.opengl.test.junit.util.MiscUtils;
47import com.jogamp.opengl.test.junit.util.UITestCase;
48import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
50import org.junit.Assert;
51import org.junit.BeforeClass;
53import org.junit.FixMethodOrder;
54import org.junit.runners.MethodSorters;
66@FixMethodOrder(MethodSorters.NAME_ASCENDING)
70 static int width, height;
76 Assert.assertNotNull(glp);
78 Assert.assertNotNull(caps);
82 setTestSupported(
false);
88 Assert.assertNotNull(glWindow);
90 glWindow.
setTitle(
"Shared Gears NEWT Test: "+x+
"/"+y+
" shared true");
91 glWindow.
setSize(width, height);
98 public void test01() throws InterruptedException {
103 final GLWindow f1 = createGLWindow(0, 0, g1);
111 f2.setSharedAutoDrawable(f1);
119 f3.setSharedAutoDrawable(f2);
121 final AtomicBoolean gotAnimException =
new AtomicBoolean(
false);
122 final AtomicBoolean gotOtherException =
new AtomicBoolean(
false);
125 public void uncaughtException(final GLAnimatorControl _animator, final GLAutoDrawable _drawable, final Throwable _cause) {
126 if( _animator == animator && _drawable == f3 && _cause instanceof RuntimeException ) {
127 System.err.println(
"Caught expected exception: "+_cause.getMessage());
128 gotAnimException.set(true);
130 System.err.println(
"Caught unexpected exception: "+_cause.getMessage());
131 _cause.printStackTrace();
132 gotOtherException.set(true);
155 Assert.assertTrue(
"Gears1 not initialized", g1.waitForInit(
true));
160 Assert.assertTrue(
"Gears2 not initialized", g2.waitForInit(
true));
165 Assert.assertTrue(
"Gears3 not initialized", g3.waitForInit(
true));
167 Assert.assertFalse(
"Unexpected exception (animator) caught", gotAnimException.get());
168 Assert.assertFalse(
"Unexpected exception (other) caught", gotOtherException.get());
181 Assert.assertTrue(
"Ctx1 is not shared", ctx1.
isShared());
182 Assert.assertTrue(
"Ctx2 is not shared", ctx2.
isShared());
183 Assert.assertTrue(
"Ctx3 is not shared", ctx3.
isShared());
184 Assert.assertEquals(
"Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
185 Assert.assertEquals(
"Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
186 Assert.assertEquals(
"Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
187 Assert.assertEquals(
"Ctx1 Master Context is different", ctx1, ctx1.
getSharedMaster());
188 Assert.assertEquals(
"Ctx2 Master Context is different", ctx1, ctx2.
getSharedMaster());
189 Assert.assertEquals(
"Ctx3 Master Context is different", ctx2, ctx3.
getSharedMaster());
192 Assert.assertTrue(
"Gears1 is shared", !g1.usesSharedGears());
193 Assert.assertTrue(
"Gears2 is not shared", g2.usesSharedGears());
194 Assert.assertTrue(
"Gears3 is not shared", g3.usesSharedGears());
197 Thread.sleep(duration);
198 }
catch(
final Exception e) {
202 Assert.assertEquals(
false, animator.isAnimating());
204 System.err.println(
"XXX Destroy in clean order NOW");
209 Assert.assertTrue(NewtTestUtil.waitForVisible(f1,
false,
null));
210 Assert.assertTrue(NewtTestUtil.waitForRealized(f1,
false,
null));
211 Assert.assertTrue(NewtTestUtil.waitForVisible(f2,
false,
null));
212 Assert.assertTrue(NewtTestUtil.waitForRealized(f2,
false,
null));
213 Assert.assertTrue(NewtTestUtil.waitForVisible(f3,
false,
null));
214 Assert.assertTrue(NewtTestUtil.waitForRealized(f3,
false,
null));
217 static long duration = 1000;
219 public static void main(
final String args[]) {
220 for(
int i=0; i<args.length; i++) {
221 if(args[i].equals(
"-time")) {
224 duration = Integer.parseInt(args[i]);
225 }
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,...
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.
Expected error test sharing w/ different shared-master context, i.e.
GLWindow createGLWindow(final int x, final int y, final GearsES2 gears)
static void main(final String args[])
void setSharedGears(final GearsES2 shared)
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 void setUncaughtExceptionHandler(final UncaughtExceptionHandler handler)
Set the handler invoked when this animator abruptly stops due to an uncaught exception from one of it...
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.
Immutable insets representing rectangular window decoration insets on all four edges in window units.
A registered UncaughtExceptionHandler instance is invoked when an animator abruptly stops due to an u...
An animator control interface, which implementation may drive a com.jogamp.opengl....
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.