JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestImmModeSinkES1NEWT.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.jogl.util;
30
31import java.io.IOException;
32
33import com.jogamp.opengl.GLCapabilities;
34import com.jogamp.opengl.GLCapabilitiesImmutable;
35import com.jogamp.opengl.GLEventListener;
36import com.jogamp.opengl.GLProfile;
37
38import org.junit.Test;
39import org.junit.FixMethodOrder;
40import org.junit.runners.MethodSorters;
41
42import com.jogamp.newt.opengl.GLWindow;
43import com.jogamp.opengl.test.junit.util.MiscUtils;
44import com.jogamp.opengl.test.junit.util.UITestCase;
45
46/**
47 * Testing the ImmModeSink w/ GL2ES1 context
48 */
49@FixMethodOrder(MethodSorters.NAME_ASCENDING)
50public class TestImmModeSinkES1NEWT extends UITestCase {
51 static int duration = 100;
52 static final int iWidth = 400;
53 static final int iHeight = 400;
54
55 static GLCapabilities getCaps(final String profile) {
56 if( !GLProfile.isAvailable(profile) ) {
57 System.err.println("Profile "+profile+" n/a");
58 return null;
59 }
60 return new GLCapabilities(GLProfile.get(profile));
61 }
62
63 void doTest(final GLCapabilitiesImmutable reqGLCaps, final GLEventListener demo) throws InterruptedException {
64 System.out.println("Requested GL Caps: "+reqGLCaps);
65
66 //
67 // Create native windowing resources .. X11/Win/OSX
68 //
69 final GLWindow glad = GLWindow.create(reqGLCaps);
70 glad.addGLEventListener(demo);
71
72 final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
73 glad.addGLEventListener(snapshotGLEventListener);
74 glad.setSize(iWidth, iHeight);
75 glad.setVisible(true);
76
77 snapshotGLEventListener.setMakeSnapshot();
78 glad.display(); // initial resize/display
79
80 Thread.sleep(duration);
81
82 glad.destroy();
83 }
84
85 @Test
86 public void test01Plain__GL2ES1_VBOOffUsePlain() throws InterruptedException {
87 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
88 if(null == reqGLCaps) return;
89 doTest(reqGLCaps, new DemoGL2ES1Plain(false, false));
90 }
91
92 @Test
93 public void test02Plain__GL2ES1_VBOOffUseArrayData() throws InterruptedException {
94 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
95 if(null == reqGLCaps) return;
96 doTest(reqGLCaps, new DemoGL2ES1Plain(true, false));
97 }
98
99 @Test
100 public void test03Plain__GL2ES1_VBOOnUsePlain() throws InterruptedException {
101 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
102 if(null == reqGLCaps) return;
103 doTest(reqGLCaps, new DemoGL2ES1Plain(false, true));
104 }
105
106 @Test
107 public void test04Plain__GL2ES1_VBOOnUseArrayData() throws InterruptedException {
108 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
109 if(null == reqGLCaps) return;
110 doTest(reqGLCaps, new DemoGL2ES1Plain(true, true));
111 }
112
113 @Test
114 public void test05ImmSinkGL2ES1_VBOOff() throws InterruptedException {
115 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
116 if(null == reqGLCaps) return;
117 doTest(reqGLCaps, new DemoGL2ES1ImmModeSink(false));
118 }
119
120 @Test
121 public void test06ImmSinkGL2ES1_VBOOn() throws InterruptedException {
122 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
123 if(null == reqGLCaps) return;
124 doTest(reqGLCaps, new DemoGL2ES1ImmModeSink(true));
125 }
126
127 @Test
128 public void test07ImmSinkGL2ES1_VBOOnTexture() throws InterruptedException {
129 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES1);
130 if(null == reqGLCaps) return;
131 doTest(reqGLCaps, new DemoGL2ES1TextureImmModeSink());
132 }
133
134 public static void main(final String args[]) throws IOException {
135 for(int i=0; i<args.length; i++) {
136 if(args[i].equals("-time")) {
137 duration = MiscUtils.atoi(args[++i], duration);
138 }
139 }
140 org.junit.runner.JUnitCore.main(TestImmModeSinkES1NEWT.class.getName());
141 }
142
143}
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
Definition: GLWindow.java:625
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
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 boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
Definition: GLProfile.java:305
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2ES1
The intersection of the desktop GL2 and embedded ES1 profile.
Definition: GLProfile.java:591
static int atoi(final String str, final int def)
Definition: MiscUtils.java:57
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.