29package com.jogamp.opengl.test.junit.jogl.acore.ect;
31import com.jogamp.newt.NewtFactory;
32import com.jogamp.newt.Window;
33import com.jogamp.opengl.test.junit.util.GLTestUtil;
34import com.jogamp.opengl.test.junit.util.UITestCase;
36import com.jogamp.opengl.util.AnimatorBase;
38import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
39import com.jogamp.common.os.Platform;
40import com.jogamp.nativewindow.Capabilities;
41import com.jogamp.nativewindow.util.InsetsImmutable;
43import com.jogamp.opengl.GLAutoDrawable;
44import com.jogamp.opengl.GLCapabilities;
45import com.jogamp.opengl.GLCapabilitiesImmutable;
46import com.jogamp.opengl.GLProfile;
48import org.junit.Assert;
49import org.junit.BeforeClass;
50import org.junit.AfterClass;
51import org.junit.FixMethodOrder;
53import org.junit.runners.MethodSorters;
58@FixMethodOrder(MethodSorters.NAME_ASCENDING)
60 static boolean testExclusiveWithAWT =
false;
61 static long duration = 1400;
63 static boolean showFPS =
false;
64 static int showFPSRate = 60;
66 static final int demoWinSize = 128;
69 static int num_x, num_y;
71 static int swapInterval = 0;
76 dummyWindow.
setSize(demoWinSize, demoWinSize);
78 Assert.assertEquals(
true, dummyWindow.
isVisible());
83 final int[] demoScreenSize = dummyWindow.
convertToPixelUnits(
new int[] { demoWinSize, demoWinSize });
85 num_x = scrnWidth / ( demoScreenSize[0] + insetsScreenSize[0] ) - 2;
86 num_y = scrnHeight / ( demoScreenSize[1] + insetsScreenSize[1] ) - 2;
105 runTestGL(caps, drawableCount, exclusive,
false);
109 final boolean useAWTRenderThread = isAWTTestCase();
110 if( useAWTRenderThread && exclusive ) {
111 if( testExclusiveWithAWT ) {
112 System.err.println(
"Warning: Testing AWT + Exclusive -> Not advised!");
114 System.err.println(
"Info: Skip test: AWT + Exclusive!");
118 if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) {
119 System.err.println(
"Skip test: AWT + Exclusive -> Not advised!");
122 final Thread awtRenderThread = getAWTRenderThread();
125 for(
int i=0; i<drawableCount; i++) {
126 animators[i] = createAnimator();
127 if( !useAWTRenderThread ) {
133 drawables[i] = createGLAutoDrawable(
"Win #"+i, x, y, demoWinSize, demoWinSize, caps);
134 Assert.assertNotNull(drawables[i]);
141 setGLAutoDrawableVisible(drawables);
144 for(
int i=0; i<drawableCount; i++) {
145 Assert.assertEquals(
true, drawables[i].isRealized());
150 for(
int i=0; i<drawableCount; i++) {
151 animators[i].
add(drawables[i]);
154 if( useAWTRenderThread ) {
155 Assert.assertEquals(
null, animators[i].setExclusiveContext(awtRenderThread));
157 Assert.assertEquals(
false, animators[i].setExclusiveContext(
true));
160 Assert.assertFalse(animators[i].isAnimating());
161 Assert.assertFalse(animators[i].isStarted());
165 for(
int i=0; i<drawableCount; i++) {
166 Assert.assertTrue(animators[i].start());
168 Assert.assertTrue(animators[i].isStarted());
169 Assert.assertTrue(animators[i].isAnimating());
170 Assert.assertEquals(exclusive, animators[i].isExclusiveContextEnabled());
174 for(
int i=0; i<drawableCount; i++) {
177 if( useAWTRenderThread ) {
178 Assert.assertEquals(awtRenderThread, ect);
180 Assert.assertEquals(animators[i].getThread(), ect);
183 Assert.assertEquals(
null, ect);
185 Assert.assertEquals(ect, drawables[i].getExclusiveContextThread());
189 setGLAutoDrawableVisible(drawables);
192 for(
int i=0; i<drawableCount; i++) {
193 Assert.assertEquals(
true, drawables[i].isRealized());
199 Thread.sleep(duration);
202 for(
int i=0; i<drawableCount; i++) {
203 Assert.assertTrue(animators[i].stop());
204 Assert.assertFalse(animators[i].isAnimating());
205 Assert.assertFalse(animators[i].isStarted());
206 Assert.assertFalse(animators[i].isPaused());
207 Assert.assertEquals(exclusive, animators[i].isExclusiveContextEnabled());
208 Assert.assertEquals(
null, animators[i].getExclusiveContextThread());
212 for(
int i=0; i<drawableCount; i++) {
213 destroyGLAutoDrawableVisible(drawables[i]);
222 runTestGL(caps, 1 ,
false ,
false );
229 runTestGL(caps, 1 ,
true ,
false );
236 runTestGL(caps, 4 ,
false ,
false );
241 if( Platform.OSType.MACOS == Platform.getOSType() ) {
243 System.err.println(
"Disabled, see Bug 1415");
248 runTestGL(caps, 4 ,
true ,
false );
255 runTestGL(caps, 1 ,
false ,
true );
262 runTestGL(caps, 1 ,
true ,
true );
269 runTestGL(caps, 4 ,
false ,
true );
276 runTestGL(caps, 4 ,
true ,
true );
Specifies a set of capabilities that a window's rendering context must support, such as color depth p...
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
ExclusiveContextThread base implementation to test performance impact of the ExclusiveContext feature...
abstract boolean isAWTTestCase()
void test11Normal_1WinPreVis()
void test03Excl_1WinPostVis()
abstract AnimatorBase createAnimator()
static void releaseClass00()
abstract GLAutoDrawable createGLAutoDrawable(String title, int x, int y, int width, int height, GLCapabilitiesImmutable caps)
void test13Excl_1WinPreVis()
void test07Excl_4WinPostVis()
abstract void destroyGLAutoDrawableVisible(GLAutoDrawable glad)
abstract Thread getAWTRenderThread()
void runTestGL(final GLCapabilitiesImmutable caps, final int drawableCount, final boolean exclusive)
static void initClass00()
abstract void setGLAutoDrawableVisible(GLAutoDrawable[] glads)
void test01Normal_1WinPostVis()
void test17Excl_4WinPreVis()
void test05Normal_4WinPostVis()
void runTestGL(final GLCapabilitiesImmutable caps, final int drawableCount, final boolean exclusive, final boolean preVisible)
void test15Normal_4WinPreVis()
GearsES2 setVerbose(final boolean v)
static boolean waitForRealized(final GLAutoDrawable glad, final boolean realized, final Runnable waitAction)
Base implementation of GLAnimatorControl
static final int MODE_EXPECT_AWT_RENDERING_THREAD
If present in modeBits field and AWT is available, implementation is aware of the AWT EDT,...
final synchronized void setModeBits(final boolean enable, final int bitValues)
Enables or disables the given bitValues in this Animators modeBits.
final synchronized Thread getExclusiveContextThread()
Returns the exclusive context thread if isExclusiveContextEnabled() and isStarted(),...
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
int[] convertToPixelUnits(final int[] windowUnitsAndResult)
Converts the given window units into pixel units in place.
InsetsImmutable getInsets()
Returns the insets defined as the width and height of the window decoration on the left,...
Immutable insets representing rectangular window decoration insets on all four edges in window units.
Specifying NEWT's Window functionality:
void setSize(int width, int height)
Sets the size of the window's client area in window units, excluding decorations.
void setVisible(boolean visible)
Calls setVisible(true, visible), i.e.
void destroy()
Destroys this window incl.releasing all related resources.
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.
Specifies an immutable set of OpenGL capabilities.