JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestGLContextDrawableSwitch11NewtAWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2013 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.jogl.acore.glels;
30
31import java.io.IOException;
32
33import com.jogamp.opengl.GLCapabilities;
34import com.jogamp.opengl.GLProfile;
35
36
37import com.jogamp.opengl.GLEventListenerState;
38import com.jogamp.opengl.util.Animator;
39
40import com.jogamp.opengl.test.junit.util.GLEventListenerCounter;
41
42import org.junit.Test;
43import org.junit.FixMethodOrder;
44import org.junit.runners.MethodSorters;
45
46/**
47 * Test re-association of GLContext/GLDrawables,
48 * here GLContext's survival of GLDrawable destruction
49 * and reuse w/ new or recreated GLDrawable.
50 * <p>
51 * Test utilizes {@link GLEventListenerState} for preserving the
52 * GLAutoDrawable state, i.e. GLContext, all GLEventListener
53 * and the GLAnimatorControl association.
54 * </p>
55 * <p>
56 * This test is using JOGL's NEWT GLWindow.
57 * </p>
58 * <p>
59 * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665.
60 * </p>
61 */
62@FixMethodOrder(MethodSorters.NAME_ASCENDING)
64
65 @Test(timeout=30000)
66 public void test21GLWindowGL2ES2() throws InterruptedException {
67 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
68 if(null == reqGLCaps) return;
69 testGLWindowImpl(reqGLCaps);
70 }
71
72 @Test(timeout=30000)
73 public void test22GLWindowGLES2() throws InterruptedException {
74 final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2);
75 if(null == reqGLCaps) return;
76 testGLWindowImpl(reqGLCaps);
77 }
78
79 private void testGLWindowImpl(final GLCapabilities caps) throws InterruptedException {
80 final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
81 final GLEventListenerCounter glelTracker = new GLEventListenerCounter();
82 final Animator animator = new Animator();
83 animator.start();
84
85 final GLEventListenerState glels[] = new GLEventListenerState[1];
86
87 // - create glad1 w/o context
88 // - create context using glad1 and assign it to glad1
89 {
90 testGLADOneLifecycle(null, caps, GLADType.GLWindow, width,
91 height, glelTracker,
92 snapshotGLEventListener,
93 null, glels, animator);
94 }
95
96 // - create glad2 w/ survived context
97 {
98 testGLADOneLifecycle(null, caps, GLADType.GLWindow, width+100,
99 height+100, glelTracker,
100 snapshotGLEventListener,
101 glels[0], null, null);
102 }
103 animator.stop();
104 }
105
106 public static void main(final String args[]) throws IOException {
107 for(int i=0; i<args.length; i++) {
108 if(args[i].equals("-time")) {
109 i++;
110 try {
111 duration = Integer.parseInt(args[i]);
112 } catch (final Exception ex) { ex.printStackTrace(); }
113 }
114 }
115 /**
116 BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
117 System.err.println("Press enter to continue");
118 System.err.println(stdin.readLine()); */
119 org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch11NewtAWT.class.getName());
120 }
121}
Specifies a set of OpenGL capabilities.
GLEventListenerState is holding GLAutoDrawable components crucial to relocating all its GLEventListen...
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static final String GL2ES2
The intersection of the desktop GL3, GL2 and embedded ES2 profile.
Definition: GLProfile.java:594
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition: GLProfile.java:585
Test re-association of GLContext/GLDrawables, here GLContext's survival of GLDrawable destruction and...
Test re-association of GLContext/GLDrawables, here GLContext's survival of GLDrawable destruction and...
final synchronized boolean start()
Starts this animator, if not running.
Definition: Animator.java:344
final synchronized boolean stop()
Stops this animator.
Definition: Animator.java:368