29package com.jogamp.opengl.test.junit.jogl.util.texture;
31import java.io.IOException;
32import java.io.InputStream;
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.After;
41import org.junit.Assert;
42import org.junit.Before;
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.jogl.demos.gl2.TextureDraw01GL2Listener;
52import com.jogamp.opengl.test.junit.util.MiscUtils;
53import com.jogamp.opengl.test.junit.util.QuitAdapter;
54import com.jogamp.opengl.test.junit.util.UITestCase;
55import com.jogamp.opengl.util.Animator;
56import com.jogamp.opengl.util.GLReadBufferUtil;
57import com.jogamp.opengl.util.texture.TextureData;
58import com.jogamp.opengl.util.texture.TextureIO;
60@FixMethodOrder(MethodSorters.NAME_ASCENDING)
62 static boolean showFPS =
false;
63 static long duration = 100;
65 InputStream testTextureStream01U32;
66 InputStream testTextureStream02RLE32;
67 InputStream testTextureStream03RLE32;
72 final URLConnection testTextureUrlConn = IOUtil.getResource(
"test-u32.tga", this.getClass().getClassLoader(), this.getClass());
73 Assert.assertNotNull(testTextureUrlConn);
74 testTextureStream01U32 = testTextureUrlConn.getInputStream();
75 Assert.assertNotNull(testTextureStream01U32);
78 final URLConnection testTextureUrlConn = IOUtil.getResource(
"bug744-rle32.tga", this.getClass().getClassLoader(), this.getClass());
79 Assert.assertNotNull(testTextureUrlConn);
80 testTextureStream02RLE32 = testTextureUrlConn.getInputStream();
81 Assert.assertNotNull(testTextureStream02RLE32);
84 final URLConnection testTextureUrlConn = IOUtil.getResource(
"bug982.rle32.256x256.tga", this.getClass().getClassLoader(), this.getClass());
85 Assert.assertNotNull(testTextureUrlConn);
86 testTextureStream03RLE32 = testTextureUrlConn.getInputStream();
87 Assert.assertNotNull(testTextureStream03RLE32);
91 public void testImpl(
final boolean useFFP,
final InputStream istream)
throws InterruptedException, IOException {
99 System.err.println(getSimpleTestName(
".")+
": GLProfile n/a, useFFP: "+useFFP);
106 System.err.println(
"TextureData: "+texData);
109 glad.
setTitle(
"TestTGATextureGL2FromFileNEWT");
118 boolean shot =
false;
131 @Override
public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
142 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.
getTotalFPSDuration()<duration) {
152 testImpl(
true, testTextureStream01U32);
157 testImpl(
true, testTextureStream02RLE32);
162 testImpl(
true, testTextureStream03RLE32);
167 testTextureStream01U32 =
null;
168 testTextureStream02RLE32 =
null;
169 testTextureStream03RLE32 =
null;
172 public static void main(
final String args[])
throws IOException {
173 for(
int i=0; i<args.length; i++) {
174 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)
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.
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 TGA
Constant which can be used as a file suffix to indicate a Targa file, value {@value}.
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.
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.