28package com.jogamp.opengl.test.junit.jogl.demos.gl4.awt;
30import java.awt.AWTException;
31import java.awt.BorderLayout;
32import java.awt.Dimension;
33import java.lang.reflect.InvocationTargetException;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLCapabilitiesImmutable;
37import com.jogamp.opengl.GLProfile;
38import com.jogamp.opengl.awt.GLJPanel;
39import javax.swing.JFrame;
40import javax.swing.SwingUtilities;
42import org.junit.AfterClass;
43import org.junit.Assert;
44import org.junit.BeforeClass;
45import org.junit.FixMethodOrder;
47import org.junit.runners.MethodSorters;
49import com.jogamp.newt.event.KeyEvent;
50import com.jogamp.newt.event.TraceKeyAdapter;
51import com.jogamp.newt.event.TraceWindowAdapter;
52import com.jogamp.newt.event.awt.AWTKeyAdapter;
53import com.jogamp.newt.event.awt.AWTWindowAdapter;
54import com.jogamp.opengl.test.junit.jogl.demos.gl4.TriangleInstancedRendererWithShaderState;
55import com.jogamp.opengl.test.junit.util.MiscUtils;
56import com.jogamp.opengl.test.junit.util.QuitAdapter;
57import com.jogamp.opengl.test.junit.util.UITestCase;
58import com.jogamp.opengl.util.FPSAnimator;
63@FixMethodOrder(MethodSorters.NAME_ASCENDING)
66 static int width, height;
67 static boolean shallUsePBuffer =
false;
68 static boolean shallUseBitmap =
false;
69 static boolean useMSAA =
false;
70 static int swapInterval = 0;
71 static boolean useAnimator =
true;
72 static boolean manualTest =
false;
78 Assert.assertNotNull(glp);
82 setTestSupported(
false);
91 throws AWTException, InterruptedException, InvocationTargetException
93 final JFrame frame =
new JFrame(
"Swing GLJPanel");
94 Assert.assertNotNull(frame);
96 Assert.assertNotNull(glJPanel);
97 final Dimension glc_sz =
new Dimension(width, height);
98 glJPanel.setMinimumSize(glc_sz);
99 glJPanel.setPreferredSize(glc_sz);
105 SwingUtilities.invokeAndWait(
new Runnable() {
108 frame.getContentPane().add(glJPanel, BorderLayout.CENTER);
109 frame.getContentPane().validate();
111 frame.setVisible(
true);
116 Assert.assertEquals(
true, animator.isAnimating());
123 public void keyPressed(
final KeyEvent e) {
141 System.err.println(
"[set MSAA "+msaa+
" Caps had]: "+capsPre);
142 System.err.println(
"[set MSAA "+msaa+
" Caps new]: "+capsNew);
143 System.err.println(
"XXX-A1: "+animator.
toString());
145 System.err.println(
"XXX-A2: "+animator.
toString());
146 System.err.println(
"XXX: "+glJPanel.
toString());
161 System.err.println(
"[set Bitmap "+bmp+
" Caps had]: "+capsPre);
162 System.err.println(
"[set Bitmap "+bmp+
" Caps new]: "+capsNew);
163 System.err.println(
"XXX-A1: "+animator.
toString());
165 System.err.println(
"XXX-A2: "+animator.
toString());
166 System.err.println(
"XXX: "+glJPanel.
toString());
170 final long t0 = System.currentTimeMillis();
172 boolean triggerSnap =
false;
173 while(!quitAdapter.shouldQuit() && t1 - t0 < duration) {
175 t1 = System.currentTimeMillis();
183 Assert.assertNotNull(frame);
184 Assert.assertNotNull(glJPanel);
185 Assert.assertNotNull(animator);
188 Assert.assertEquals(
false, animator.isAnimating());
190 SwingUtilities.invokeAndWait(
new Runnable() {
193 frame.setVisible(
false);
194 frame.getContentPane().remove(glJPanel);
195 frame.remove(glJPanel);
203 throws AWTException, InterruptedException, InvocationTargetException
214 static long duration = 500;
216 public static void main(
final String args[]) {
217 for(
int i=0; i<args.length; i++) {
218 if(args[i].equals(
"-time")) {
221 }
else if(args[i].equals(
"-vsync")) {
224 }
else if(args[i].equals(
"-msaa")) {
226 }
else if(args[i].equals(
"-noanim")) {
228 }
else if(args[i].equals(
"-pbuffer")) {
229 shallUsePBuffer =
true;
230 }
else if(args[i].equals(
"-bitmap")) {
231 shallUseBitmap =
true;
232 }
else if(args[i].equals(
"-manual")) {
236 System.err.println(
"swapInterval "+swapInterval);
237 System.err.println(
"useMSAA "+useMSAA);
238 System.err.println(
"useAnimator "+useAnimator);
239 System.err.println(
"shallUsePBuffer "+shallUsePBuffer);
240 System.err.println(
"shallUseBitmap "+shallUseBitmap);
241 System.err.println(
"manualTest "+manualTest);
void setBitmap(final boolean enable)
Requesting offscreen bitmap mode.
final char getKeyChar()
Returns the UTF-16 character reflecting the key symbol incl.
AWT: printable: PRESSED (t0), TYPED (t0), RELEASED (t1) non-printable: PRESSED (t0),...
synchronized AWTAdapter addTo(final java.awt.Component awtComponent)
Due to the fact that some NEWT com.jogamp.newt.event.NEWTEventListener are mapped to more than one ja...
synchronized AWTAdapter addTo(final java.awt.Component awtComponent)
Due to the fact that some NEWT com.jogamp.newt.event.NEWTEventListener are mapped to more than one ja...
Specifies a set of OpenGL capabilities.
void setPBuffer(final boolean enable)
Requesting offscreen pbuffer mode.
void setDoubleBuffered(final boolean enable)
Enables or disables double buffering.
void setFBO(final boolean enable)
Requesting offscreen FBO mode.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
GLCapabilities copyFrom(final CapabilitiesImmutable source)
Copies all CapabilitiesImmutable values from source into this instance.
void setSampleBuffers(final boolean enable)
Defaults to false.
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 get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL4
The desktop OpenGL core profile 4.x, with x >= 0.
A lightweight Swing component which provides OpenGL rendering support.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
void destroy()
Just an alias for removeNotify.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Test Instanced rendering demo TrianglesInstancedRenderer.
void runTestGL(final GLCapabilities caps)
void test01_DefaultMsaa()
static void main(final String args[])
static void releaseClass()
static int atoi(final String str, final int def)
static long atol(final String str, final long def)
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.
boolean isBitmap()
Returns whether bitmap offscreen mode is requested, available or chosen.
Specifies an immutable set of OpenGL capabilities.
boolean getSampleBuffers()
Returns whether sample buffers for full-scene antialiasing (FSAA) should be allocated for this drawab...
GLProfile getGLProfile()
Returns the GL profile you desire or used by the drawable.
void setSize(int width, int height)
Requests a new width and height for this AWTGLAutoDrawable.