30package com.jogamp.opengl.test.junit.newt.parenting;
32import org.junit.Assert;
33import org.junit.BeforeClass;
35import org.junit.FixMethodOrder;
36import org.junit.runners.MethodSorters;
38import com.jogamp.opengl.*;
39import com.jogamp.nativewindow.*;
40import com.jogamp.nativewindow.util.Point;
41import com.jogamp.nativewindow.util.PointImmutable;
42import com.jogamp.newt.*;
43import com.jogamp.newt.event.*;
44import com.jogamp.newt.opengl.*;
46import java.io.IOException;
48import com.jogamp.opengl.test.junit.util.*;
49import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
50import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
54@FixMethodOrder(MethodSorters.NAME_ASCENDING)
56 static int width, height;
57 static long durationPerTest = 500;
66 Assert.assertNotNull(caps);
68 Assert.assertNotNull(window);
73 Assert.assertNotNull(caps);
76 Assert.assertNotNull(window);
98 Assert.assertNotNull(caps);
100 Assert.assertNotNull(display);
102 Assert.assertNotNull(screen);
109 final Window window1 = createWindow(screen, caps);
110 Assert.assertNotNull(window1);
112 Assert.assertNotNull(glWindow1);
113 glWindow1.
setSize(width, height);
114 Assert.assertEquals(width,glWindow1.
getWidth());
115 Assert.assertEquals(height,glWindow1.
getHeight());
116 glWindow1.
setTitle(
"test01NewtOnNewtParentChildDraw - PARENT");
122 setDemoFields(demo1, window1, glWindow1,
false);
127 Assert.assertNotNull(capsChosen);
128 Assert.assertTrue(capsChosen.
isOnscreen()==
true);
130 final Window window2 = createWindow(window1, caps);
131 Assert.assertNotNull(window2);
133 Assert.assertNotNull(glWindow2);
134 glWindow2.
setSize(width/2, height/2);
137 glWindow2.
setTitle(
"test01NewtOnNewtParentChildDraw - CHILD");
144 setDemoFields(demo2, window2, glWindow2,
false);
149 Assert.assertNotNull(capsChosen);
150 Assert.assertTrue(capsChosen.
isOnscreen()==
true);
156 boolean shouldQuit =
false;
157 long duration = durationPerTest;
158 final long step = 20;
161 while (duration>0 && !shouldQuit) {
175 }
while( !windowMoved && waitCount < 10);
176 final boolean didWindowMove = windowMoved;
179 System.err.println(
"Moved: exp "+expPos+
", has "+hasPos+
", equals "+expPos.
equals(hasPos)+
", didWindowMove "+didWindowMove+
", waitCount "+waitCount);
182 while(
null != ( event = eventFifo.
get() ) ) {
186 }
else if(event instanceof
KeyEvent) {
199 destroyWindow(
null,
null, window2, glWindow2);
200 destroyWindow(display, screen, window1, glWindow1);
202 volatile boolean windowMoved =
false;
211 Assert.assertNotNull(demo);
212 Assert.assertNotNull(window);
222 static int atoi(
final String a) {
225 i = Integer.parseInt(a);
226 }
catch (
final Exception ex) { ex.printStackTrace(); }
230 public static void main(
final String args[])
throws IOException {
231 for(
int i=0; i<args.length; i++) {
232 if(args[i].equals(
"-time")) {
233 durationPerTest = atoi(args[++i]);
237 org.junit.runner.JUnitCore.
main(tstname);
Specifies a set of capabilities that a window's rendering context must support, such as color depth p...
abstract void destroy()
Manually trigger the destruction, incl.
static Display createDisplay(final String name)
Create a Display entity.
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract void destroy()
Manually trigger the destruction, incl.
final char getKeyChar()
Returns the UTF-16 character reflecting the key symbol incl.
synchronized NEWTEvent get()
Remove NEWTEvent from head.
NEWT events are provided for notification purposes ONLY; The NEWT will automatically handle the even...
final short getEventType()
Returns the event type of this event.
NEWT Window events are provided for notification purposes ONLY.
static final short EVENT_WINDOW_DESTROY_NOTIFY
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 AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
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 void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
final int getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
final int getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
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.
void test01NewtOnNewtParentChildDraw()
static void main(final String args[])
static void setDemoFields(final GLEventListener demo, final Window window, final GLWindow glWindow, final boolean debug)
static boolean setFieldIfExists(final Object instance, final String fieldName, final Object value)
CapabilitiesImmutable getChosenCapabilities()
Return the capabilities reflecting this graphics configuration, which may differ from the capabilitie...
Specifies an immutable set of capabilities that a window's rendering context must support,...
boolean isOnscreen()
Returns whether an on- or offscreen surface is requested, available or chosen.
Extend the NativeSurface interface with windowing information such as window-handle,...
Immutable Point interface.
boolean equals(Object obj)
Checks whether two points objects are equal.
Specifying NEWT's Window functionality:
boolean setFullscreen(boolean fullscreen)
Enable or disable fullscreen mode for this window.
void setUndecorated(boolean value)
void destroy()
Destroys this window incl.releasing all related resources.
NEWT WindowEvent listener.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.