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;
67 InputStream testTextureStream01YUV444_Base;
68 InputStream testTextureStream01YUV444_Prog;
70 InputStream testTextureStream01YUV422h_Base;
71 InputStream testTextureStream01YUV422h_Prog;
73 InputStream testTextureStream02YUV420_Base;
74 InputStream testTextureStream02YUV420_Prog;
75 InputStream testTextureStream02YUV420_BaseGray;
77 InputStream testTextureStream03CMYK_01;
78 InputStream testTextureStream03YCCK_01;
80 InputStream testTextureStream04QTTDefPostFrame;
85 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscN_3-01-160x90-90pct-yuv444-base.jpg", this.getClass().getClassLoader(), this.getClass());
86 Assert.assertNotNull(testTextureUrlConn);
87 testTextureStream01YUV444_Base = testTextureUrlConn.getInputStream();
88 Assert.assertNotNull(testTextureStream01YUV444_Base);
91 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscN_3-01-160x90-90pct-yuv444-prog.jpg", this.getClass().getClassLoader(), this.getClass());
92 Assert.assertNotNull(testTextureUrlConn);
93 testTextureStream01YUV444_Prog = testTextureUrlConn.getInputStream();
94 Assert.assertNotNull(testTextureStream01YUV444_Prog);
97 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscN_3-01-160x90-60pct-yuv422h-base.jpg", this.getClass().getClassLoader(), this.getClass());
98 Assert.assertNotNull(testTextureUrlConn);
99 testTextureStream01YUV422h_Base = testTextureUrlConn.getInputStream();
100 Assert.assertNotNull(testTextureStream01YUV422h_Base);
103 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscN_3-01-160x90-60pct-yuv422h-prog.jpg", this.getClass().getClassLoader(), this.getClass());
104 Assert.assertNotNull(testTextureUrlConn);
105 testTextureStream01YUV422h_Prog = testTextureUrlConn.getInputStream();
106 Assert.assertNotNull(testTextureStream01YUV422h_Prog);
110 final URLConnection testTextureUrlConn = IOUtil.getResource(
"j1-baseline.jpg", this.getClass().getClassLoader(), this.getClass());
111 Assert.assertNotNull(testTextureUrlConn);
112 testTextureStream02YUV420_Base = testTextureUrlConn.getInputStream();
113 Assert.assertNotNull(testTextureStream02YUV420_Base);
116 final URLConnection testTextureUrlConn = IOUtil.getResource(
"j2-progressive.jpg", this.getClass().getClassLoader(), this.getClass());
117 Assert.assertNotNull(testTextureUrlConn);
118 testTextureStream02YUV420_Prog = testTextureUrlConn.getInputStream();
119 Assert.assertNotNull(testTextureStream02YUV420_Prog);
122 final URLConnection testTextureUrlConn = IOUtil.getResource(
"j3-baseline_gray.jpg", this.getClass().getClassLoader(), this.getClass());
123 Assert.assertNotNull(testTextureUrlConn);
124 testTextureStream02YUV420_BaseGray = testTextureUrlConn.getInputStream();
125 Assert.assertNotNull(testTextureStream02YUV420_BaseGray);
129 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-cmyk-01.jpg", this.getClass().getClassLoader(), this.getClass());
130 Assert.assertNotNull(testTextureUrlConn);
131 testTextureStream03CMYK_01 = testTextureUrlConn.getInputStream();
132 Assert.assertNotNull(testTextureStream03CMYK_01);
135 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ycck-01.jpg", this.getClass().getClassLoader(), this.getClass());
136 Assert.assertNotNull(testTextureUrlConn);
137 testTextureStream03YCCK_01 = testTextureUrlConn.getInputStream();
138 Assert.assertNotNull(testTextureStream03YCCK_01);
141 final URLConnection testTextureUrlConn = IOUtil.getResource(
"bug745_qttdef_post_frame.jpg", this.getClass().getClassLoader(), this.getClass());
142 Assert.assertNotNull(testTextureUrlConn);
143 testTextureStream04QTTDefPostFrame = testTextureUrlConn.getInputStream();
144 Assert.assertNotNull(testTextureStream04QTTDefPostFrame);
151 testTextureStream01YUV444_Base =
null;
152 testTextureStream01YUV444_Prog =
null;
153 testTextureStream01YUV422h_Base =
null;
154 testTextureStream01YUV422h_Prog =
null;
155 testTextureStream02YUV420_Base =
null;
156 testTextureStream02YUV420_Prog =
null;
157 testTextureStream02YUV420_BaseGray =
null;
158 testTextureStream03CMYK_01 =
null;
159 testTextureStream03YCCK_01 =
null;
160 testTextureStream04QTTDefPostFrame =
null;
163 public void testImpl(
final boolean useFFP,
final InputStream istream)
throws InterruptedException, IOException {
171 System.err.println(getSimpleTestName(
".")+
": GLProfile n/a, useFFP: "+useFFP);
178 System.err.println(
"TextureData: "+texData);
181 glad.
setTitle(
"TestPNGTextureGL2FromFileNEWT");
190 boolean shot =
false;
203 @Override
public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
214 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
224 testImpl(
true, testTextureStream01YUV444_Base);
228 testImpl(
false, testTextureStream01YUV444_Base);
232 testImpl(
true, testTextureStream01YUV444_Prog);
236 testImpl(
false, testTextureStream01YUV444_Prog);
241 testImpl(
false, testTextureStream01YUV422h_Base);
245 testImpl(
false, testTextureStream01YUV422h_Prog);
250 testImpl(
false, testTextureStream02YUV420_Base);
254 testImpl(
false, testTextureStream02YUV420_Prog);
258 testImpl(
false, testTextureStream02YUV420_BaseGray);
263 testImpl(
false, testTextureStream03CMYK_01);
267 testImpl(
false, testTextureStream03YCCK_01);
272 testImpl(
false, testTextureStream04QTTDefPostFrame);
275 public static void main(
final String args[])
throws IOException {
276 for(
int i=0; i<args.length; i++) {
277 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)
void test01YUV444Base__GL2()
void test02YUV420BaseGray_ES2()
void test01YUV422hBase__ES2()
void test02YUV420Prog_ES2()
void test01YUV444Prog__ES2()
static void main(final String args[])
void test01YUV444Base__ES2()
void test01YUV444Prog__GL2()
void test04QTTDefPostFrame_ES2()
void test02YUV420Base__ES2()
void test01YUV422hProg_ES2()
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.
static final String JPG
Constant which can be used as a file suffix to indicate a JPEG 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.
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.