29package com.jogamp.opengl.test.junit.jogl.awt;
31import java.awt.Container;
32import java.awt.event.WindowAdapter;
33import java.awt.event.WindowEvent;
35import java.awt.image.BufferedImage;
36import java.lang.reflect.InvocationTargetException;
38import com.jogamp.opengl.GL;
39import com.jogamp.opengl.GL2;
40import com.jogamp.opengl.GLAutoDrawable;
41import com.jogamp.opengl.GLCapabilities;
42import com.jogamp.opengl.GLDrawableFactory;
43import com.jogamp.opengl.GLEventListener;
44import com.jogamp.opengl.GLOffscreenAutoDrawable;
45import com.jogamp.opengl.GLProfile;
46import javax.swing.ImageIcon;
47import javax.swing.JFrame;
48import javax.swing.JLabel;
50import org.junit.Assert;
52import org.junit.FixMethodOrder;
53import org.junit.runners.MethodSorters;
55import com.jogamp.opengl.test.junit.util.MiscUtils;
56import com.jogamp.opengl.test.junit.util.UITestCase;
57import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
65@FixMethodOrder(MethodSorters.NAME_ASCENDING)
67 static long durationPerTest = 500;
74 Assert.assertNotNull(gl);
94 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {
99 render(offScreenBuffer);
101 Assert.assertNotNull(outputImage);
102 final ImageIcon imageIcon =
new ImageIcon(outputImage);
103 final JLabel imageLabel =
new JLabel(imageIcon);
105 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
107 final Container cont = jframe.getContentPane();
109 cont.add(imageLabel);
112 }
catch (
final Exception e) {
121 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
123 jframe.setVisible(
false);
126 }
catch (
final Exception e) {
133 jframe =
new JFrame(
"Offscreen Supersampling");
134 Assert.assertNotNull(jframe);
135 jframe.addWindowListener(
new WindowAdapter() {
136 public void windowClosing(
final WindowEvent e) {
142 Assert.assertNotNull(glp);
145 Assert.assertNotNull(fac);
148 Assert.assertNotNull(glCap);
163 Assert.assertNotNull(offScreenBuffer);
165 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
167 jframe.setSize( 300, 300);
168 jframe.setVisible(
true);
173 Thread.sleep(durationPerTest);
178 public static void main(
final String args[]) {
179 for(
int i=0; i<args.length; i++) {
180 if(args[i].equals(
"-time")) {
181 durationPerTest =
MiscUtils.
atol(args[++i], durationPerTest);
Specifies a set of OpenGL capabilities.
void setStencilBits(final int stencilBits)
Sets the number of bits requested for the stencil buffer.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
void setSampleBuffers(final boolean enable)
Defaults to false.
abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, int width, int height)
Creates a realized GLOffscreenAutoDrawable incl it's offscreen NativeSurface with the given capabilit...
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
Specifies the the OpenGL profile.
static AbstractGraphicsDevice getDefaultDevice()
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Tests for bug 461, a failure of GLDrawableFactory.createOffscreenAutoDrawable(..) on Windows when the...
void testOffscreenSupersampling()
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
static void main(final String args[])
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Called by the drawable during the first repaint after the component has been resized.
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
static long atol(final String str, final long def)
void dispose(final GL gl)
GLReadBufferUtil specialization allowing to read out a frambuffer to an AWT BufferedImage utilizing A...
BufferedImage readPixelsToBufferedImage(final GL gl, final boolean awtOrientation)
Read the drawable's pixels to TextureData and Texture, if requested at construction,...
void glVertex2d(double x, double y)
Entry point to C language function: void {@native glVertex2d}(GLdouble x, GLdouble y) Part of GL_V...
void glBegin(int mode)
Entry point to C language function: void {@native glBegin}(GLenum mode) Part of GL_VERSION_1_0
void glEnd()
Entry point to C language function: void {@native glEnd}() Part of GL_VERSION_1_0
void glColor3f(float red, float green, float blue)
Entry point to C language function: void {@native glColor3f}(GLfloat red, GLfloat green,...
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.
void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
GL2 getGL2()
Casts this object to the GL2 interface.
GLProfile getGLProfile()
Fetches the GLProfile for this drawable.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
Platform-independent GLAutoDrawable specialization, exposing offscreen functionality.
static final int GL_TRIANGLES
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRIANGLES" with expre...
static final int GL_COLOR_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_COLOR_BUFFER_BIT" wit...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...