28 package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt;
30import com.jogamp.opengl.*;
32import com.jogamp.opengl.util.FPSAnimator;
33import com.jogamp.opengl.util.GLReadBufferUtil;
34import com.jogamp.opengl.util.texture.TextureIO;
36import com.jogamp.opengl.awt.GLJPanel;
37import com.jogamp.opengl.glu.gl2.GLUgl2;
39import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
40import com.jogamp.opengl.test.junit.util.UITestCase;
42import java.awt.AWTException;
43import java.awt.BorderLayout;
44import java.lang.reflect.InvocationTargetException;
45import java.nio.ByteBuffer;
47import javax.swing.JFrame;
48import javax.swing.SwingUtilities;
50import org.junit.Assert;
51import org.junit.BeforeClass;
52import org.junit.AfterClass;
54import org.junit.FixMethodOrder;
55import org.junit.runners.MethodSorters;
67@FixMethodOrder(MethodSorters.NAME_ASCENDING)
70 static int width, height;
74 static boolean failed;
79 Assert.assertNotNull(glp);
91 throws AWTException, InterruptedException, InvocationTargetException
94 final JFrame frame =
new JFrame(
"Swing GLJPanel");
95 Assert.assertNotNull(frame);
98 Assert.assertNotNull(glJPanel);
100 demo.
setAspect((
float)width/(
float)height);
114 final ByteBuffer bytebuffer = ByteBuffer.allocateDirect( 3 );
116 final byte byte0 = bytebuffer.get( 0 );
117 final byte byte1 = bytebuffer.get( 1 );
118 final byte byte2 = bytebuffer.get( 2 );
119 if( (byte0 == 0) && (byte1 == 0) && (byte2 == 0) ) {
123 System.err.println(
"BGR ("+r_x+
"/"+r_y+
"): "+byte0+
", "+byte1+
", "+byte2+
" - OK "+(!failed));
131 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
136 SwingUtilities.invokeAndWait(
new Runnable() {
138 frame.getContentPane().add(glJPanel, BorderLayout.CENTER);
139 frame.setSize(width, height);
140 frame.setVisible(
true);
145 Assert.assertEquals(
true, animator.isAnimating());
151 Assert.assertNotNull(frame);
152 Assert.assertNotNull(glJPanel);
153 Assert.assertNotNull(animator);
156 Assert.assertEquals(
false, animator.isAnimating());
157 SwingUtilities.invokeAndWait(
new Runnable() {
159 frame.setVisible(
false);
160 frame.getContentPane().remove(glJPanel);
161 frame.remove(glJPanel);
166 Assert.assertFalse( failed );
171 throws AWTException, InterruptedException, InvocationTargetException
177 static long duration = 500;
179 public static void main(
final String args[]) {
180 for(
int i=0; i<args.length; i++) {
181 if(args[i].equals(
"-time")) {
184 duration = Integer.parseInt(args[i]);
185 }
catch (
final Exception ex) { ex.printStackTrace(); }
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
A lightweight Swing component which provides OpenGL rendering support.
void destroy()
Just an alias for removeNotify.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
static final GL2 getCurrentGL2()
void setDoRotation(final boolean rotate)
void setAspect(final float aspect)
Test for bug 450, which causes the right part of the frame to be black for all x >= height.
static void releaseClass()
static void main(final String args[])
void runTestGL(final GLCapabilities caps)
final long getTotalFPSDuration()
final void setUpdateFPSFrames(final int frames, final PrintStream out)
An Animator subclass which attempts to achieve a target frames-per-second rate to avoid using all CPU...
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this FPSAnimator.
Utility to read out the current FB to TextureData, optionally writing the data back to a texture obje...
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) ...
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void glReadPixels(int x, int y, int width, int height, int format, int type, Buffer pixels)
Entry point to C language function: void {@native glReadPixels}(GLint x, GLint y,...
static final int GL_BGR
GL_VERSION_1_2, GL_EXT_bgra Alias for: GL_BGR_EXT Define "GL_BGR" with expression '0x80E0',...
static final int GL_UNSIGNED_BYTE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_BYTE" with e...