29package com.jogamp.opengl.test.junit.jogl.util.texture;
31import com.jogamp.common.util.InterruptSource;
32import com.jogamp.newt.opengl.GLWindow;
34import com.jogamp.opengl.GLAutoDrawable;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLEventListener;
37import com.jogamp.opengl.GLProfile;
39import com.jogamp.opengl.util.Animator;
40import com.jogamp.opengl.util.GLReadBufferUtil;
41import com.jogamp.opengl.util.texture.TextureIO;
43import com.jogamp.opengl.test.junit.util.UITestCase;
44import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
45import com.jogamp.opengl.test.junit.jogl.offscreen.WindowUtilNEWT;
47import org.junit.Assert;
48import org.junit.BeforeClass;
50import org.junit.FixMethodOrder;
51import org.junit.runners.MethodSorters;
53@FixMethodOrder(MethodSorters.NAME_ASCENDING)
57 static int width, height;
62 Assert.assertNotNull(glp);
64 Assert.assertNotNull(caps);
70 private void testWritePNGWithResizeImpl(
final boolean offscreen)
throws InterruptedException {
74 Assert.assertNotNull(glWindow);
75 glWindow.
setTitle(
"Shared Gears NEWT Test");
76 glWindow.
setSize(width, height);
79 int i=0, dw_old=0, c=0;
81 System.err.println(
"XXX: init");
84 System.err.println(
"XXX: dispose");
89 final boolean sz_changed = dw_old != dw && dw <= 512;
99 System.err.println(
"XXX: ["+dw_old+
"], "+dw+
"x"+dh+
", sz_changed "+sz_changed+
", snap "+snap);
101 snapshot(i++,
null, drawable.
getGL(), screenshot, TextureIO.PNG,
null);
103 new InterruptSource.Thread() {
110 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
112 final Animator animator =
new Animator(glWindow);
113 animator.setUpdateFPSFrames(60,
null);
118 while(animator.getTotalFPSFrames() < 50) {
128 testWritePNGWithResizeImpl(
false);
133 testWritePNGWithResizeImpl(
true);
136 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.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final void setTitle(final String title)
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 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.
Specifies the the OpenGL profile.
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
static GLCapabilities fixCaps(final GLCapabilities caps, final boolean onscreen, final boolean pbuffer, final boolean undecorated)
void testOffscreenWritePNGWithResize()
void testOnscreenWritePNGWithResize()
static void main(final String args[])
Utility to read out the current FB to TextureData, optionally writing the data back to a texture obje...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
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.