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 
29 package com.jogamp.opengl.test.junit.jogl.acore;
30 
31 import java.io.IOException;
32 
33 import com.jogamp.opengl.GLDrawableFactory;
34 import com.jogamp.opengl.GLProfile;
35 
36 import org.junit.FixMethodOrder;
37 import org.junit.Test;
38 import org.junit.runners.MethodSorters;
39 
40 import com.jogamp.common.GlueGenVersion;
41 import com.jogamp.common.util.VersionUtil;
42 import com.jogamp.nativewindow.NativeWindowVersion;
43 import com.jogamp.newt.NewtVersion;
44 import com.jogamp.opengl.JoglVersion;
45 
46 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
47 public class TestGLProfile01NEWT extends GLProfile0XBase {
48 
49     @Test
test00Version()50     public void test00Version() throws InterruptedException {
51         System.err.println(VersionUtil.getPlatformInfo());
52         System.err.println(GlueGenVersion.getInstance());
53         System.err.println(NativeWindowVersion.getInstance());
54         System.err.println(JoglVersion.getInstance());
55         System.err.println(NewtVersion.getInstance());
56 
57         final GLDrawableFactory deskFactory = GLDrawableFactory.getDesktopFactory();
58         if( null != deskFactory ) {
59             System.err.println(JoglVersion.getDefaultOpenGLInfo(deskFactory.getDefaultDevice(), null, true).toString());
60         }
61         final GLDrawableFactory eglFactory = GLDrawableFactory.getEGLFactory();
62         if( null != eglFactory ) {
63             System.err.println(JoglVersion.getDefaultOpenGLInfo(eglFactory.getDefaultDevice(), null, true).toString());
64         }
65     }
66 
67     @Test
test01GLProfileDefault()68     public void test01GLProfileDefault() throws InterruptedException {
69         System.out.println("GLProfile "+GLProfile.glAvailabilityToString());
70         System.out.println("GLProfile.getDefaultDevice(): "+GLProfile.getDefaultDevice());
71         final GLProfile glp = GLProfile.getDefault();
72         System.out.println("GLProfile.getDefault(): "+glp);
73         validateOffline("default", glp);
74         validateOnlineOnscreen("default", glp);
75     }
76 
77     @Test
test02GLProfileMaxProgrammable()78     public void test02GLProfileMaxProgrammable() throws InterruptedException {
79         // Assuming at least one programmable profile is available
80         final GLProfile glp = GLProfile.getMaxProgrammable(true);
81         System.out.println("GLProfile.getMaxProgrammable(): "+glp);
82         validateOffline("maxProgrammable", glp);
83         validateOnlineOnscreen("maxProgrammable", glp);
84     }
85 
86     @Test
test03GLProfileMaxFixedFunc()87     public void test03GLProfileMaxFixedFunc() throws InterruptedException {
88         // Assuming at least one fixed function profile is available
89         final GLProfile glp = GLProfile.getMaxFixedFunc(true);
90         System.out.println("GLProfile.getMaxFixedFunc(): "+glp);
91         validateOffline("maxFixedFunc", glp);
92         validateOnlineOnscreen("maxFixedFunc", glp);
93     }
94 
95     @Test
test04GLProfileGL2ES1()96     public void test04GLProfileGL2ES1() throws InterruptedException {
97         if(!GLProfile.isAvailable(GLProfile.GL2ES1)) {
98             System.out.println("GLProfile GL2ES1 n/a");
99             return;
100         }
101         final GLProfile glp = GLProfile.getGL2ES1();
102         validateOffline(GLProfile.GL2ES1, glp);
103         validateOnlineOnscreen(GLProfile.GL2ES1, glp);
104     }
105 
106     @Test
test05GLProfileGL2ES2()107     public void test05GLProfileGL2ES2() throws InterruptedException {
108         if(!GLProfile.isAvailable(GLProfile.GL2ES2)) {
109             System.out.println("GLProfile GL2ES2 n/a");
110             return;
111         }
112         final GLProfile glp = GLProfile.getGL2ES2();
113         validateOffline(GLProfile.GL2ES2, glp);
114         validateOnlineOnscreen(GLProfile.GL2ES2, glp);
115     }
116 
117     @Test
test06GLProfileGL4ES3()118     public void test06GLProfileGL4ES3() throws InterruptedException {
119         if(!GLProfile.isAvailable(GLProfile.GL4ES3)) {
120             System.out.println("GLProfile GL4ES3 n/a");
121             return;
122         }
123         final GLProfile glp = GLProfile.getGL4ES3();
124         validateOffline(GLProfile.GL4ES3, glp);
125         validateOnlineOnscreen(GLProfile.GL4ES3, glp);
126     }
127 
128     @Test
test07GLProfileGL2GL3()129     public void test07GLProfileGL2GL3() throws InterruptedException {
130         if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
131             System.out.println("GLProfile GL2GL3 n/a");
132             return;
133         }
134         final GLProfile glp = GLProfile.getGL2GL3();
135         validateOffline(GLProfile.GL2GL3, glp);
136         validateOnlineOnscreen(GLProfile.GL2GL3, glp);
137     }
138 
testSpecificProfile(final String glps)139     void testSpecificProfile(final String glps) throws InterruptedException {
140         if(GLProfile.isAvailable(glps)) {
141             final GLProfile glp = GLProfile.get(glps);
142             validateOffline(glps, glp);
143             validateOnlineOnscreen(glps, glp);
144         } else {
145             System.err.println("Profile "+glps+" n/a");
146         }
147     }
148 
149     @Test
test10_GL4bc()150     public void test10_GL4bc() throws InterruptedException {
151         testSpecificProfile(GLProfile.GL4bc);
152     }
153 
154     @Test
test11_GL3bc()155     public void test11_GL3bc() throws InterruptedException {
156         testSpecificProfile(GLProfile.GL3bc);
157     }
158 
159     @Test
test12_GL2()160     public void test12_GL2() throws InterruptedException {
161         testSpecificProfile(GLProfile.GL2);
162     }
163 
164     @Test
test13_GL4()165     public void test13_GL4() throws InterruptedException {
166         testSpecificProfile(GLProfile.GL4);
167     }
168 
169     @Test
test14_GL3()170     public void test14_GL3() throws InterruptedException {
171         testSpecificProfile(GLProfile.GL3);
172     }
173 
174     @Test
test15_GLES1()175     public void test15_GLES1() throws InterruptedException {
176         testSpecificProfile(GLProfile.GLES1);
177     }
178 
179     @Test
test16_GLES2()180     public void test16_GLES2() throws InterruptedException {
181         testSpecificProfile(GLProfile.GLES2);
182     }
183 
184     @Test
test17_GLES3()185     public void test17_GLES3() throws InterruptedException {
186         testSpecificProfile(GLProfile.GLES3);
187     }
188 
main(final String args[])189     public static void main(final String args[]) throws IOException {
190         final String tstname = TestGLProfile01NEWT.class.getName();
191         org.junit.runner.JUnitCore.main(tstname);
192     }
193 
194 }
195