28package com.jogamp.opengl.test.junit.jogl.util.texture;
30import java.io.IOException;
31import java.io.InputStream;
32import java.net.MalformedURLException;
33import java.net.URLConnection;
35import com.jogamp.opengl.GLAutoDrawable;
36import com.jogamp.opengl.GLCapabilities;
37import com.jogamp.opengl.GLEventListener;
38import com.jogamp.opengl.GLProfile;
40import org.junit.Assert;
42import org.junit.FixMethodOrder;
43import org.junit.runners.MethodSorters;
45import com.jogamp.common.util.IOUtil;
46import com.jogamp.newt.opengl.GLWindow;
47import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
48import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
49import com.jogamp.opengl.test.junit.util.MiscUtils;
50import com.jogamp.opengl.test.junit.util.QuitAdapter;
51import com.jogamp.opengl.test.junit.util.UITestCase;
52import com.jogamp.opengl.util.Animator;
53import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
54import com.jogamp.opengl.util.GLReadBufferUtil;
55import com.jogamp.opengl.util.texture.TextureData;
56import com.jogamp.opengl.util.texture.TextureIO;
57import com.jogamp.opengl.util.texture.spi.JPEGImage;
58import com.jogamp.opengl.GL;
66@FixMethodOrder(MethodSorters.NAME_ASCENDING)
69 static boolean showFPS =
false;
70 static long duration = 100;
72 public void testImpl(
final InputStream istream)
throws InterruptedException, IOException {
74 Assert.assertNotNull(image);
76 System.err.println(
"JPEGImage: "+image+
", hasAlpha "+hasAlpha);
85 final int internalFormat;
87 internalFormat = hasAlpha ? GL.GL_RGBA8 :
GL.
GL_RGB8;
89 internalFormat = hasAlpha ? GL.GL_RGBA :
GL.
GL_RGB;
102 System.err.println(
"TextureData: "+texData);
105 glad.
setTitle(
"TestJPEGImage01NEWT");
114 boolean shot =
false;
127 @Override
public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
138 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
147 public void testReadES2_RGBn() throws InterruptedException, IOException, MalformedURLException {
148 final String fname =
null == _fname ?
"test-ntscN_3-01-160x90-90pct-yuv444-base.jpg" : _fname;
149 final URLConnection urlConn = IOUtil.getResource(fname, this.getClass().getClassLoader(), this.getClass());
150 testImpl(urlConn.getInputStream());
153 static String _fname =
null;
154 public static void main(
final String args[]) {
155 for(
int i=0; i<args.length; i++) {
156 if(args[i].equals(
"-time")) {
159 }
else if(args[i].equals(
"-file")) {
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 GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
final boolean isGL2ES3()
Indicates whether this profile is capable of GL2ES3.
Test reading and displaying a JPG image.
static void main(final String args[])
void testImpl(final InputStream istream)
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}.
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_RGB8
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_EXT_texture, GL_OES_rgb8_rgba8, GL_OES_required_internalformat ...
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 ...