29package com.jogamp.opengl.test.junit.jogl.acore;
31import com.jogamp.newt.opengl.GLWindow;
33import com.jogamp.nativewindow.util.InsetsImmutable;
34import com.jogamp.opengl.GLAutoDrawable;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLContext;
37import com.jogamp.opengl.GLDrawableFactory;
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;
79@FixMethodOrder(MethodSorters.NAME_ASCENDING)
83 static int width, height;
91 Assert.assertNotNull(glp);
93 Assert.assertNotNull(caps);
97 setTestSupported(
false);
101 private void initShared(
final boolean onscreen)
throws InterruptedException {
104 Assert.assertNotNull(glWindow);
105 glWindow.
setSize(width, height);
107 sharedDrawable = glWindow;
111 Assert.assertNotNull(sharedDrawable);
113 Assert.assertTrue(GLTestUtil.waitForRealized(obj,
true,
null));
115 sharedGears =
new GearsES2();
116 Assert.assertNotNull(sharedGears);
121 Assert.assertTrue(
"Master ctx not created", GLTestUtil.waitForContextCreated(sharedDrawable,
true,
null));
122 Assert.assertTrue(
"Master Ctx is shared before shared creation", !ctxM.
isShared());
123 Assert.assertTrue(
"Master Gears not initialized", sharedGears.
waitForInit(
true));
124 System.err.println(
"Master Gears Init done: "+sharedGears);
125 Assert.assertTrue(
"Master Gears is shared", !sharedGears.usesSharedGears());
128 private void releaseShared() {
129 Assert.assertNotNull(sharedDrawable);
131 sharedDrawable =
null;
134 protected GLWindow runTestGL(
final Animator animator,
final int x,
final int y,
final boolean useShared,
final boolean vsync)
throws InterruptedException {
136 Assert.assertNotNull(glWindow);
138 glWindow.
setTitle(
"Shared Gears NEWT Test: "+x+
"/"+y+
" shared "+useShared);
140 glWindow.setSharedAutoDrawable(sharedDrawable);
143 glWindow.
setSize(width, height);
151 animator.add(glWindow);
162 Assert.assertEquals(
"Master Context not shared as expected",
true, sharedMasterContext.
isShared());
167 Assert.assertEquals(
"New Context not shared as expected", useShared, glWindow.
getContext().
isShared());
169 Assert.assertTrue(
"Gears not initialized", gears.
waitForInit(
true));
170 System.err.println(
"Slave Gears Init done: "+gears);
171 Assert.assertEquals(
"Gears is not shared as expected", useShared, gears.usesSharedGears());
180 final GLWindow f1 = runTestGL(animator, 0, 0,
true,
false);
183 f1.
getY()+0,
true,
false);
187 Thread.sleep(duration);
188 }
catch(
final Exception e) {
215 final GLWindow f1 = runTestGL(animator1, 0, 0,
true,
false);
218 f1.
getY()+0,
true,
false);
223 Thread.sleep(duration);
224 }
catch(
final Exception e) {
251 final GLWindow f1 = runTestGL(animator, 0, 0,
true,
false);
254 f1.
getY()+0,
true,
false);
258 Thread.sleep(duration);
259 }
catch(
final Exception e) {
286 final GLWindow f1 = runTestGL(animator1, 0, 0,
true,
false);
289 f1.
getY()+0,
true,
false);
294 Thread.sleep(duration);
295 }
catch(
final Exception e) {
318 static long duration = 1000;
320 public static void main(
final String args[]) {
321 for(
int i=0; i<args.length; i++) {
322 if(args[i].equals(
"-time")) {
325 duration = Integer.parseInt(args[i]);
326 }
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.
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
abstract GLAutoDrawable createDummyAutoDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser)
Creates a realized dummy GLAutoDrawable incl it's dummy, invisible NativeSurface as created with crea...
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.
static void main(final String args[])
void test01CommonAnimatorSharedOnscreen()
GLWindow runTestGL(final Animator animator, final int x, final int y, final boolean useShared, final boolean vsync)
void test11CommonAnimatorSharedOffscreen()
void test12EachWithAnimatorSharedOffscreen()
void test02EachWithAnimatorSharedOnscreen()
void setSharedGears(final GearsES2 shared)
boolean waitForInit(final boolean initialized)
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 boolean stop()
Stops this animator.
Immutable insets representing rectangular window decoration insets on all four edges in window units.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
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.
GLContext getContext()
Returns the context associated with this drawable.