JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestImmModeSinkES2NEWT.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 TestImmModeSinkES2NEWT 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 test05ImmSinkGL2ES2_VBOOff_Direct() throws InterruptedException {
87 final GLCapabilities reqGLCaps = new GLCapabilities( GLProfile.getMaxFixedFunc(true) );
88 doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(false, false));
89 }
90
91 @Test
92 public void test05ImmSinkGL2ES2_VBOOff_ShaderState() throws InterruptedException {
93 final GLCapabilities reqGLCaps = new GLCapabilities( GLProfile.getMaxFixedFunc(true) );
94 doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(false, true));
95 }
96
97 @Test
98 public void test06ImmSinkGL2ES2_VBOOn_Direct() throws InterruptedException {
99 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
100 if(null == reqGLCaps) return;
101 doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(true, false));
102 }
103
104 @Test
105 public void test06ImmSinkGL2ES2_VBOOn_ShaderState() throws InterruptedException {
106 final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2);
107 if(null == reqGLCaps) return;
108 doTest(reqGLCaps, new DemoGL2ES2ImmModeSink(true, true));
109 }
110
111 public static void main(final String args[]) throws IOException {
112 for(int i=0; i<args.length; i++) {
113 if(args[i].equals("-time")) {
114 duration = MiscUtils.atoi(args[++i], duration);
115 }
116 }
117 org.junit.runner.JUnitCore.main(TestImmModeSinkES2NEWT.class.getName());
118 }
119
120}
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 getMaxFixedFunc(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
Returns the highest profile, implementing the fixed function pipeline.
Definition: GLProfile.java:808
static final String GL2ES2
The intersection of the desktop GL3, GL2 and embedded ES2 profile.
Definition: GLProfile.java:594
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
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.