29package com.jogamp.opengl.test.junit.jogl.util.texture;
32import com.jogamp.common.os.Platform;
33import com.jogamp.common.util.IOUtil;
34import com.jogamp.junit.util.JunitTracer;
35import com.jogamp.newt.opengl.GLWindow;
36import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
37import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
38import com.jogamp.opengl.test.junit.util.MiscUtils;
39import com.jogamp.opengl.test.junit.util.QuitAdapter;
40import com.jogamp.opengl.test.junit.util.UITestCase;
42import javax.imageio.ImageIO;
43import com.jogamp.opengl.GL;
44import com.jogamp.opengl.GLAutoDrawable;
45import com.jogamp.opengl.GLEventListener;
46import com.jogamp.opengl.GLProfile;
47import com.jogamp.opengl.GLCapabilities;
49import com.jogamp.opengl.util.texture.TextureData;
50import com.jogamp.opengl.util.texture.TextureIO;
51import com.jogamp.opengl.util.texture.awt.AWTTextureData;
52import com.jogamp.opengl.util.texture.spi.JPEGImage;
53import com.jogamp.opengl.util.Animator;
54import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
55import com.jogamp.opengl.util.GLReadBufferUtil;
57import java.awt.image.BufferedImage;
58import java.io.IOException;
59import java.io.InputStream;
60import java.net.URLConnection;
62import org.junit.Assert;
63import org.junit.BeforeClass;
65import org.junit.FixMethodOrder;
66import org.junit.runners.MethodSorters;
68@FixMethodOrder(MethodSorters.NAME_ASCENDING)
70 static boolean showFPS =
false;
71 static long duration = 100;
73 String[] files = {
"test-ntscN_3-01-160x90-90pct-yuv444-base.jpg",
74 "test-ntscN_3-01-160x90-90pct-yuv444-prog.jpg",
75 "test-ntscN_3-01-160x90-60pct-yuv422h-base.jpg",
76 "test-ntscN_3-01-160x90-60pct-yuv422h-prog.jpg",
79 "j3-baseline_gray.jpg",
83 void testImpl(
final String fname)
throws InterruptedException, IOException {
86 final GLWindow w1 = testJOGLJpeg(fname);
97 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
106 GLWindow testJOGLJpeg(
final String fname)
throws InterruptedException, IOException {
107 final URLConnection testTextureUrlConn = IOUtil.getResource(fname, this.getClass().getClassLoader(), this.getClass());
108 Assert.assertNotNull(testTextureUrlConn);
109 final InputStream istream = testTextureUrlConn.getInputStream();
110 Assert.assertNotNull(istream);
113 Assert.assertNotNull(image);
114 System.err.println(
"JPEGImage: "+image);
129 System.err.println(
"TextureData: "+texData);
138 glad1.
setSize(texData.getWidth(), texData.getHeight());
146 boolean shot =
false;
160 @Override
public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
166 GLWindow testAWTJpeg(
final String fname,
final int xpos)
throws InterruptedException, IOException {
167 final URLConnection testTextureUrlConn = IOUtil.getResource(fname, this.getClass().getClassLoader(), this.getClass());
168 Assert.assertNotNull(testTextureUrlConn);
169 final InputStream istream = testTextureUrlConn.getInputStream();
170 Assert.assertNotNull(istream);
174 int w = 300, h = 300;
176 final BufferedImage img = ImageIO.read(istream);
178 System.err.println(
"TextureData: "+texData);
181 }
catch (
final Exception e) {
182 System.err.println(
"AWT ImageIO failure w/ file "+fname+
": "+e.getMessage());
199 if( texData !=
null ) {
206 boolean shot =
false;
220 @Override
public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
269 if( Platform.OSType.MACOS == Platform.getOSType() ) {
270 JunitTracer.setTestSupported(
false);
274 static boolean manual_test =
false;
276 public static void main(
final String args[])
throws IOException {
278 for(
int i=0; i<args.length; i++) {
279 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 setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
final void setTitle(final String title)
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
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 getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
static void beforeClass()
void test02YUV420Prog_ES2()
void test01YUV422hBase__ES2()
void test02YUV420BaseGray_ES2()
static void main(final String args[])
void test01YUV444Base__ES2()
void test01YUV422hProg_ES2()
void test02YUV420Base__ES2()
void test01YUV444Prog__ES2()
static long atol(final String str, final long def)
final long getTotalFPSDuration()
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
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}.
ByteBuffer getData()
Returns the raw data for this texture in the correct (bottom-to-top) order for calls to glTexImage2D.
int getBytesPerPixel()
Returns the bytes per pixel.
int getGLFormat()
Returns the OpenGL format for this texture; e.g.
int getWidth()
Returns the width of the image.
int getHeight()
Returns the height of the image.
int getGLType()
Returns the OpenGL data type: GL.GL_UNSIGNED_BYTE.
static JPEGImage read(final InputStream in, final ColorSpace cs)
Reads a JPEG image from the specified InputStream, using the given color space for storage.
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.
static final int GL_RGB
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RGB" with expression ...
static final int GL_RGBA
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RGBA" with expression...