Jogamp
NewtVersionActivity: Remove 'gears' test; Version Info: Drop NativeWindow/Newt Versio...
[jogl.git] / src / jogl / classes / com / jogamp / opengl / JoglVersion.java
CommitLineData
d7faeb8b
SG
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
dac35658 29package com.jogamp.opengl;
d7faeb8b 30
2aa90676 31import com.jogamp.common.GlueGenVersion;
d7faeb8b
SG
32import javax.media.opengl.*;
33import com.jogamp.common.os.Platform;
08933398 34import com.jogamp.common.util.VersionUtil;
dac35658 35import com.jogamp.common.util.JogampVersion;
2aa90676 36import com.jogamp.nativewindow.NativeWindowVersion;
dac35658 37import java.util.jar.Manifest;
d8293b3a 38import javax.media.nativewindow.AbstractGraphicsDevice;
d7faeb8b 39
dac35658 40public class JoglVersion extends JogampVersion {
d7faeb8b 41
448d9ca9 42 protected static volatile JoglVersion jogampCommonVersionInfo;
dac35658
SG
43
44 protected JoglVersion(String packageName, Manifest mf) {
45 super(packageName, mf);
08933398
SG
46 }
47
dac35658 48 public static JoglVersion getInstance() {
76444dce 49 if(null == jogampCommonVersionInfo) { // volatile: ok
dac35658
SG
50 synchronized(JoglVersion.class) {
51 if( null == jogampCommonVersionInfo ) {
52 final String packageName = "javax.media.opengl";
448d9ca9 53 final Manifest mf = VersionUtil.getManifest(JoglVersion.class.getClassLoader(), packageName);
dac35658
SG
54 jogampCommonVersionInfo = new JoglVersion(packageName, mf);
55 }
56 }
d7faeb8b 57 }
dac35658
SG
58 return jogampCommonVersionInfo;
59 }
d7faeb8b 60
77546f89 61 public StringBuilder toString(GL gl, StringBuilder sb) {
2aa90676 62 sb = super.toString(sb).append(Platform.getNewline());
dac35658 63 getGLInfo(gl, sb);
d7faeb8b
SG
64 return sb;
65 }
66
83d3a3f2 67 public String toString(GL gl) {
448d9ca9 68 return toString(gl, null).toString();
83d3a3f2
SG
69 }
70
77546f89 71 public static StringBuilder getGLInfo(GL gl, StringBuilder sb) {
d8293b3a
SG
72 AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface()
73 .getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
d7faeb8b 74 if(null==sb) {
77546f89 75 sb = new StringBuilder();
d7faeb8b 76 }
0c9eb947 77 GLContext ctx = gl.getContext();
d7faeb8b 78
2aa90676 79 sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline());
77546f89 80 sb.append(device.getClass().getSimpleName()).append("[type ")
d8293b3a
SG
81 .append(device.getType()).append(", connection ").append(device.getConnection()).append("]: ")
82 .append(GLProfile.glAvailabilityToString(device));
597d10f5 83 sb.append(Platform.getNewline());
dac35658 84 sb.append("Swap Interval ").append(gl.getSwapInterval());
d7faeb8b 85 sb.append(Platform.getNewline());
dac35658 86 sb.append("GL Profile ").append(gl.getGLProfile());
d7faeb8b 87 sb.append(Platform.getNewline());
dac35658 88 sb.append("CTX VERSION ").append(gl.getContext().getGLVersion());
d7faeb8b 89 sb.append(Platform.getNewline());
dac35658 90 sb.append("GL ").append(gl);
d7faeb8b 91 sb.append(Platform.getNewline());
c6c30d46
SG
92 sb.append("GL_VENDOR ").append(gl.glGetString(gl.GL_VENDOR));
93 sb.append(Platform.getNewline());
dac35658 94 sb.append("GL_VERSION ").append(gl.glGetString(gl.GL_VERSION));
d7faeb8b 95 sb.append(Platform.getNewline());
dac35658 96 sb.append("GL_EXTENSIONS ");
d7faeb8b 97 sb.append(Platform.getNewline());
0c9eb947
SG
98 sb.append(" ").append(ctx.getGLExtensionsString());
99 sb.append(Platform.getNewline());
100 sb.append("GLX_EXTENSIONS ");
101 sb.append(Platform.getNewline());
102 sb.append(" ").append(ctx.getPlatformExtensionsString());
08933398 103 sb.append(Platform.getNewline());
8998ed04
SG
104 sb.append("GLSL ").append(gl.hasGLSL()).append(", shader-compiler: ").append(gl.isFunctionAvailable("glCompileShader"));
105 sb.append(Platform.getNewline());
2aa90676 106 sb.append(VersionUtil.SEPERATOR);
d7faeb8b
SG
107
108 return sb;
109 }
110
08933398 111 public static void main(String args[]) {
8c9f3bb3 112 System.err.println(VersionUtil.getPlatformInfo());
2aa90676 113 System.err.println(GlueGenVersion.getInstance());
62df9dd1 114 // System.err.println(NativeWindowVersion.getInstance());
83d3a3f2 115 System.err.println(JoglVersion.getInstance());
d7faeb8b
SG
116 }
117}
118
http://JogAmp.org git info: FAQ, tutorial and man pages.