1package com.jogamp.opengl.test.bugs;
3import java.applet.Applet;
4import java.awt.BorderLayout;
7import java.awt.GraphicsDevice;
8import java.awt.GraphicsEnvironment;
10import java.awt.Rectangle;
11import java.awt.event.WindowAdapter;
12import java.awt.event.WindowEvent;
14import com.jogamp.opengl.GLAutoDrawable;
15import com.jogamp.opengl.GLCapabilities;
16import com.jogamp.opengl.GLEventListener;
17import com.jogamp.opengl.GLProfile;
18import com.jogamp.opengl.awt.GLCanvas;
19import javax.swing.SwingUtilities;
21import com.jogamp.newt.awt.NewtCanvasAWT;
22import com.jogamp.newt.opengl.GLWindow;
23import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2;
24import com.jogamp.opengl.test.junit.util.MiscUtils;
25import com.jogamp.opengl.test.junit.util.UITestCase;
26import com.jogamp.opengl.util.Animator;
27import com.jogamp.opengl.util.AnimatorBase;
47@SuppressWarnings(
"serial")
49 static public final int AWT = 0;
50 static public final int NEWT = 1;
52 static public final int APPLET_WIDTH = 500;
53 static public final int APPLET_HEIGHT = 290;
54 static public final int TOOLKIT = NEWT;
55 static public final boolean IGNORE_AWT_REPAINT =
false;
56 static public boolean USE_ECT =
false;
57 static public int SWAP_INTERVAL = 1;
61 static boolean waitForKey =
false;
62 static private Frame frame;
75 setSize(APPLET_WIDTH, APPLET_HEIGHT);
78 height = APPLET_HEIGHT;
88 private void initGL() {
98 awtCanvas.setBackground(
new Color(0xFFCCCCCC,
true));
99 awtCanvas.setFocusable(
true);
101 applet.setLayout(
new BorderLayout());
102 applet.add(awtCanvas, BorderLayout.CENTER);
104 if (IGNORE_AWT_REPAINT) {
105 awtCanvas.setIgnoreRepaint(
true);
108 }
else if (TOOLKIT == NEWT) {
109 newtWindow = GLWindow.
create(caps);
110 newtCanvas =
new NewtCanvasAWT(newtWindow);
112 newtCanvas.setBackground(
new Color(0xFFCCCCCC,
true));
113 newtCanvas.setFocusable(
true);
115 applet.setLayout(
new BorderLayout());
116 applet.add(newtCanvas, BorderLayout.CENTER);
118 if (IGNORE_AWT_REPAINT) {
119 newtCanvas.setIgnoreRepaint(
true);
124 demo =
new LandscapeES2(SWAP_INTERVAL);
127 animator =
new Animator(glad);
131 private void initDraw() {
132 if (TOOLKIT == AWT) {
136 awtCanvas.requestFocus();
138 }
else if (TOOLKIT == NEWT) {
144 newtCanvas.requestFocus();
149 static public void main(
final String[] args) {
150 for(
int i=0; i<args.length; i++) {
151 if(args[i].equals(
"-vsync")) {
154 }
else if(args[i].equals(
"-exclctx")) {
156 }
else if(args[i].equals(
"-wait")) {
160 System.err.println(
"swapInterval "+SWAP_INTERVAL);
161 System.err.println(
"exclusiveContext "+USE_ECT);
166 final GraphicsEnvironment environment =
167 GraphicsEnvironment.getLocalGraphicsEnvironment();
168 final GraphicsDevice displayDevice = environment.getDefaultScreenDevice();
170 frame =
new Frame(displayDevice.getDefaultConfiguration());
171 frame.setBackground(
new Color(0xCC, 0xCC, 0xCC));
172 frame.setTitle(
"TestBug735Inv3AppletAWT");
175 frame.addWindowListener(
new WindowAdapter() {
176 public void windowClosing(
final WindowEvent e) {
182 final Class<?> c = Thread.currentThread().getContextClassLoader().
185 }
catch (
final Exception e) {
186 throw new RuntimeException(e);
194 final Insets insets = frame.getInsets();
195 final int windowW = applet.width + insets.left + insets.right;
196 final int windowH = applet.height + insets.top + insets.bottom;
199 SwingUtilities.invokeAndWait(
new Runnable() {
201 frame.setSize(windowW, windowH);
204 final Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds();
205 frame.setLocation(screenRect.x + (screenRect.width - applet.width) / 2,
206 screenRect.y + (screenRect.height - applet.height) / 2);
208 frame.setResizable(
false);
209 frame.setVisible(
true);
212 }
catch (
final Exception e) {
void setBackgroundOpaque(final boolean opaque)
Sets whether the surface shall be opaque or translucent.
void setOnscreen(final boolean onscreen)
Sets whether the surface shall be on- or offscreen.
AWT Canvas containing a NEWT Window using native parenting.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
void setSampleBuffers(final boolean enable)
Defaults to false.
Specifies the the OpenGL profile.
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
A heavyweight AWT component which provides OpenGL rendering support.
final GLDrawable getDelegatedDrawable()
If the implementation uses delegation, return the delegated GLDrawable instance, otherwise return thi...
static void main(final String[] args)
static int atoi(final String str, final int def)
Base implementation of GLAnimatorControl
final synchronized Thread setExclusiveContext(final Thread t)
Dedicate all GLAutoDrawable's context to the given exclusive context thread.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
boolean start()
Starts this animator, if not running.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
boolean isRealized()
Returns true if this drawable is realized, otherwise false.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.