JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestGLPointsNEWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2011 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;
30
31import com.jogamp.newt.opengl.GLWindow;
32import com.jogamp.opengl.test.junit.util.UITestCase;
33
34import com.jogamp.opengl.test.junit.jogl.demos.PointsDemo;
35import com.jogamp.opengl.test.junit.jogl.demos.es1.PointsDemoES1;
36import com.jogamp.opengl.test.junit.jogl.demos.es2.PointsDemoES2;
37
38import com.jogamp.opengl.GLCapabilities;
39import com.jogamp.opengl.GLProfile;
40
41import org.junit.Assert;
42import org.junit.BeforeClass;
43import org.junit.AfterClass;
44import org.junit.Test;
45import org.junit.FixMethodOrder;
46import org.junit.runners.MethodSorters;
47
48@FixMethodOrder(MethodSorters.NAME_ASCENDING)
49public class TestGLPointsNEWT extends UITestCase {
50 static int width, height;
51
52 @BeforeClass
53 public static void initClass() {
54 width = 512;
55 height = 512;
56 }
57
58 @AfterClass
59 public static void releaseClass() {
60 }
61
62 protected void runTestGL0(final GLCapabilities caps, final PointsDemo demo) throws InterruptedException {
63 final GLWindow glWindow = GLWindow.create(caps);
64 Assert.assertNotNull(glWindow);
65 glWindow.setTitle(getSimpleTestName("."));
66
67 glWindow.addGLEventListener(demo);
69 snap.setPostSNDetail(demo.getClass().getSimpleName());
70 glWindow.addGLEventListener(snap);
71
72 glWindow.setSize(width, height);
73 glWindow.setVisible(true);
74
75 demo.setSmoothPoints(false);
76 snap.setMakeSnapshot();
77 snap.setPostSNDetail("flat");
78 glWindow.display();
79
80 demo.setSmoothPoints(true);
81 snap.setMakeSnapshot();
82 snap.setPostSNDetail("smooth");
83 glWindow.display();
84
85 demo.setPointParams(2f, 40f, 0.01f, 0.0f, 0.01f, 1f);
86 snap.setMakeSnapshot();
87 snap.setPostSNDetail("attn0");
88 glWindow.display();
89
90 glWindow.removeGLEventListener(demo);
91
92 glWindow.destroy();
93 }
94
95 protected void runTestGL(final GLCapabilities caps, final PointsDemo demo, final boolean forceFFPEmu) throws InterruptedException {
96 // final PointsDemoES2 demo01 = new PointsDemoES2();
97 runTestGL0(caps, demo);
98 }
99
100 @Test
101 public void test01FFP__GL2() throws InterruptedException {
102 if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
104 runTestGL(caps, new PointsDemoES1(), false);
105 }
106
107 @Test
108 public void test02FFP__ES1() throws InterruptedException {
109 if(!GLProfile.isAvailable(GLProfile.GLES1)) { System.err.println("GLES1 n/a"); return; }
111 runTestGL(caps, new PointsDemoES1(), false);
112 }
113
114 @Test
115 public void test03FFP__ES2() throws InterruptedException {
116 if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
118 final PointsDemoES1 demo = new PointsDemoES1();
119 demo.setForceFFPEmu(true, false, false, false);
120 runTestGL(caps, demo, false);
121 }
122
123 @Test
124 public void test04FFP__GL2ES2() throws InterruptedException {
125 if(!GLProfile.isAvailable(GLProfile.GL2ES2)) { System.err.println("GL2ES2 n/a"); return; }
127 final PointsDemoES1 demo = new PointsDemoES1();
128 demo.setForceFFPEmu(true, false, false, false);
129 runTestGL(caps, demo, false);
130 }
131
132 @Test
133 public void test11GLSL_GL2() throws InterruptedException {
134 if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; }
136 runTestGL(caps, new PointsDemoES2(), false);
137 }
138
139 @Test
140 public void test12GLSL_ES2() throws InterruptedException {
141 if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; }
143 runTestGL(caps, new PointsDemoES2(), false); // should be FFPEmu implicit
144 }
145
146 static long duration = 1000; // ms
147
148 public static void main(final String args[]) {
149 for(int i=0; i<args.length; i++) {
150 if(args[i].equals("-time")) {
151 i++;
152 try {
153 duration = Integer.parseInt(args[i]);
154 } catch (final Exception ex) { ex.printStackTrace(); }
155 }
156 }
157 org.junit.runner.JUnitCore.main(TestGLPointsNEWT.class.getName());
158 }
159}
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 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 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
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition: GLProfile.java:579
static final String GLES1
The embedded OpenGL profile ES 1.x, with x >= 0.
Definition: GLProfile.java:582
void runTestGL(final GLCapabilities caps, final PointsDemo demo, final boolean forceFFPEmu)
void runTestGL0(final GLCapabilities caps, final PointsDemo demo)
void setForceFFPEmu(final boolean forceFFPEmu, final boolean verboseFFPEmu, final boolean debugFFPEmu, final boolean traceFFPEmu)
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GLEventListener removeGLEventListener(GLEventListener listener)
Removes the given listener from this drawable queue.