29package com.jogamp.opengl.test.junit.jogl.util.texture;
32import com.jogamp.common.util.IOUtil;
33import com.jogamp.newt.opengl.GLWindow;
34import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
35import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
36import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener;
37import com.jogamp.opengl.test.junit.util.MiscUtils;
38import com.jogamp.opengl.test.junit.util.QuitAdapter;
39import com.jogamp.opengl.test.junit.util.UITestCase;
41import com.jogamp.opengl.GLAutoDrawable;
42import com.jogamp.opengl.GLEventListener;
43import com.jogamp.opengl.GLProfile;
44import com.jogamp.opengl.GLCapabilities;
46import com.jogamp.opengl.util.texture.TextureData;
47import com.jogamp.opengl.util.texture.TextureIO;
48import com.jogamp.opengl.util.Animator;
49import com.jogamp.opengl.util.GLReadBufferUtil;
51import java.io.IOException;
52import java.io.InputStream;
53import java.net.URLConnection;
55import org.junit.Assert;
56import org.junit.After;
57import org.junit.Before;
59import org.junit.FixMethodOrder;
60import org.junit.runners.MethodSorters;
62@FixMethodOrder(MethodSorters.NAME_ASCENDING)
64 static boolean showFPS =
false;
65 static long duration = 100;
66 InputStream grayTextureStream;
68 InputStream testTextureStreamN_3;
69 InputStream testTextureStreamN_4;
70 InputStream testTextureStreamNG4;
72 InputStream testTextureStreamI_3;
73 InputStream testTextureStreamIG3;
74 InputStream testTextureStreamI_4;
75 InputStream testTextureStreamIG4;
77 InputStream testTextureStreamP_3;
78 InputStream testTextureStreamP_4;
83 Assert.assertNotNull(grayTextureStream);
85 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscN_3-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
86 Assert.assertNotNull(testTextureUrlConn);
87 testTextureStreamN_3 = testTextureUrlConn.getInputStream();
88 Assert.assertNotNull(testTextureStreamN_3);
91 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscN_4-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
92 Assert.assertNotNull(testTextureUrlConn);
93 testTextureStreamN_4 = testTextureUrlConn.getInputStream();
94 Assert.assertNotNull(testTextureStreamN_4);
97 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscNG4-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
98 Assert.assertNotNull(testTextureUrlConn);
99 testTextureStreamNG4 = testTextureUrlConn.getInputStream();
100 Assert.assertNotNull(testTextureStreamNG4);
104 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscI_3-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
105 Assert.assertNotNull(testTextureUrlConn);
106 testTextureStreamI_3 = testTextureUrlConn.getInputStream();
107 Assert.assertNotNull(testTextureStreamI_3);
110 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscIG3-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
111 Assert.assertNotNull(testTextureUrlConn);
112 testTextureStreamIG3 = testTextureUrlConn.getInputStream();
113 Assert.assertNotNull(testTextureStreamIG3);
116 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscI_4-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
117 Assert.assertNotNull(testTextureUrlConn);
118 testTextureStreamI_4 = testTextureUrlConn.getInputStream();
119 Assert.assertNotNull(testTextureStreamI_4);
122 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscIG4-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
123 Assert.assertNotNull(testTextureUrlConn);
124 testTextureStreamIG4 = testTextureUrlConn.getInputStream();
125 Assert.assertNotNull(testTextureStreamIG4);
130 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscP_3-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
131 Assert.assertNotNull(testTextureUrlConn);
132 testTextureStreamP_3 = testTextureUrlConn.getInputStream();
133 Assert.assertNotNull(testTextureStreamP_3);
136 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscP_4-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
137 Assert.assertNotNull(testTextureUrlConn);
138 testTextureStreamP_4 = testTextureUrlConn.getInputStream();
139 Assert.assertNotNull(testTextureStreamP_4);
145 grayTextureStream =
null;
146 testTextureStreamN_3 =
null;
147 testTextureStreamI_3 =
null;
148 testTextureStreamIG3 =
null;
149 testTextureStreamP_3 =
null;
150 testTextureStreamP_4 =
null;
153 public void testImpl(
final boolean useFFP,
final InputStream istream)
throws InterruptedException, IOException {
161 System.err.println(getSimpleTestName(
".")+
": GLProfile n/a, useFFP: "+useFFP);
168 System.err.println(
"TextureData: "+texData);
171 glad.
setTitle(
"TestPNGTextureGL2FromFileNEWT");
180 boolean shot =
false;
193 @Override
public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
204 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
214 testImpl(
true, grayTextureStream);
218 testImpl(
false, grayTextureStream);
223 testImpl(
true, testTextureStreamN_3);
227 testImpl(
false, testTextureStreamN_3);
231 testImpl(
true, testTextureStreamN_4);
235 testImpl(
false, testTextureStreamN_4);
239 testImpl(
false, testTextureStreamNG4);
244 testImpl(
false, testTextureStreamI_3);
248 testImpl(
false, testTextureStreamI_4);
252 testImpl(
false, testTextureStreamIG3);
256 testImpl(
false, testTextureStreamIG4);
261 testImpl(
false, testTextureStreamP_3);
265 testImpl(
false, testTextureStreamP_4);
268 public static void main(
final String args[])
throws IOException {
269 for(
int i=0; i<args.length; i++) {
270 if(args[i].equals(
"-time")) {
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 addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
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 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 boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
static GLProfile getMaxFixedFunc(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
Returns the highest profile, implementing the fixed function pipeline.
static final String GL2ES2
The intersection of the desktop GL3, GL2 and embedded ES2 profile.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
void testImpl(final boolean useFFP, final InputStream istream)
static void main(final String args[])
static long atol(final String str, final long def)
final long getTotalFPSDuration()
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...
Represents the data for an OpenGL texture.
int getHeight()
Returns the height in pixels of the texture data.
int getWidth()
Returns the width in pixels of the texture data.
static final String PNG
Constant which can be used as a file suffix to indicate a PNG file, value {@value}.
static TextureData newTextureData(final GLProfile glp, final File file, final boolean mipmap, String fileSuffix)
Creates a TextureData from the given file.
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.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.