JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestEventSourceNotAWTBug.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.test.junit.newt;
30
31import org.junit.BeforeClass;
32import org.junit.Test;
33import org.junit.FixMethodOrder;
34import org.junit.runners.MethodSorters;
35
36import java.io.IOException;
37import java.lang.reflect.InvocationTargetException;
38
39import com.jogamp.opengl.GLCapabilities;
40import com.jogamp.opengl.GLProfile;
41import javax.swing.JFrame;
42import javax.swing.SwingUtilities;
43import javax.swing.WindowConstants;
44
45import com.jogamp.newt.awt.NewtCanvasAWT;
46import com.jogamp.newt.opengl.GLWindow;
47import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
48import com.jogamp.opengl.test.junit.util.*;
49
50/**
51 * This simple program will throw a {@link RuntimeException} when the application is closed.
52 */
53@FixMethodOrder(MethodSorters.NAME_ASCENDING)
55
56 @BeforeClass
57 public static void initClass() {
58 }
59
60 @Test
61 public void testEventSourceNotNewtBug() throws InterruptedException, InvocationTargetException {
62 final JFrame jf = new JFrame();
63
64 jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
65
67 final GLWindow glWindow = GLWindow.create(caps);
68 final NewtCanvasAWT canvas = new NewtCanvasAWT(glWindow);
69 jf.getContentPane().add(canvas);
70
71 // The following line isn't event necessary to see the problem.
72 glWindow.addGLEventListener(new GearsES2());
73
74 final JFrame f_jf = jf;
75
76 SwingUtilities.invokeAndWait(new Runnable() {
77 public void run() {
78 f_jf.setSize(800, 600);
79 f_jf.setVisible(true);
80 }
81 });
82
83 Thread.sleep(500);
84
85 SwingUtilities.invokeAndWait(new Runnable() {
86 public void run() {
87 f_jf.dispose();
88 }
89 });
90 glWindow.destroy();
91 }
92
93 public static void main(final String args[]) throws IOException {
94 final String tstname = TestEventSourceNotAWTBug.class.getName();
95 /*
96 org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
97 tstname,
98 "filtertrace=true",
99 "haltOnError=false",
100 "haltOnFailure=false",
101 "showoutput=true",
102 "outputtoformatters=true",
103 "logfailedtests=true",
104 "logtestlistenerevents=true",
105 "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
106 "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); */
107 org.junit.runner.JUnitCore.main(tstname);
108 }
109}
AWT Canvas containing a NEWT Window using native parenting.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Definition: GLWindow.java:169
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
Definition: GLProfile.java:913
This simple program will throw a RuntimeException when the application is closed.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.