29package com.jogamp.opengl.test.junit.jogl.util.texture;
31import java.awt.Dimension;
34import com.jogamp.opengl.GLAutoDrawable;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLEventListener;
37import com.jogamp.opengl.GLProfile;
38import com.jogamp.opengl.Threading;
39import com.jogamp.opengl.awt.GLCanvas;
41import jogamp.nativewindow.jawt.JAWTUtil;
43import com.jogamp.opengl.util.Animator;
44import com.jogamp.opengl.util.GLReadBufferUtil;
45import com.jogamp.opengl.util.texture.TextureIO;
47import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
48import com.jogamp.opengl.test.junit.util.UITestCase;
49import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
51import org.junit.Assert;
52import org.junit.Assume;
53import org.junit.BeforeClass;
55import org.junit.FixMethodOrder;
56import org.junit.runners.MethodSorters;
58@FixMethodOrder(MethodSorters.NAME_ASCENDING)
62 static int width, height;
67 Assert.assertNotNull(glp);
69 Assert.assertNotNull(caps);
76 if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) {
77 System.err.println(
"onscreen layer n/a");
80 if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) {
81 System.err.println(
"offscreen layer n/a");
88 glc.setMinimumSize(glc_sz);
89 glc.setPreferredSize(glc_sz);
91 final Frame frame =
new Frame(getSimpleTestName(
"."));
92 Assert.assertNotNull(frame);
97 int i=0, fw_old=0, dw_old=0, c=0;
101 final int fw = frame.getWidth();
102 final int fh = frame.getHeight();
105 final boolean sz_changed = fw_old != fw && dw_old != dw && dw <= 512;
115 System.err.println(
"XXX: ["+fw_old+
", "+dw_old+
"], "+fw+
"x"+fh+
", "+dw+
"x"+dh+
", sz_changed "+sz_changed+
", snap "+snap);
123 glc.setMinimumSize(new_sz);
124 glc.setPreferredSize(new_sz);
128 } }, glc.getTreeLock());
131 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
138 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
141 frame.setVisible(
true);
143 }
catch(
final Throwable throwable ) {
144 throwable.printStackTrace();
145 Assume.assumeNoException( throwable );
149 Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer,
159 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
161 frame.setVisible(
false);
165 }
catch(
final Throwable throwable ) {
166 throwable.printStackTrace();
167 Assume.assumeNoException( throwable );
173 testWritePNGWithResizeImpl(
false);
178 testWritePNGWithResizeImpl(
true);
181 public static void main(
final String args[]) {
void setAlphaBits(final int alphaBits)
Sets the number of bits requested for the color buffer's alpha component.
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
This API provides access to the threading model for the implementation of the classes in this package...
static final void invoke(final boolean wait, final Runnable r, final Object lock)
If not isOpenGLThread() and the lock is not being hold by this thread, invoke Runnable r on the OpenG...
A heavyweight AWT component which provides OpenGL rendering support.
void setShallUseOffscreenLayer(final boolean v)
Request an offscreen layer, if supported.
final boolean isOffscreenLayerSurfaceEnabled()
Returns true if this instance uses an offscreen layer, otherwise false.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
void testWritePNGWithResizeImpl(final boolean offscreenLayer)
static void main(final String args[])
void testOnscreenWritePNGWithResize()
void testOffscreenWritePNGWithResize()
static boolean waitForRealized(final java.awt.Component comp, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final java.awt.Component comp, final boolean visible, final Runnable waitAction)
final int getTotalFPSFrames()
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
Utility to read out the current FB to TextureData, optionally writing the data back to a texture obje...
static final String PNG
Constant which can be used as a file suffix to indicate a PNG file, value {@value}.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void setSize(int width, int height)
Requests a new width and height for this AWTGLAutoDrawable.