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.nativewindow.util.PixelFormat;
36import com.jogamp.opengl.GL;
37import com.jogamp.opengl.GLAutoDrawable;
38import com.jogamp.opengl.GLCapabilities;
39import com.jogamp.opengl.GLEventListener;
40import com.jogamp.opengl.GLProfile;
42import org.junit.Assert;
44import org.junit.FixMethodOrder;
45import org.junit.runners.MethodSorters;
47import com.jogamp.common.util.IOUtil;
48import com.jogamp.newt.opengl.GLWindow;
49import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
50import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
51import com.jogamp.opengl.test.junit.util.MiscUtils;
52import com.jogamp.opengl.test.junit.util.QuitAdapter;
53import com.jogamp.opengl.test.junit.util.UITestCase;
54import com.jogamp.opengl.util.Animator;
55import com.jogamp.opengl.util.GLReadBufferUtil;
56import com.jogamp.opengl.util.PNGPixelRect;
57import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
58import com.jogamp.opengl.util.texture.TextureData;
59import com.jogamp.opengl.util.texture.TextureIO;
67@FixMethodOrder(MethodSorters.NAME_ASCENDING)
69 static boolean showFPS =
false;
70 static long duration = 200;
72 public void testImpl(
final int num,
final String basename,
final InputStream istream,
final PixelFormat destFmt)
throws InterruptedException, IOException {
75 Assert.assertNotNull(image);
76 System.err.println(
"PNGPixelRect: "+basename+
", "+image);
79 System.err.println(
"GLPixelAttributes: "+glpa);
87 final int internalFormat;
89 internalFormat = hasAlpha ? GL.GL_RGBA8 :
GL.
GL_RGB8;
91 internalFormat = hasAlpha ? GL.GL_RGBA :
GL.
GL_RGB;
105 System.err.println(
"TextureData: "+texData);
108 glad.
setTitle(this.getSimpleTestName(
"."));
119 boolean shot =
false;
135 @Override
public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
146 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
155 public void testRead00_Manual() throws InterruptedException, IOException, MalformedURLException {
156 if(
null == _fname ) {
159 final URLConnection urlConn = IOUtil.getResource(_fname, this.getClass().getClassLoader(), this.getClass());
160 if(
null == urlConn ) {
161 throw new IOException(
"Cannot find "+_fname+
".png");
163 testImpl(0, _fname, urlConn.getInputStream(),
null);
167 public void testRead01_All() throws InterruptedException, IOException, MalformedURLException {
168 if(
null != _fname ) {
173 final URLConnection urlConn = IOUtil.getResource(basename+
".png", this.getClass().getClassLoader(), this.getClass());
174 if(
null == urlConn ) {
175 throw new IOException(
"Cannot find "+basename+
".png");
177 testImpl(i, basename, urlConn.getInputStream(),
null);
182 if(
null != _fname ) {
187 final URLConnection urlConn = IOUtil.getResource(basename+
".png", this.getClass().getClassLoader(), this.getClass());
188 if(
null == urlConn ) {
189 throw new IOException(
"Cannot find "+basename+
".png");
195 static String _fname =
null;
196 public static void main(
final String args[]) {
197 for(
int i=0; i<args.length; i++) {
198 if(args[i].equals(
"-time")) {
201 }
else if(args[i].equals(
"-file")) {
void setAlphaBits(final int alphaBits)
Sets the number of bits requested for the color buffer's alpha component.
DimensionImmutable getSize()
Returns the size, i.e.
ByteBuffer getPixels()
Returns the pixels.
PixelFormat getPixelformat()
Returns the PixelFormat.
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.
static final String[] allBasenames
static final String[] greyBasenames
Test reading and displaying a PNG image.
void testRead02_Gray2RGBA()
void testImpl(final int num, final String basename, final InputStream istream, final PixelFormat destFmt)
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.
final PixelFormat pfmt
PixelFormat describing the component layout
Utility to read out the current FB to TextureData, optionally writing the data back to a texture obje...
static PNGPixelRect read(final InputStream in, final PixelFormat ddestFmt, final boolean destDirectBuffer, final int destMinStrideInBytes, final boolean destIsGLOriented)
Reads a PNG image from the specified InputStream.
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}.
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.
GLContext getContext()
Returns the GLContext associated which this GL object.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
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 ...