JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestTessellationShader01GL4NEWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2014 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 */
28package com.jogamp.opengl.test.junit.jogl.demos.gl4.newt;
29
30import java.io.IOException;
31
32import com.jogamp.opengl.GLCapabilities;
33import com.jogamp.opengl.GLEventListener;
34import com.jogamp.opengl.GLProfile;
35
36import org.junit.Assert;
37import org.junit.Test;
38import org.junit.FixMethodOrder;
39import org.junit.runners.MethodSorters;
40
41import com.jogamp.newt.opengl.GLWindow;
42import com.jogamp.opengl.test.junit.jogl.demos.gl4.TessellationShader01aGLSL440CoreHardcoded;
43import com.jogamp.opengl.test.junit.jogl.demos.gl4.TessellationShader01bGL4;
44import com.jogamp.opengl.test.junit.util.MiscUtils;
45import com.jogamp.opengl.test.junit.util.QuitAdapter;
46import com.jogamp.opengl.test.junit.util.UITestCase;
47import com.jogamp.opengl.util.Animator;
48
49/**
50 * Test Geometry shader demo TessellationShader01aGL4 and TessellationShader01bGL4
51 */
52@FixMethodOrder(MethodSorters.NAME_ASCENDING)
54 static long duration = 500; // ms
55
56 static GLCapabilities getCaps(final String profile) {
57 if( !GLProfile.isAvailable(profile) ) {
58 System.err.println("Profile "+profile+" n/a");
59 return null;
60 }
61 return new GLCapabilities(GLProfile.get(profile));
62 }
63
64 @Test
65 public void test01_01a() throws InterruptedException {
66 final GLCapabilities caps = getCaps(GLProfile.GL4);
67 if( null == caps ) { return; }
69 }
70
71 @Test
72 public void test02_01b() throws InterruptedException {
73 final GLCapabilities caps = getCaps(GLProfile.GL4);
74 if( null == caps ) { return; }
75 testImpl(caps, new TessellationShader01bGL4());
76 }
77
78 private void testImpl(final GLCapabilities caps, final GLEventListener glel) throws InterruptedException {
79 final GLWindow glWindow = GLWindow.create(caps);
80 Assert.assertNotNull(glWindow);
81 glWindow.setSize(800, 600);
82 glWindow.setVisible(true);
83 glWindow.setTitle("JOGL Tessellation Shader Test");
84 Assert.assertTrue(glWindow.isNativeValid());
85
86 final QuitAdapter quitAdapter = new QuitAdapter();
87 glWindow.addKeyListener(quitAdapter);
88 glWindow.addWindowListener(quitAdapter);
89 glWindow.addGLEventListener( glel );
90
91 final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
92 glWindow.addGLEventListener(snapshotGLEventListener);
93
94 final Animator animator = new Animator(glWindow);
95 animator.start();
96
97 animator.setUpdateFPSFrames(60, System.err);
98 snapshotGLEventListener.setMakeSnapshot();
99
100 while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
101 Thread.sleep(100);
102 }
103
104 animator.stop();
105 glWindow.destroy();
106 }
107
108 public static void main(final String args[]) throws IOException {
109 for(int i=0; i<args.length; i++) {
110 if(args[i].equals("-time")) {
111 i++;
112 duration = MiscUtils.atol(args[i], duration);
113 }
114 }
115 org.junit.runner.JUnitCore.main(TestTessellationShader01GL4NEWT.class.getName());
116 }
117}
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final void setTitle(final String title)
Definition: GLWindow.java:297
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
Definition: GLWindow.java:902
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 addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
Definition: GLWindow.java:882
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 GL4
The desktop OpenGL core profile 4.x, with x >= 0.
Definition: GLProfile.java:569
Test Geometry shader demo TessellationShader01aGL4 and TessellationShader01bGL4.
static long atol(final String str, final long def)
Definition: MiscUtils.java:66
final void setUpdateFPSFrames(final int frames, final PrintStream out)
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
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.