29package com.jogamp.opengl.test.junit.jogl.awt;
31import java.awt.event.WindowAdapter;
32import java.awt.event.WindowEvent;
33import java.awt.image.BufferedImage;
34import java.lang.reflect.InvocationTargetException;
36import com.jogamp.opengl.GL;
37import com.jogamp.opengl.GL2;
38import com.jogamp.opengl.GLAutoDrawable;
39import com.jogamp.opengl.GLCapabilities;
40import com.jogamp.opengl.GLDrawableFactory;
41import com.jogamp.opengl.GLEventListener;
42import com.jogamp.opengl.GLOffscreenAutoDrawable;
43import com.jogamp.opengl.GLProfile;
44import javax.swing.ImageIcon;
45import javax.swing.JFrame;
46import javax.swing.JLabel;
48import org.junit.Assert;
50import org.junit.FixMethodOrder;
51import org.junit.runners.MethodSorters;
53import com.jogamp.opengl.test.junit.util.UITestCase;
54import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
62@FixMethodOrder(MethodSorters.NAME_ASCENDING)
70 Assert.assertNotNull(gl);
90 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {
95 render(offScreenBuffer);
97 Assert.assertNotNull(outputImage);
98 final ImageIcon imageIcon =
new ImageIcon(outputImage);
99 final JLabel imageLabel =
new JLabel(imageIcon);
100 jframe.getContentPane().add(imageLabel);
107 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
109 jframe.setVisible(
false);
112 }
catch (
final Exception e) {
120 Assert.assertNotNull(glp);
128 Assert.assertNotNull(glp);
134 void test(
final GLCapabilities glCap)
throws InterruptedException, InvocationTargetException {
135 jframe =
new JFrame(
"Offscreen Supersampling");
136 Assert.assertNotNull(jframe);
137 jframe.setSize( 300, 300);
138 jframe.addWindowListener(
new WindowAdapter() {
139 public void windowClosing(
final WindowEvent e) {
145 Assert.assertNotNull(fac);
149 glCap.setSampleBuffers(
true);
150 glCap.setNumSamples(4);
153 glCap.setDoubleBuffered(
false);
155 glCap.setStencilBits(1);
159 Assert.assertNotNull(offScreenBuffer);
162 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
164 jframe.setVisible(
true);
169 public static void main(
final String args[]) {
Specifies a set of OpenGL capabilities.
void setPBuffer(final boolean enable)
Requesting offscreen pbuffer mode.
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 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 PBuffer GLDrawableFactory.createOffscreenAutoDrawable(....
void test01DefaultOffscreenSupersampling()
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 dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void test02PBufferOffscreenSupersampling()
static void main(final String args[])
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
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_...