JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
JoglVersion.java
Go to the documentation of this file.
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
29package com.jogamp.opengl;
30
31import com.jogamp.common.GlueGenVersion;
32
33import com.jogamp.common.os.Platform;
34import com.jogamp.common.util.VersionUtil;
35import com.jogamp.common.util.JogampVersion;
36
37import java.util.List;
38import java.util.jar.Manifest;
39
40import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
41import com.jogamp.nativewindow.AbstractGraphicsDevice;
42import com.jogamp.nativewindow.AbstractGraphicsScreen;
43import com.jogamp.nativewindow.NativeSurface;
44
45public class JoglVersion extends JogampVersion {
46
47 protected static volatile JoglVersion jogampCommonVersionInfo;
48
49 protected JoglVersion(final String packageName, final Manifest mf) {
50 super(packageName, mf);
51 }
52
53 public static JoglVersion getInstance() {
54 if(null == jogampCommonVersionInfo) { // volatile: ok
55 synchronized(JoglVersion.class) {
56 if( null == jogampCommonVersionInfo ) {
57 final String packageName = "com.jogamp.opengl";
58 final Manifest mf = VersionUtil.getManifest(JoglVersion.class.getClassLoader(), packageName);
59 jogampCommonVersionInfo = new JoglVersion(packageName, mf);
60 }
61 }
62 }
64 }
65
66 public StringBuilder toString(final GL gl, StringBuilder sb) {
67 sb = super.toString(sb).append(Platform.getNewline());
68 getGLInfo(gl, sb);
69 return sb;
70 }
71
72 public String toString(final GL gl) {
73 return toString(gl, null).toString();
74 }
75
76 public static StringBuilder getAvailableCapabilitiesInfo(final AbstractGraphicsDevice device, StringBuilder sb) {
77 if(null==sb) {
78 sb = new StringBuilder();
79 }
80 boolean done = false;
81 final GLDrawableFactory factory = GLDrawableFactory.getFactory(device);
82 if(null!=factory) {
83 try {
84 final List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(device);
85 if(null != availCaps && availCaps.size()>0) {
86 for(int i=0; i<availCaps.size(); i++) {
87 sb.append("\t").append(availCaps.get(i)).append(Platform.getNewline());
88 }
89 done = true;
90 }
91 } catch (final GLException gle) { /* n/a */ }
92 }
93 if(!done) {
94 sb.append("\tnone").append(Platform.getNewline());
95 }
96 sb.append(Platform.getNewline());
97 return sb;
98 }
99
100 public static StringBuilder getAllAvailableCapabilitiesInfo(AbstractGraphicsDevice device, StringBuilder sb) {
101 if(null==sb) {
102 sb = new StringBuilder();
103 }
104 if(null == device) {
105 device = GLProfile.getDefaultDevice();
106 }
107 sb.append(Platform.getNewline()).append(Platform.getNewline());
108 try {
109 sb.append("Capabilities for ").append(device.toString()).append(Platform.getNewline());
111 } catch (final GLException gle) {
112 System.err.println(gle.getMessage());
113 }
114 return sb;
115 }
116
117 public static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, final boolean withCapabilitiesInfo) {
118 if(null==sb) {
119 sb = new StringBuilder();
120 }
121 if(null == device) {
122 device = GLProfile.getDefaultDevice();
123 }
124 sb.append("GLProfiles on device ").append(device).append(Platform.getNewline());
125 if(null!=device) {
126 GLProfile.glAvailabilityToString(device, sb, "\t", 1);
127 } else {
128 sb.append("none");
129 }
130 if(withCapabilitiesInfo) {
131 sb = getAllAvailableCapabilitiesInfo(device, sb);
132 }
133 return sb;
134 }
135
136 public static StringBuilder getGLInfo(final GL gl, final StringBuilder sb) {
137 return getGLInfo(gl, sb, false);
138 }
139 public static StringBuilder getGLInfo(final GL gl, final StringBuilder sb, final boolean withCapabilitiesAndExtensionInfo) {
140 return getGLInfo(gl, sb, true, withCapabilitiesAndExtensionInfo, withCapabilitiesAndExtensionInfo);
141 }
142
143 public static StringBuilder getGLInfo(final GL gl, StringBuilder sb,
144 final boolean withAvailabilityInfo,
145 final boolean withCapabilitiesInfo,
146 final boolean withExtensionInfo) {
147 if(null==sb) {
148 sb = new StringBuilder();
149 }
150 sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline());
151 if( null == gl ) {
152 sb.append("Null GL instance").append(Platform.getNewline());
153 sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline());
154 return sb;
155 }
158
159 sb.append(device.toString()).append(':').append(Platform.getNewline());
160 if( withAvailabilityInfo ) {
161 GLProfile.glAvailabilityToString(device, sb, "\t", 1);
162 }
163 sb.append(Platform.getNewline());
164
165 sb = getGLStrings(gl, sb, withExtensionInfo);
166
167 if( withCapabilitiesInfo ) {
168 sb = getAllAvailableCapabilitiesInfo(device, sb);
169 }
170 return sb;
171 }
172
173 public static StringBuilder getGLStrings(final GL gl, final StringBuilder sb) {
174 return getGLStrings(gl, sb, true);
175 }
176
177 public static StringBuilder getGLStrings(final GL gl, StringBuilder sb, final boolean withExtensions) {
178 if(null==sb) {
179 sb = new StringBuilder();
180 }
181 final GLContext ctx = gl.getContext();
182 sb.append("Swap Interval ").append(gl.getSwapInterval());
183 sb.append(Platform.getNewline());
184 sb.append("GL Profile ").append(gl.getGLProfile());
185 sb.append(Platform.getNewline());
186 sb.append("GL Version ").append(ctx.getGLVersion()).append(" [GL ").append(ctx.getGLVersionNumber()).append(", vendor ").append(ctx.getGLVendorVersionNumber()).append("]");
187 sb.append(Platform.getNewline());
188 sb.append("Quirks ").append(ctx.getRendererQuirks());
189 sb.append(Platform.getNewline());
190 sb.append("Impl. class ").append(gl.getClass().getCanonicalName());
191 sb.append(Platform.getNewline());
192 sb.append("GL_VENDOR ").append(gl.glGetString(GL.GL_VENDOR));
193 sb.append(Platform.getNewline());
194 sb.append("GL_RENDERER ").append(gl.glGetString(GL.GL_RENDERER));
195 sb.append(Platform.getNewline());
196 sb.append("GL_VERSION ").append(gl.glGetString(GL.GL_VERSION));
197 sb.append(Platform.getNewline());
198 sb.append("GLSL ").append(gl.hasGLSL()).append(", has-compiler-func: ").append(gl.isFunctionAvailable("glCompileShader"));
199 if(gl.hasGLSL()) {
200 sb.append(", version: ").append(gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION)).append(" / ").append(ctx.getGLSLVersionNumber());
201 }
202 sb.append(Platform.getNewline());
203 sb.append("GL FBO: basic ").append(gl.hasBasicFBOSupport()).append(", full ").append(gl.hasFullFBOSupport());
204 sb.append(Platform.getNewline());
205 sb.append("GL_EXTENSIONS ").append(ctx.getGLExtensionCount());
206 sb.append(Platform.getNewline());
207 if( withExtensions ) {
208 sb.append(" ").append(ctx.getGLExtensionsString());
209 sb.append(Platform.getNewline());
210 }
211 sb.append("GLX_EXTENSIONS ").append(ctx.getPlatformExtensionCount());
212 sb.append(Platform.getNewline());
213 if( withExtensions ) {
214 sb.append(" ").append(ctx.getPlatformExtensionsString());
215 sb.append(Platform.getNewline());
216 }
217 sb.append(VersionUtil.SEPERATOR);
218
219 return sb;
220 }
221
222 public StringBuilder getBriefOSGLBuildInfo(final GL gl, StringBuilder sb) {
223 if(null==sb) {
224 sb = new StringBuilder();
225 }
226 sb.append("OS: ").append(Platform.getOSName()).append(", version ").append(Platform.getOSVersion()).append(", arch ").append(Platform.getArchName());
227 sb.append(Platform.getNewline());
228 sb.append("GL_VENDOR ").append(gl.glGetString(GL.GL_VENDOR));
229 sb.append(Platform.getNewline());
230 sb.append("GL_RENDERER ").append(gl.glGetString(GL.GL_RENDERER));
231 sb.append(Platform.getNewline());
232 sb.append("GL_VERSION ").append(gl.glGetString(GL.GL_VERSION));
233 sb.append(Platform.getNewline());
234 sb.append("JOGL GIT sha1 ").append(getImplementationCommit());
235 sb.append(Platform.getNewline());
236 return sb;
237 }
238
239 public static void main(final String args[]) {
240 System.err.println(VersionUtil.getPlatformInfo());
241 System.err.println(GlueGenVersion.getInstance());
242 // System.err.println(NativeWindowVersion.getInstance());
243 System.err.println(JoglVersion.getInstance());
244 }
245}
246
Abstraction for an OpenGL rendering context.
Definition: GLContext.java:74
final StringBuilder append(final StringBuilder sb)
Definition: GLContext.java:640
abstract GLDrawable getGLDrawable()
Returns the write-drawable this context uses for framebuffer operations.
abstract String getGLExtensionsString()
Returns a non-null (but possibly empty) string containing the space-separated list of available exten...
final VersionNumber getGLVersionNumber()
Returns this context OpenGL version.
Definition: GLContext.java:777
final GLRendererQuirks getRendererQuirks()
Returns the instance of GLRendererQuirks, allowing one to determine workarounds.
Definition: GLContext.java:290
final VersionNumberString getGLVendorVersionNumber()
Returns the vendor's version, i.e.
Definition: GLContext.java:788
abstract String getPlatformExtensionsString()
Returns a non-null (but possibly empty) string containing the space-separated list of available platf...
final String getGLVersion()
Returns a valid OpenGL version string, ie
Definition: GLContext.java:769
abstract int getGLExtensionCount()
Returns the number of OpenGL extensions.
abstract int getPlatformExtensionCount()
Returns the number of platform extensions.
final List< GLCapabilitiesImmutable > getAvailableCapabilities(AbstractGraphicsDevice device)
Returns an array of available GLCapabilities for the device.
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static String glAvailabilityToString(final AbstractGraphicsDevice device)
Definition: GLProfile.java:333
static AbstractGraphicsDevice getDefaultDevice()
static StringBuilder getGLStrings(final GL gl, StringBuilder sb, final boolean withExtensions)
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb, final boolean withCapabilitiesAndExtensionInfo)
static StringBuilder getAvailableCapabilitiesInfo(final AbstractGraphicsDevice device, StringBuilder sb)
static volatile JoglVersion jogampCommonVersionInfo
JoglVersion(final String packageName, final Manifest mf)
String toString(final GL gl)
static JoglVersion getInstance()
static void main(final String args[])
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb)
static StringBuilder getAllAvailableCapabilitiesInfo(AbstractGraphicsDevice device, StringBuilder sb)
static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, final boolean withCapabilitiesInfo)
static StringBuilder getGLInfo(final GL gl, StringBuilder sb, final boolean withAvailabilityInfo, final boolean withCapabilitiesInfo, final boolean withExtensionInfo)
static StringBuilder getGLStrings(final GL gl, final StringBuilder sb)
StringBuilder getBriefOSGLBuildInfo(final GL gl, StringBuilder sb)
StringBuilder toString(final GL gl, StringBuilder sb)
AbstractGraphicsScreen getScreen()
Return the screen this graphics configuration is valid for.
A interface describing a graphics device in a toolkit-independent manner.
AbstractGraphicsDevice getDevice()
Return the device this graphics configuration is valid for.
AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
static final int GL_SHADING_LANGUAGE_VERSION
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_ARB_shading_language_100 Alias for: GL_SHADING_LANGUAGE_VERSION...
Definition: GL2ES2.java:234
boolean hasGLSL()
Indicates whether this GL object supports GLSL.
boolean hasBasicFBOSupport()
Returns true if basic FBO support is available, otherwise false.
GLProfile getGLProfile()
Returns the GLProfile associated with this GL object.
GLContext getContext()
Returns the GLContext associated which this GL object.
boolean isFunctionAvailable(String glFunctionName)
Returns true if the specified OpenGL core- or extension-function can be used successfully through thi...
int getSwapInterval()
Return the current swap interval.
boolean hasFullFBOSupport()
Returns true if full FBO support is available, otherwise false.
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.
static final int GL_VERSION
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_VERSION" with express...
Definition: GL.java:190
String glGetString(int name)
Entry point to C language function: const GLubyte * {@native glGetString}(GLenum name) Part of GL_...
static final int GL_RENDERER
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RENDERER" with expres...
Definition: GL.java:662
static final int GL_VENDOR
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_VENDOR" with expressi...
Definition: GL.java:607