29package com.jogamp.opengl.test.junit.jogl.acore;
31import java.awt.Component;
32import java.awt.Dimension;
34import java.io.IOException;
36import com.jogamp.nativewindow.AbstractGraphicsDevice;
37import com.jogamp.nativewindow.CapabilitiesImmutable;
38import com.jogamp.opengl.GLAutoDrawable;
39import com.jogamp.opengl.GLCapabilities;
40import com.jogamp.opengl.GLCapabilitiesImmutable;
41import com.jogamp.opengl.GLContext;
42import com.jogamp.opengl.GLDrawable;
43import com.jogamp.opengl.GLDrawableFactory;
44import com.jogamp.opengl.GLEventListener;
45import com.jogamp.opengl.GLProfile;
47import jogamp.nativewindow.jawt.JAWTUtil;
48import jogamp.opengl.GLGraphicsConfigurationUtil;
50import org.junit.Assert;
51import org.junit.Assume;
53import org.junit.FixMethodOrder;
54import org.junit.runners.MethodSorters;
56import com.jogamp.newt.awt.NewtCanvasAWT;
57import com.jogamp.newt.opengl.GLWindow;
58import com.jogamp.opengl.JoglVersion;
59import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
60import com.jogamp.opengl.test.junit.util.NewtTestUtil;
61import com.jogamp.opengl.test.junit.util.GLTestUtil;
62import com.jogamp.opengl.test.junit.util.UITestCase;
70@FixMethodOrder(MethodSorters.NAME_ASCENDING)
72 static final int widthStep = 800/4;
73 static final int heightStep = 600/4;
74 volatile int szStep = 2;
78 System.err.println(
"Profile "+profile+
" n/a");
84 static void setComponentSize(
final Frame frame,
final Component comp,
final int width,
final int height) {
86 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
89 comp.setMinimumSize(new_sz);
90 comp.setPreferredSize(new_sz);
95 }
catch(
final Throwable throwable ) {
96 throwable.printStackTrace();
97 Assume.assumeNoException( throwable );
102 void setMakeSnapshot();
106 if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) {
107 System.err.println(
"onscreen layer n/a");
110 if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) {
111 System.err.println(
"offscreen layer n/a");
114 System.out.println(
"Requested GL Caps: "+reqGLCaps);
118 GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(reqGLCaps, factory, device) :
119 GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, factory, device);
120 System.out.println(
"Expected GL Caps: "+expGLCaps);
123 Assert.assertNotNull(glad);
127 Assert.assertNotNull(nca);
130 nca.setPreferredSize(size0);
131 nca.setMinimumSize(size0);
134 final Frame frame =
new Frame(getSimpleTestName(
"."));
135 Assert.assertNotNull(frame);
139 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
142 frame.setVisible(
true);
144 }
catch(
final Throwable throwable ) {
145 throwable.printStackTrace();
146 Assume.assumeNoException( throwable );
151 System.out.println(
"Window: "+glad.getClass().getName());
155 System.out.println(
"Window Caps Pre_GL: "+chosenCaps);
156 Assert.assertNotNull(chosenCaps);
169 Assert.assertNotNull(actualDrawable);
170 System.out.println(
"Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+
", "+actualDrawable.
getNativeSurface().getClass().getName());
174 System.out.println(
"Drawable Post-GL(1): "+glad.getClass().getName()+
", "+glad.
getNativeSurface().getClass().getName());
178 System.out.println(
"Chosen GL Caps(1): "+chosenGLCaps);
179 Assert.assertNotNull(chosenGLCaps);
182 Assert.assertTrue(chosenGLCaps.
getRedBits()>5);
185 Assert.assertEquals(expGLCaps.
isFBO(), chosenGLCaps.
isFBO());
196 System.out.println(
"Chosen GL CTX (2): "+context.
getGLVersion());
197 Assert.assertNotNull(context);
202 System.out.println(
"Drawable Post-GL(2): "+glad.getClass().getName()+
", "+glad.
getNativeSurface().getClass().getName());
213 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glad.
getSurfaceWidth()+
"x"+glad.
getSurfaceHeight(),
220 setComponentSize(frame, nca, widthStep*szStep, heightStep*szStep);
221 expSurfaceSize[0] = widthStep*szStep;
222 expSurfaceSize[1] = heightStep*szStep;
224 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glad.
getSurfaceWidth()+
"x"+glad.
getSurfaceHeight(),
232 setComponentSize(frame, nca, widthStep*szStep, heightStep*szStep);
233 expSurfaceSize[0] = widthStep*szStep;
234 expSurfaceSize[1] = heightStep*szStep;
236 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glad.
getSurfaceWidth()+
"x"+glad.
getSurfaceHeight(),
245 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
247 frame.setVisible(
false);
251 }
catch(
final Throwable throwable ) {
252 throwable.printStackTrace();
253 Assume.assumeNoException( throwable );
256 System.out.println(
"Fin: "+nca);
257 System.out.println(
"Fin: "+glad);
263 if(
null == reqGLCaps)
return;
264 doTest(
false, reqGLCaps,
new GearsES2(1));
270 if(
null == reqGLCaps)
return;
272 doTest(
false, reqGLCaps,
new GearsES2(1));
278 if(
null == reqGLCaps)
return;
281 doTest(
false, reqGLCaps,
new GearsES2(1));
287 if(
null == reqGLCaps)
return;
291 doTest(
false, reqGLCaps,
new GearsES2(1));
297 if(
null == reqGLCaps)
return;
298 doTest(
true, reqGLCaps,
new GearsES2(1));
304 if(
null == reqGLCaps)
return;
308 doTest(
true, reqGLCaps,
new GearsES2(1));
314 if(
null == reqGLCaps)
return;
319 doTest(
true, reqGLCaps,
new GearsES2(1));
325 if(
null == reqGLCaps)
return;
331 doTest(
true, reqGLCaps,
new GearsES2(1));
337 if(
null == reqGLCaps)
return;
340 doTest(
true, reqGLCaps,
new GearsES2(1));
343 public static void main(
final String args[])
throws IOException {
void setOnscreen(final boolean onscreen)
Sets whether the surface shall be on- or offscreen.
AWT Canvas containing a NEWT Window using native parenting.
void setShallUseOffscreenLayer(final boolean v)
Request an offscreen layer, if supported.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
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.
void setPBuffer(final boolean enable)
Requesting offscreen pbuffer mode.
void setStencilBits(final int stencilBits)
Sets the number of bits requested for the stencil buffer.
void setFBO(final boolean enable)
Requesting offscreen FBO mode.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
void setSampleBuffers(final boolean enable)
Defaults to false.
Abstraction for an OpenGL rendering context.
final boolean isCreated()
Indicates whether the underlying native OpenGL context has been created.
final String getGLVersion()
Returns a valid OpenGL version string, ie
abstract AbstractGraphicsDevice getDefaultDevice()
Retrieve the default device connection, unit ID and unique ID name.
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
Specifies the the OpenGL profile.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Tests using a NEWT GLWindow auto drawable for on- and offscreen cases.
void testGL2OffScreenFBODblBufMSAA()
void testGL2OffScreenFBODblBufStencilMSAA()
void testGL2OnScreenDblBufStencilMSAA()
void testGL2OffScreenPbuffer()
void testGL2OnScreenDblBufStencil()
void testGL2OffScreenLayerAutoDblBuf()
void testGL2OnScreenDblBuf()
static void main(final String args[])
void testGL2OnScreenDblBufMSAA()
void testGL2OffScreenFBODblBufStencil()
static boolean waitForSize(final GLDrawable drawable, final int width, final int height, final Runnable waitAction)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final Window win, final boolean visible, final Runnable waitAction)
A interface describing a graphics device in a toolkit-independent manner.
Specifies an immutable set of capabilities that a window's rendering context must support,...
int getBlueBits()
Returns the number of bits for the color buffer's blue component.
boolean isBitmap()
Returns whether bitmap offscreen mode is requested, available or chosen.
int getRedBits()
Returns the number of bits for the color buffer's red component.
int getGreenBits()
Returns the number of bits for the color buffer's green component.
boolean isOnscreen()
Returns whether an on- or offscreen surface is requested, available or chosen.
int[] convertToPixelUnits(final int[] windowUnitsAndResult)
Converts the given window units into pixel units in place.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GLContext getContext()
Returns the context associated with this drawable.
GLDrawable getDelegatedDrawable()
If the implementation uses delegation, return the delegated GLDrawable instance, otherwise return thi...
Specifies an immutable set of OpenGL capabilities.
int getDepthBits()
Returns the number of depth buffer bits.
boolean isPBuffer()
Returns whether pbuffer offscreen mode is requested, available or chosen.
GLProfile getGLProfile()
Returns the GL profile you desire or used by the drawable.
boolean isFBO()
Returns whether FBO offscreen mode is requested, available or chosen.
An abstraction for an OpenGL rendering target.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.