JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestIdentOfCapabilitiesNEWT.java
Go to the documentation of this file.
1/**
2 * Copyright 2023 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.caps;
30
31import com.jogamp.opengl.GLCapabilitiesImmutable;
32import com.jogamp.opengl.GLDrawableFactory;
33import com.jogamp.opengl.GLException;
34import com.jogamp.opengl.JoglVersion;
35
36import org.junit.Test;
37
38import java.util.ArrayList;
39import java.util.List;
40
41import org.junit.Assert;
42import org.junit.FixMethodOrder;
43import org.junit.runners.MethodSorters;
44
45import com.jogamp.junit.util.SingletonJunitCase;
46import com.jogamp.nativewindow.AbstractGraphicsDevice;
47
48@FixMethodOrder(MethodSorters.NAME_ASCENDING)
49public class TestIdentOfCapabilitiesNEWT extends SingletonJunitCase {
50
51 public static void main(final String[] args) {
52 final String tstname = TestIdentOfCapabilitiesNEWT.class.getName();
53 org.junit.runner.JUnitCore.main(tstname);
54 }
55
56 @Test
57 public void test01DesktopCapsEquals() throws InterruptedException {
58 final GLDrawableFactory factory = GLDrawableFactory.getFactory(false);
59 if( null == factory ) {
60 System.err.println("No desktop factory available, bailing out");
61 return;
62 }
63 testEquals(factory);
64 }
65 @Test
66 public void test02EGLCapsEquals() throws InterruptedException {
68 if( null == factory ) {
69 System.err.println("No EGL factory available, bailing out");
70 return;
71 }
72 testEquals(factory);
73 }
74
75 private static List<GLCapabilitiesImmutable> getEquals(final GLCapabilitiesImmutable caps, final List<GLCapabilitiesImmutable> availCaps) {
76 final List<GLCapabilitiesImmutable> res = new ArrayList<GLCapabilitiesImmutable>();
77 for(final GLCapabilitiesImmutable c : availCaps) {
78 if( c.equals(caps) ) {
79 res.add(c);
80 }
81 }
82 return res;
83 }
84
85 private void testEquals(final GLDrawableFactory factory) {
86 final AbstractGraphicsDevice device = factory.getDefaultDevice();
87 Assert.assertNotNull(device);
88 // System.err.println(JoglVersion.getDefaultOpenGLInfo(device, null, true).toString());
89
90 try {
91 final List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(device);
92 if( null != availCaps ) {
93 for(int i=0; i < availCaps.size(); i++) {
94 final GLCapabilitiesImmutable one = availCaps.get(i);
95 final List<GLCapabilitiesImmutable> res = getEquals(one, availCaps);
96 if( 1 != res.size() ) {
97 // oops
98 System.err.println("Error: "+one+" matches more than one in list, not unique:");
99 res.forEach(System.err::println);
100 }
101 Assert.assertEquals(1, res.size());
102 System.err.printf("#%3d/%d: %s%n", (i+1), availCaps.size(), one);
103 }
104 }
105 } catch (final GLException gle) { /* n/a */ }
106 }
107
108
109}
final List< GLCapabilitiesImmutable > getAvailableCapabilities(AbstractGraphicsDevice device)
Returns an array of available GLCapabilities for the device.
abstract AbstractGraphicsDevice getDefaultDevice()
Retrieve the default device connection, unit ID and unique ID name.
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
A interface describing a graphics device in a toolkit-independent manner.
Specifies an immutable set of OpenGL capabilities.