29package com.jogamp.opengl.test.junit.jogl.util.texture;
32import com.jogamp.common.util.IOUtil;
33import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
34import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
35import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener;
36import com.jogamp.opengl.test.junit.util.MiscUtils;
37import com.jogamp.opengl.test.junit.util.QuitAdapter;
38import com.jogamp.opengl.test.junit.util.UITestCase;
40import com.jogamp.opengl.GLAutoDrawable;
41import com.jogamp.opengl.GLEventListener;
42import com.jogamp.opengl.GLProfile;
43import com.jogamp.opengl.GLCapabilities;
44import com.jogamp.opengl.awt.GLCanvas;
46import com.jogamp.opengl.util.texture.TextureData;
47import com.jogamp.opengl.util.texture.TextureIO;
48import com.jogamp.opengl.util.texture.spi.TextureProvider;
49import com.jogamp.opengl.util.Animator;
50import com.jogamp.opengl.util.GLReadBufferUtil;
52import java.awt.Dimension;
54import java.io.IOException;
55import java.io.InputStream;
56import java.net.URLConnection;
58import org.junit.Assert;
59import org.junit.After;
60import org.junit.Assume;
61import org.junit.Before;
62import org.junit.BeforeClass;
64import org.junit.FixMethodOrder;
65import org.junit.runners.MethodSorters;
73@FixMethodOrder(MethodSorters.NAME_ASCENDING)
75 static boolean showFPS =
false;
76 static long duration = 100;
77 InputStream grayTextureStream;
78 InputStream testTextureStream;
87 Assert.assertNotNull(grayTextureStream);
89 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-ntscN_3-01-160x90.png", this.getClass().getClassLoader(), this.getClass());
90 Assert.assertNotNull(testTextureUrlConn);
91 testTextureStream = testTextureUrlConn.getInputStream();
92 Assert.assertNotNull(testTextureStream);
98 grayTextureStream =
null;
99 testTextureStream =
null;
102 public void testImpl(
final boolean useFFP,
final InputStream istream,
final boolean useAWTIIOP)
103 throws InterruptedException, IOException
112 System.err.println(getSimpleTestName(
".")+
": GLProfile n/a, useFFP: "+useFFP);
118 final TextureProvider texProvider =
new com.jogamp.opengl.util.texture.spi.awt.IIOTextureProvider();
123 System.err.println(
"TextureData: "+texData);
127 glc.setMinimumSize(glc_sz);
128 glc.setPreferredSize(glc_sz);
129 final Frame frame =
new Frame(
"TestPNGTextureGL2FromFileAWT");
130 Assert.assertNotNull(frame);
138 boolean shot =
false;
152 @Override
public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
156 new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter, glc).addTo(glc);
157 new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter, glc).addTo(glc);
160 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
163 frame.setVisible(
true);
165 }
catch(
final Throwable throwable ) {
166 throwable.printStackTrace();
167 Assume.assumeNoException( throwable );
174 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
180 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
182 frame.setVisible(
false);
186 }
catch(
final Throwable throwable ) {
187 throwable.printStackTrace();
188 Assume.assumeNoException( throwable );
194 testImpl(
true, grayTextureStream,
true);
198 testImpl(
false, grayTextureStream,
true);
203 testImpl(
true, grayTextureStream,
false);
207 testImpl(
false, grayTextureStream,
false);
212 testImpl(
true, testTextureStream,
true);
216 testImpl(
false, testTextureStream,
true);
221 testImpl(
true, testTextureStream,
false);
225 testImpl(
false, testTextureStream,
false);
228 public static void main(
final String args[])
throws IOException {
229 for(
int i=0; i<args.length; i++) {
230 if(args[i].equals(
"-time")) {
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.
A heavyweight AWT component which provides OpenGL rendering support.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Unit test for bug 417, which shows a GLException when reading a grayscale texture.
void testImpl(final boolean useFFP, final InputStream istream, final boolean useAWTIIOP)
void testGrayAWTILoaderGL2()
void testGrayPNGJLoaderES2()
void testTestAWTILoaderES2()
void testGrayAWTILoaderES2()
void testGrayPNGJLoaderGL2()
void testTestPNGJLoaderGL2()
static void main(final String args[])
void testTestPNGJLoaderES2()
void testTestAWTILoaderGL2()
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.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
Plug-in interface to TextureIO to support reading OpenGL textures from new file formats.
TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, boolean mipmap, String fileSuffix)
Produces a TextureData object from a stream, or returns null if the file format was not supported by ...