1package com.jogamp.opengl.test.junit.jogl.awt;
3import java.awt.BorderLayout;
5import java.awt.Component;
6import java.awt.Container;
7import java.awt.Dimension;
8import java.awt.GraphicsConfiguration;
9import java.awt.Rectangle;
11import java.io.IOException;
13import com.jogamp.opengl.GLAnimatorControl;
14import com.jogamp.opengl.GLAutoDrawable;
15import com.jogamp.opengl.GLCapabilities;
16import com.jogamp.opengl.GLProfile;
17import com.jogamp.opengl.awt.GLCanvas;
18import com.jogamp.opengl.awt.GLJPanel;
19import javax.swing.JFrame;
20import javax.swing.JPanel;
21import javax.swing.JScrollPane;
22import javax.swing.JSplitPane;
23import javax.swing.WindowConstants;
25import org.junit.Assert;
26import org.junit.Assume;
28import org.junit.FixMethodOrder;
29import org.junit.runners.MethodSorters;
31import com.jogamp.common.util.ReflectionUtil;
32import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
33import com.jogamp.opengl.test.junit.util.MiscUtils;
34import com.jogamp.opengl.test.junit.util.UITestCase;
35import com.jogamp.opengl.util.Animator;
36import com.jogamp.opengl.util.FPSAnimator;
47@FixMethodOrder(MethodSorters.NAME_ASCENDING)
49 static long durationPerTest = 500;
59 @SuppressWarnings(
"serial")
68 ReflectionUtil.callStaticMethod(
69 "com.sun.awt.AWTUtilities",
"setComponentMixingCutoutShape",
70 new Class<?>[] { Component.class, Shape.class },
71 new Object[] {
this,
new Rectangle() } ,
72 GraphicsConfiguration.class.getClassLoader());
73 System.err.println(
"com.sun.awt.AWTUtilities.setComponentMixingCutoutShape(..) passed");
74 }
catch (
final RuntimeException re) {
75 System.err.println(
"com.sun.awt.AWTUtilities.setComponentMixingCutoutShape(..) failed: "+re.getMessage());
84 protected void runTestGL(
final GLCapabilities caps,
final boolean useGLJPanel,
final boolean useContainer)
throws InterruptedException {
85 final String typeS = useGLJPanel ?
"LW" :
"HW";
86 final JFrame frame =
new JFrame(
"Mix Hw/Lw Swing - Canvas "+typeS);
87 Assert.assertNotNull(frame);
89 final Dimension f_sz =
new Dimension(824,568);
93 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
95 final Component glComp;
99 Assert.assertNotNull(glJPanel);
105 Assert.assertNotNull(glCanvas);
108 final Container cont =
new Container();
109 cont.setLayout(
new BorderLayout());
110 cont.add(glCanvas, BorderLayout.CENTER);
118 final Container contentPane = frame.getContentPane();
120 final JSplitPane splitPane =
new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
121 splitPane.setResizeWeight(0.5d);
122 splitPane.setLeftComponent(glComp);
125 splitPane.setRightComponent(
new JPanel());
126 contentPane.add(splitPane, BorderLayout.CENTER);
132 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
134 frame.setPreferredSize(f_sz);
135 frame.setSize(f_sz.width+1, f_sz.height+1);
137 frame.setVisible(
true);
140 }
catch (
final Throwable t) {
142 Assume.assumeNoException(t);
146 Thread.sleep(durationPerTest);
151 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
153 frame.setVisible(
false);
156 }
catch (
final Throwable t) {
158 Assume.assumeNoException(t);
166 runTestGL(caps,
false,
false);
173 runTestGL(caps,
false,
true);
180 runTestGL(caps,
true,
false);
183 public static void main(
final String args[])
throws IOException {
184 for(
int i=0; i<args.length; i++) {
185 if(args[i].equals(
"-time")) {
186 durationPerTest =
MiscUtils.
atol(args[++i], durationPerTest);
194 System.out.println(
"durationPerTest: "+durationPerTest);
196 org.junit.runner.JUnitCore.
main(tstname);
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 heavyweight AWT component which provides OpenGL rendering support.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
A lightweight Swing component which provides OpenGL rendering support.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Documenting Bug 642 (related to Bug 586)
void test01JSplitPaneWithHwGLCanvasPlain()
static void main(final String args[])
void test02JSplitPaneWithHwGLCanvasContainer()
void runTestGL(final GLCapabilities caps, final boolean useGLJPanel, final boolean useContainer)
void test03JSplitPaneWithLwGLJPanel()
static long atol(final String str, final long def)
An Animator subclass which attempts to achieve a target frames-per-second rate to avoid using all CPU...
void setUpdateFPSFrames(int frames, PrintStream out)
An animator control interface, which implementation may drive a com.jogamp.opengl....
boolean start()
Starts this animator, if not running.
boolean stop()
Stops this animator.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...