JOGL v2.6.0-rc-20250722
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLContext.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2023 JogAmp Community. All rights reserved.
3 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * - Redistribution of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistribution in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any kind. ALL
21 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
22 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
23 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
24 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
25 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
27 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
28 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
29 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
30 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
31 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that this software is not designed or intended for use
34 * in the design, construction, operation or maintenance of any nuclear
35 * facility.
36 */
37
38package com.jogamp.opengl;
39
40import java.nio.IntBuffer;
41import java.util.HashMap;
42import java.util.IdentityHashMap;
43import java.util.Iterator;
44import java.util.List;
45import java.util.Set;
46
47import com.jogamp.common.os.DynamicLibraryBundle;
48import com.jogamp.common.os.Platform;
49import com.jogamp.common.util.Bitfield;
50import com.jogamp.common.util.VersionNumber;
51import com.jogamp.common.util.VersionNumberString;
52import com.jogamp.common.util.locks.LockFactory;
53import com.jogamp.common.util.locks.RecursiveLock;
54import com.jogamp.nativewindow.AbstractGraphicsDevice;
55import com.jogamp.nativewindow.NativeSurface;
56
57import jogamp.opengl.Debug;
58import jogamp.opengl.GLContextImpl;
59import jogamp.opengl.GLContextShareSet;
60import jogamp.opengl.GLDynamicLookupHelper;
61
62/** Abstraction for an OpenGL rendering context. In order to perform
63 OpenGL rendering, a context must be "made current" on the current
64 thread. OpenGL rendering semantics specify that only one context
65 may be current on the current thread at any given time, and also
66 that a given context may be current on only one thread at any
67 given time. Because components can be added to and removed from
68 the component hierarchy at any time, it is possible that the
69 underlying OpenGL context may need to be destroyed and recreated
70 multiple times over the lifetime of a given component. This
71 process is handled by the implementation, and the GLContext
72 abstraction provides a stable object which clients can use to
73 refer to a given context. */
74public abstract class GLContext {
75
76 public static final boolean DEBUG = Debug.debug("GLContext");
77 public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true);
78 public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH;
79
80 /**
81 * If <code>true</code> (default), bootstrapping the available GL profiles
82 * will use the highest compatible GL context for each profile,
83 * hence skipping querying lower profiles if a compatible higher one is found:
84 * <ul>
85 * <li>4.2-core -> 4.2-core, 3.3-core</li>
86 * <li>4.2-comp -> 4.2-comp, 3.3-comp, 2</li>
87 * </ul>
88 * Otherwise the dedicated GL context would be queried and used:
89 * <ul>
90 * <li>4.2-core -> 4.2-core</li>
91 * <li>3.3-core -> 3.3-core</li>
92 * <li>4.2-comp -> 4.2-comp</li>
93 * <li>3.3-comp -> 3.3-comp</li>
94 * <li>3.0-comp -> 2</li>
95 * </ul>
96 * Using aliasing speeds up initialization about:
97 * <ul>
98 * <li>Linux x86_64 - Nvidia: 28%, 700ms down to 500ms</li>
99 * <li>Linux x86_64 - AMD : 40%, 1500ms down to 900ms</li>
100 * <p>
101 * Can be turned off with property <code>jogl.debug.GLContext.NoProfileAliasing</code>.
102 * </p>
103 */
104 public static final boolean PROFILE_ALIASING = !Debug.isPropertyDefined("jogl.debug.GLContext.NoProfileAliasing", true);
105
106 /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */
107 public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true);
108 /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */
109 public static final boolean TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true);
110
111 /** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
112 public static final int CONTEXT_NOT_CURRENT = 0;
113 /** Indicates that the context was made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
114 public static final int CONTEXT_CURRENT = 1;
115 /** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
116 public static final int CONTEXT_CURRENT_NEW = 2;
117
118 /** Version 1.00, i.e. GLSL 1.00 for ES 2.0. */
119 public static final VersionNumber Version1_0 = new VersionNumber(1, 0, 0);
120 /** Version 1.10, i.e. GLSL 1.10 for GL 2.0. */
121 public static final VersionNumber Version1_10 = new VersionNumber(1, 10, 0);
122 /** Version 1.20, i.e. GLSL 1.20 for GL 2.1. */
123 public static final VersionNumber Version1_20 = new VersionNumber(1, 20, 0);
124 /** Version 1.30, i.e. GLSL 1.30 for GL 3.0. */
125 public static final VersionNumber Version1_30 = new VersionNumber(1, 30, 0);
126 /** Version 1.40, i.e. GLSL 1.40 for GL 3.1. */
127 public static final VersionNumber Version1_40 = new VersionNumber(1, 40, 0);
128 /** Version 1.50, i.e. GLSL 1.50 for GL 3.2. */
129 public static final VersionNumber Version1_50 = new VersionNumber(1, 50, 0);
130
131 /** Version 1.1, i.e. GL 1.1 */
132 public static final VersionNumber Version1_1 = new VersionNumber(1, 1, 0);
133
134 /** Version 1.2, i.e. GL 1.2 */
135 public static final VersionNumber Version1_2 = new VersionNumber(1, 2, 0);
136
137 /** Version 1.4, i.e. GL 1.4 */
138 public static final VersionNumber Version1_4 = new VersionNumber(1, 4, 0);
139
140 /** Version 1.5, i.e. GL 1.5 */
141 public static final VersionNumber Version1_5 = new VersionNumber(1, 5, 0);
142
143 /** Version 3.0. As an OpenGL version, it qualifies for desktop {@link #isGL2()} only, or ES 3.0. Or GLSL 3.00 for ES 3.0. */
144 public static final VersionNumber Version3_0 = new VersionNumber(3, 0, 0);
145 /** Version 3.10. GLSL 3.10 for ES 3.1. */
146 public static final VersionNumber Version3_10 = new VersionNumber(3, 10, 0);
147 /** Version 3.20. GLSL 3.20 for ES 3.2. */
148 public static final VersionNumber Version3_20 = new VersionNumber(3, 20, 0);
149
150 /** Version 3.1. As an OpenGL version, it qualifies for {@link #isGL3core()}, {@link #isGL3bc()} and {@link #isGL3()}, or ES 3.1. */
151 public static final VersionNumber Version3_1 = new VersionNumber(3, 1, 0);
152
153 /** Version 3.2. As an OpenGL version, it qualifies for geometry shader, , or ES 3.2. */
154 public static final VersionNumber Version3_2 = new VersionNumber(3, 2, 0);
155
156 /** Version 4.3. As an OpenGL version, it qualifies for <code>GL_ARB_ES3_compatibility</code> */
157 public static final VersionNumber Version4_3 = new VersionNumber(4, 3, 0);
158
159 protected static final VersionNumber Version8_0 = new VersionNumber(8, 0, 0);
160
161 private static final String S_EMPTY = "";
162
163 //
164 // Cached keys, bits [0..15]
165 //
166
167 /** Context option bits, full bit mask covering 16 bits [0..15], i.e. <code>0x0000FFFF</code>, {@value}. */
168 protected static final int CTX_IMPL_FULL_MASK = 0x0000FFFF;
169
170 /** Context option bits, cached bit mask covering 10 bits [0..9], i.e. <code>0x000003FF</code>, {@value}. Leaving 6 bits for non cached options, i.e. 10:6. */
171 protected static final int CTX_IMPL_CACHE_MASK = 0x000003FF;
172
173 /** <code>ARB_create_context</code> related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
174 protected static final int CTX_IS_ARB_CREATED = 1 << 0;
175 /** <code>ARB_create_context</code> related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
176 protected static final int CTX_PROFILE_COMPAT = 1 << 1;
177 /** <code>ARB_create_context</code> related: desktop core profile. Cache key value. See {@link #isGLCoreProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
178 protected static final int CTX_PROFILE_CORE = 1 << 2;
179 /** <code>ARB_create_context</code> related: ES profile. Cache key value. See {@link #isGLES()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
180 protected static final int CTX_PROFILE_ES = 1 << 3;
181 /** <code>ARB_create_context</code> related: flag forward compatible. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
182 protected static final int CTX_OPTION_FORWARD = 1 << 4;
183 /** <code>ARB_create_context</code> related: flag debug. Cache key value. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
184 public static final int CTX_OPTION_DEBUG = 1 << 5;
185 /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
186 protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 6;
187
188 //
189 // Non cached keys, 6 bits [10..15]
190 //
191
192 /** <code>GL_ARB_ES2_compatibility</code> implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
193 protected static final int CTX_IMPL_ES2_COMPAT = 1 << 10;
194
195 /** <code>GL_ARB_ES3_compatibility</code> implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
196 protected static final int CTX_IMPL_ES3_COMPAT = 1 << 11;
197
198 /** <code>GL_ARB_ES3_1_compatibility</code> implementation related: Context is compatible w/ ES 3.1. Not a cache key. See {@link #isGLES31Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
199 protected static final int CTX_IMPL_ES31_COMPAT = 1 << 12;
200
201 /** <code>GL_ARB_ES3_2_compatibility</code> implementation related: Context is compatible w/ ES 3.2. Not a cache key. See {@link #isGLES32Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
202 protected static final int CTX_IMPL_ES32_COMPAT = 1 << 13;
203
204 /**
205 * Context supports basic FBO, details see {@link #hasBasicFBOSupport()}.
206 * Not a cache key.
207 * @see #hasBasicFBOSupport()
208 * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
209 */
210 protected static final int CTX_IMPL_FBO = 1 << 14;
211
212 /**
213 * Context supports <code>OES_single_precision</code>, fp32, fixed function point (FFP) compatibility entry points,
214 * see {@link #hasFP32CompatAPI()}.
215 * Not a cache key.
216 * @see #hasFP32CompatAPI()
217 * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
218 */
219 protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 15;
220
221 private static final ThreadLocal<GLContext> currentContext = new ThreadLocal<GLContext>();
222
223 private final HashMap<String, Object> attachedObjects = new HashMap<String, Object>();
224
225 // RecursiveLock maintains a queue of waiting Threads, ensuring the longest waiting thread will be notified at unlock.
226 protected final RecursiveLock lock = LockFactory.createRecursiveLock(); // FIXME: Move to GLContextImpl when incr. minor version (incompatible change)
227
228 /** The underlying native OpenGL context */
229 protected volatile long contextHandle; // volatile: avoid locking for read-only access
230
231 protected GLContext() {
232 resetStates(true);
233 }
234
235 protected VersionNumberString ctxVersion;
236 protected int ctxOptions;
237 protected String ctxVersionString;
238 protected VersionNumberString ctxVendorVersion;
239 protected VersionNumberString ctxGLSLVersion;
241
242 /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */
243 protected boolean drawableRetargeted;
244
245 /**
246 * @param isInit true if called for class initialization, otherwise false (re-init or destruction).
247 */
248 protected void resetStates(final boolean isInit) {
249 if (DEBUG) {
250 System.err.println(getThreadName() + ": GLContext.resetStates(isInit "+isInit+")");
251 // Thread.dumpStack();
252 }
253 ctxVersion = VersionNumberString.zeroVersion;
254 ctxVendorVersion = VersionNumberString.zeroVersion;
255 ctxOptions=0;
256 ctxVersionString=null;
257 ctxGLSLVersion = VersionNumberString.zeroVersion;
258 attachedObjects.clear();
260 glRendererQuirks = null;
261 drawableRetargeted = false;
262 }
263
264 /** Returns true if this GLContext is shared, otherwise false. */
265 public final boolean isShared() {
266 return GLContextShareSet.isShared(this);
267 }
268
269 /**
270 * Returns the shared master GLContext of this GLContext if shared, otherwise return <code>null</code>.
271 * <p>
272 * Returns this GLContext, if it is a shared master.
273 * </p>
274 * @since 2.2.1
275 */
276 public final GLContext getSharedMaster() {
277 return GLContextShareSet.getSharedMaster(this);
278 }
279
280 /** Returns a new list of created GLContext shared with this GLContext. */
281 public final List<GLContext> getCreatedShares() {
282 return GLContextShareSet.getCreatedShares(this);
283 }
284
285 /** Returns a new list of destroyed GLContext shared with this GLContext. */
286 public final List<GLContext> getDestroyedShares() {
287 return GLContextShareSet.getDestroyedShares(this);
288 }
289
290 /**
291 * Returns the instance of {@link GLRendererQuirks}, allowing one to determine workarounds.
292 * @return instance of {@link GLRendererQuirks} if context was made current once, otherwise <code>null</code>.
293 */
295
296 /**
297 * Returns true if the <code>quirk</code> exist in {@link #getRendererQuirks()}, otherwise false.
298 * <p>
299 * Convenience method for:
300 * <pre>
301 * final GLRendererQuirks glrq = ctx.getRendererQuirks();
302 * boolean hasQuirk = null != glrq ? glrq.exist(quirk) : false ;
303 * </pre>
304 * </p>
305 * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
306 * @throws IllegalArgumentException if the quirk is out of range
307 */
308 public final boolean hasRendererQuirk(final int quirk) throws IllegalArgumentException {
309 return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ;
310 }
311
312 /**
313 * Sets the read/write drawable for framebuffer operations, i.e. reassociation of the context's drawable.
314 * <p>
315 * If the arguments reflect the current state of this context
316 * this method is a no-operation and returns the old and current {@link GLDrawable}.
317 * </p>
318 * <p>
319 * Remarks:
320 * <ul>
321 * <li>{@link GL#glFinish() glFinish()} is issued if context {@link #isCreated()} and a {@link #getGLDrawable() previous drawable} was bound before disassociation.</li>
322 * <li>If the context was current on this thread, it is being released before drawable reassociation
323 * and made current afterwards.</li>
324 * <li>Implementation may issue {@link #makeCurrent()} and {@link #release()} while drawable reassociation.</li>
325 * <li>The user shall take extra care of thread synchronization,
326 * i.e. lock the involved {@link GLDrawable#getNativeSurface() drawable's} {@link NativeSurface}s
327 * to avoid a race condition. In case {@link GLAutoDrawable auto-drawable's} are used,
328 * their {@link GLAutoDrawable#getUpstreamLock() upstream-lock} must be locked beforehand
329 * see <a href="GLAutoDrawable.html#locking">GLAutoDrawable Locking</a>.</li>
330 * </ul>
331 * </p>
332 * @param readWrite The read/write drawable for framebuffer operations, maybe <code>null</code> to remove association.
333 * @param setWriteOnly Only change the write-drawable, if <code>setWriteOnly</code> is <code>true</code> and
334 * if the {@link #getGLReadDrawable() read-drawable} differs
335 * from the {@link #getGLDrawable() write-drawable}.
336 * Otherwise set both drawables, read and write.
337 * @return The previous read/write drawable if operation succeeds
338 *
339 * @throws GLException in case <code>null</code> is being passed,
340 * this context is made current on another thread
341 * or operation fails.
342 *
343 * @see #isGLReadDrawableAvailable()
344 * @see #setGLReadDrawable(GLDrawable)
345 * @see #getGLReadDrawable()
346 * @see #setGLDrawable(GLDrawable, boolean)
347 * @see #getGLDrawable()
348 */
349 public abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly);
350
351 /**
352 * Returns the write-drawable this context uses for framebuffer operations.
353 * <p>
354 * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)},
355 * it equals to the write-drawable (default).
356 * </p>
357 * <p>
358 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
359 * </p>
360 * @see #setGLDrawable(GLDrawable, boolean)
361 * @see #setGLReadDrawable(GLDrawable)
362 */
363 public abstract GLDrawable getGLDrawable();
364
365 /**
366 * Query whether using a distinguished read-drawable is supported.
367 * @return true if using a read-drawable is supported with your driver/OS, otherwise false.
368 */
369 public abstract boolean isGLReadDrawableAvailable();
370
371 /**
372 * Set the read-Drawable for read framebuffer operations.<br>
373 * The caller should query if this feature is supported via {@link #isGLReadDrawableAvailable()}.
374 * <p>
375 * If the context was current on this thread, it is being released before switching the drawable
376 * and made current afterwards. However the user shall take extra care that not other thread
377 * attempts to make this context current. Otherwise a race condition may happen.
378 * </p>
379 *
380 * @param read the read-drawable for read framebuffer operations.
381 * If null is passed, the default write drawable will be set.
382 * @return the previous read-drawable
383 *
384 * @throws GLException in case a read drawable is not supported or
385 * this context is made current on another thread.
386 *
387 * @see #isGLReadDrawableAvailable()
388 * @see #getGLReadDrawable()
389 */
391
392 /**
393 * Returns the read-Drawable this context uses for read framebuffer operations.
394 * <p>
395 * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)},
396 * it equals to the write-drawable (default).
397 * </p>
398 * <p>
399 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
400 * </p>
401 * @see #isGLReadDrawableAvailable()
402 * @see #setGLReadDrawable(GLDrawable)
403 * @see #getGLReadDrawable()
404 */
405 public abstract GLDrawable getGLReadDrawable();
406
407 /**
408 * Makes this GLContext current on the calling thread.
409 * <p>
410 * Recursive call to {@link #makeCurrent()} and hence {@link #release()} are supported.
411 * </p>
412 * <p>
413 * There are two return values that indicate success and one that
414 * indicates failure.
415 * </p>
416 * <p>
417 * A return value of {@link #CONTEXT_CURRENT_NEW}
418 * indicates that that context has been made current for the 1st time,
419 * or that the state of the underlying context or drawable has
420 * changed since the last time this context was current.
421 * In this case, the application may wish to initialize the render state.
422 * </p>
423 * <p>
424 * A return value of {@link #CONTEXT_CURRENT} indicates that the context has
425 * been made current, with its previous state restored.
426 * </p>
427 * <p>
428 * If the context could not be made current (for example, because
429 * the underlying drawable has not ben realized on the display) ,
430 * a value of {@link #CONTEXT_NOT_CURRENT} is returned.
431 * </p>
432 * <p>
433 * This method is blocking, i.e. waits until another thread has
434 * released the context.
435 * </p>
436 * <p>
437 * The drawable's surface is being locked at entry
438 * and unlocked at {@link #release()}
439 * </p>
440 *
441 * @return <ul>
442 * <li>{@link #CONTEXT_CURRENT_NEW} if the context was successfully made current the 1st time,</li>
443 * <li>{@link #CONTEXT_CURRENT} if the context was successfully made current,</li>
444 * <li>{@link #CONTEXT_NOT_CURRENT} if the context could not be made current.</li>
445 * </ul>
446 *
447 * @throws GLException if the context could not be created
448 * or made current due to non-recoverable, system-specific errors.
449 */
450 public abstract int makeCurrent() throws GLException;
451
452 /**
453 * Releases control of this GLContext from the current thread.
454 * <p>
455 * Recursive call to {@link #release()} and hence {@link #makeCurrent()} are supported.
456 * </p>
457 * <p>
458 * The drawable's surface is being unlocked at exit,
459 * assumed to be locked by {@link #makeCurrent()}.
460 * </p>
461 *
462 * @throws GLException if the context had not previously been made
463 * current on the current thread
464 */
465 public abstract void release() throws GLException;
466
467 /**
468 * Copies selected groups of OpenGL state variables from the
469 * supplied source context into this one. The <code>mask</code>
470 * parameter indicates which groups of state variables are to be
471 * copied. <code>mask</code> contains the bitwise OR of the same
472 * symbolic names that are passed to the GL command {@link
473 * GL2#glPushAttrib glPushAttrib}. The single symbolic constant
474 * {@link GL2#GL_ALL_ATTRIB_BITS GL_ALL_ATTRIB_BITS} can be used to
475 * copy the maximum possible portion of rendering state. <P>
476 *
477 * Not all values for GL state can be copied. For example, pixel
478 * pack and unpack state, render mode state, and select and feedback
479 * state are not copied. The state that can be copied is exactly the
480 * state that is manipulated by the GL command {@link
481 * GL2#glPushAttrib glPushAttrib}. <P>
482 *
483 * On most platforms, this context may not be current to any thread,
484 * including the calling thread, when this method is called. Some
485 * platforms have additional requirements such as whether this
486 * context or the source context must occasionally be made current
487 * in order for the results of the copy to be seen; these
488 * requirements are beyond the scope of this specification.
489 *
490 * @param source the source OpenGL context from which to copy state
491 * @param mask a mask of symbolic names indicating which groups of state to copy
492
493 * @throws GLException if an OpenGL-related error occurred
494 */
495 public abstract void copy(GLContext source, int mask) throws GLException;
496
497 /**
498 * Returns the GL object bound to this thread current context.
499 * If no context is current, throw an GLException
500 *
501 * @return the current context's GL object on this thread
502 * @throws GLException if no context is current
503 */
504 public static GL getCurrentGL() throws GLException {
505 final GLContext glc = getCurrent();
506 if(null==glc) {
507 throw new GLException(getThreadName()+": No OpenGL context current on this thread");
508 }
509 return glc.getGL();
510 }
511
512 /**
513 * Returns this thread current context.
514 * If no context is current, returns null.
515 *
516 * @return the context current on this thread, or null if no context
517 * is current.
518 */
519 public static GLContext getCurrent() {
520 return currentContext.get();
521 }
522
523 /**
524 * @return true if this GLContext is current on this thread
525 */
526 public final boolean isCurrent() {
527 return getCurrent() == this ;
528 }
529
530 /**
531 * @throws GLException if this GLContext is not current on this thread
532 */
533 public final void validateCurrent() throws GLException {
534 if(getCurrent() != this) {
535 throw new GLException(getThreadName()+": This context is not current. Current context: "+getCurrent()+", this context "+this);
536 }
537 }
538
539 /** Returns a String representation of the {@link #makeCurrent()} result. */
540 public static final String makeCurrentResultToString(final int res) {
541 switch(res) {
542 case CONTEXT_NOT_CURRENT: return "CONTEXT_NOT_CURRENT";
543 case CONTEXT_CURRENT: return "CONTEXT_CURRENT";
544 case CONTEXT_CURRENT_NEW: return "CONTEXT_CURRENT_NEW";
545 default: return "INVALID_VALUE";
546 }
547 }
548
549 /**
550 * Sets the thread-local variable returned by {@link #getCurrent}
551 * and has no other side-effects. For use by third parties adding
552 * new GLContext implementations; not for use by end users.
553 */
554 protected static void setCurrent(final GLContext cur) {
555 if( TRACE_SWITCH ) {
556 if(null == cur) {
557 System.err.println(getThreadName()+": GLContext.ContextSwitch: - setCurrent() - NULL");
558 } else {
559 System.err.println(getThreadName()+": GLContext.ContextSwitch: - setCurrent() - obj " + toHexString(cur.hashCode()) + ", ctx " + toHexString(cur.getHandle()));
560 }
561 }
562 currentContext.set(cur);
563 }
564
565 /**
566 * Destroys this OpenGL context and frees its associated
567 * resources.
568 * <p>
569 * The context may be current w/o recursion when calling <code>destroy()</code>,
570 * in which case this method destroys the context and releases the lock.
571 * </p>
572 */
573 public abstract void destroy();
574
575 /**
576 * Returns the implementing root GL instance of this GLContext's GL object,
577 * considering a wrapped pipelined hierarchy, see {@link GLBase#getDownstreamGL()}.
578 * @throws GLException if the root instance is not a GL implementation
579 * @see GLBase#getRootGL()
580 * @see GLBase#getDownstreamGL()
581 * @see #getGL()
582 * @see #setGL(GL)
583 */
584 public abstract GL getRootGL();
585
586 /**
587 * Returns the GL pipeline object for this GLContext.
588 *
589 * @return the aggregated GL instance, or null if this context was not yet made current.
590 */
591 public abstract GL getGL();
592
593 /**
594 * Sets the GL pipeline object for this GLContext.
595 *
596 * @return the set GL pipeline or null if not successful
597 */
598 public abstract GL setGL(GL gl);
599
600 /**
601 * Returns the underlying native OpenGL context handle
602 */
603 public final long getHandle() { return contextHandle; }
604
605 /**
606 * Indicates whether the underlying native OpenGL context has been created.
607 */
608 public final boolean isCreated() {
609 return 0 != contextHandle;
610 }
611
612 /**
613 * Returns the attached user object for the given name to this GLContext.
614 */
615 public final Object getAttachedObject(final String name) {
616 return attachedObjects.get(name);
617 }
618
619 /**
620 * Sets the attached user object for the given name to this GLContext.
621 * Returns the previously set object or null.
622 */
623 public final Object attachObject(final String name, final Object obj) {
624 return attachedObjects.put(name, obj);
625 }
626
627 public final Object detachObject(final String name) {
628 return attachedObjects.remove(name);
629 }
630
631 /**
632 * Classname, GL, GLDrawable
633 */
634 @Override
635 public String toString() {
636 final StringBuilder sb = new StringBuilder();
637 sb.append(getClass().getSimpleName());
638 sb.append(" [");
639 this.append(sb);
640 sb.append("] ");
641 return sb.toString();
642 }
643
644 public final StringBuilder append(final StringBuilder sb) {
645 sb.append("Version ").append(getGLVersion()).append(" [GL ").append(getGLVersionNumber()).append(", vendor ").append(getGLVendorVersionNumber());
646 sb.append("], options 0x");
647 sb.append(Integer.toHexString(ctxOptions));
648 sb.append(", this ");
649 sb.append(toHexString(hashCode()));
650 sb.append(", handle ");
651 sb.append(toHexString(contextHandle));
652 sb.append(", isShared "+isShared()+", ");
653 sb.append(getGL());
654 sb.append(",\n\t quirks: ");
655 if(null != glRendererQuirks) {
657 } else {
658 sb.append("n/a");
659 }
661 sb.append(",\n\tRead Drawable : ");
662 sb.append(getGLReadDrawable());
663 sb.append(",\n\tWrite Drawable: ");
664 sb.append(getGLDrawable());
665 } else {
666 sb.append(",\n\tDrawable: ");
667 sb.append(getGLDrawable());
668 }
669 return sb;
670 }
671
672 /**
673 * Returns true if the specified OpenGL core- or extension-function can be
674 * successfully called using this GL context given the current host (OpenGL
675 * <i>client</i>) and display (OpenGL <i>server</i>) configuration.
676 *
677 * See {@link GL#isFunctionAvailable(String)} for more details.
678 *
679 * @param glFunctionName the name of the OpenGL function (e.g., use
680 * "glPolygonOffsetEXT" or "glPolygonOffset" to check if the {@link
681 * com.jogamp.opengl.GL#glPolygonOffset(float,float)} is available).
682 */
683 public abstract boolean isFunctionAvailable(String glFunctionName);
684
685 /**
686 * Returns true if the specified OpenGL extension can be
687 * successfully called using this GL context given the current host (OpenGL
688 * <i>client</i>) and display (OpenGL <i>server</i>) configuration.
689 *
690 * See {@link GL#isExtensionAvailable(String)} for more details.
691 *
692 * @param glExtensionName the name of the OpenGL extension (e.g.,
693 * "GL_VERTEX_PROGRAM_ARB").
694 */
695 public abstract boolean isExtensionAvailable(String glExtensionName);
696
697 /** Returns the number of platform extensions */
698 public abstract int getPlatformExtensionCount();
699
700 /** Returns a non-null (but possibly empty) string containing the
701 space-separated list of available platform-dependent (e.g., WGL,
702 GLX) extensions. Can only be called while this context is
703 current. */
704 public abstract String getPlatformExtensionsString();
705
706 /** Returns the number of OpenGL extensions */
707 public abstract int getGLExtensionCount();
708
709 /** Returns a non-null (but possibly empty) string containing the
710 space-separated list of available extensions.
711 Can only be called while this context is current.
712 This is equivalent to
713 {@link com.jogamp.opengl.GL#glGetString(int) glGetString}({@link com.jogamp.opengl.GL#GL_EXTENSIONS GL_EXTENSIONS})
714 */
715 public abstract String getGLExtensionsString();
716
717 /**
718 * @return Additional context creation flags, supported: {@link GLContext#CTX_OPTION_DEBUG}.
719 */
720 public abstract int getContextCreationFlags();
721
722 /**
723 * @param flags Additional context creation flags, supported: {@link GLContext#CTX_OPTION_DEBUG}.
724 * Unsupported flags are masked out.
725 * Only affects this context state if not created yet via {@link #makeCurrent()}.
726 * @see #enableGLDebugMessage(boolean)
727 * @see GLAutoDrawable#setContextCreationFlags(int)
728 */
729 public abstract void setContextCreationFlags(int flags);
730
731 /**
732 * Returns a valid OpenGL version string, ie<br>
733 * <pre>
734 * major.minor ([option]?[options,]*) - gl-version
735 * </pre><br>
736 *
737 * <ul>
738 * <li> options
739 * <ul>
740 * <li> <code>ES profile</code> ES profile</li>
741 * <li> <code>Compatibility profile</code> Compatibility profile including fixed function pipeline and deprecated functionality</li>
742 * <li> <code>Core profile</code> Core profile</li>
743 * <li> <code>forward</code> Forward profile excluding deprecated functionality</li>
744 * <li> <code>arb</code> refers to an ARB_create_context created context</li>
745 * <li> <code>debug</code> refers to a debug context</li>
746 * <li> <code>ES2 compatible</code> refers to an ES2 compatible implementation</li>
747 * <li> <code>software</code> refers to a software implementation of the rasterizer</li>
748 * <li> <code>hardware</code> refers to a hardware implementation of the rasterizer</li>
749 * </ul></li>
750 * <li> <i>gl-version</i> the GL_VERSION string</li>
751 * </ul>
752 *
753 * e.g.:
754 * <table border="0">
755 * <tr> <td></td> <td></td> </tr>
756 * <tr>
757 * <td>row 2, cell 1</td>
758 * <td>row 2, cell 2</td>
759 * </tr>
760 * </table>
761 *
762 * <table border="0">
763 * <tr><td></td> <td>ES2</td> <td><code>2.0 (ES profile, ES2 compatible, hardware) - 2.0 ES Profile</code></td></tr>
764 * <tr><td>ATI</td><td>GL2</td> <td><code>3.0 (Compatibility profile, arb, hardware) - 3.2.9704 Compatibility Profile Context</code></td></tr>
765 * <tr><td>ATI</td><td>GL3</td> <td><code>3.3 (Core profile, any, new, hardware) - 1.4 (3.2.9704 Compatibility Profile Context)</code></td></tr>
766 * <tr><td>ATI</td><td>GL3bc</td><td><code>3.3 (Compatibility profile, arb, hardware) - 1.4 (3.2.9704 Compatibility Profile Context)</code></td></tr>
767 * <tr><td>NV</td><td>GL2</td> <td><code>3.0 (Compatibility profile, arb, hardware) - 3.0.0 NVIDIA 195.36.07.03</code></td></tr>
768 * <tr><td>NV</td><td>GL3</td> <td><code>3.3 (Core profile, arb, hardware) - 3.3.0 NVIDIA 195.36.07.03</code></td></tr>
769 * <tr><td>NV</td><td>GL3bc</td> <td><code>3.3 (Compatibility profile, arb, hardware) - 3.3.0 NVIDIA 195.36.07.03</code></td></tr>
770 * <tr><td>NV</td><td>GL2</td> <td><code>3.0 (Compatibility profile, arb, ES2 compatible, hardware) - 3.0.0 NVIDIA 290.10</code></td></tr>
771 * </table>
772 */
773 public final String getGLVersion() {
774 return ctxVersionString;
775 }
776
777 /**
778 * Returns this context OpenGL version.
779 * @see #getGLSLVersionNumber()
780 **/
781 public final VersionNumberString getGLVersionNumber() { return ctxVersion; }
782
783 /**
784 * Returns the vendor's version, i.e. version number at the end of <code>GL_VERSION</code> not being the GL version.
785 * <p>
786 * In case no such version exists within <code>GL_VERSION</code>,
787 * the {@link VersionNumberString#zeroVersion zero version} instance is returned.
788 * </p>
789 * <p>
790 * The vendor's version is usually the vendor's OpenGL driver version.
791 * </p>
792 */
793 public final VersionNumberString getGLVendorVersionNumber() { return ctxVendorVersion; }
794 public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); }
795 public final boolean isGLCoreProfile() { return ( 0 != ( CTX_PROFILE_CORE & ctxOptions ) ); }
796 public final boolean isGLESProfile() { return ( 0 != ( CTX_PROFILE_ES & ctxOptions ) ); }
797 public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); }
798 public final boolean isGLDebugEnabled() { return ( 0 != ( CTX_OPTION_DEBUG & ctxOptions ) ); }
799 public final boolean isCreatedWithARBMethod() { return ( 0 != ( CTX_IS_ARB_CREATED & ctxOptions ) ); }
800
801 /**
802 * Returns the matching GLSL version number, queried by this context GL
803 * via {@link GL2ES2#GL_SHADING_LANGUAGE_VERSION} if &ge; ES2.0 or GL2.0,
804 * otherwise a static match is being utilized.
805 * <p>
806 * The context must have been current once,
807 * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned.
808 * </p>
809 * <p>
810 * Examples w/ <code>major.minor</code>:
811 * <pre>
812 * 1.00 (ES 2.0), 3.00 (ES 3.0)
813 * 1.10 (GL 2.0), 1.20 (GL 2.1), 1.50 (GL 3.2),
814 * 3.30 (GL 3.3), 4.00 (GL 4.0), 4.10 (GL 4.1), 4.20 (GL 4.2)
815 * </pre >
816 * </p>
817 * <p>
818 * <i>Matching</i> could also refer to the maximum GLSL version usable by this context
819 * since <i>normal</i> GL implementations are capable of using a lower GLSL version as well.
820 * The latter is not true on OSX w/ a GL3 context.
821 * </p>
822 *
823 * @return GLSL version number if context has been made current at least once,
824 * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned.
825 *
826 * @see #getGLVersionNumber()
827 */
828 public final VersionNumberString getGLSLVersionNumber() {
829 return ctxGLSLVersion;
830 }
831
832 /**
833 * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n',
834 * i.e. for desktop
835 * <pre>
836 * #version 110
837 * ..
838 * #version 150 core
839 * #version 330 compatibility
840 * ...
841 * </pre>
842 * And for ES:
843 * <pre>
844 * #version 100
845 * #version 300 es
846 * ..
847 * </pre>
848 * <p>
849 * If context has not been made current yet, a string of zero length is returned.
850 * </p>
851 * @see #getGLSLVersionNumber()
852 */
853 public final String getGLSLVersionString() {
854 if( ctxGLSLVersion.isZero() ) {
855 return S_EMPTY;
856 }
857 final int minor = ctxGLSLVersion.getMinor();
858 final String profileOpt;
859 if( isGLES() ) {
860 profileOpt = ctxGLSLVersion.compareTo(Version3_0) >= 0 ? " es" : S_EMPTY;
861 } else if( isGLCoreProfile() ) {
862 profileOpt = ctxGLSLVersion.compareTo(Version1_50) >= 0 ? " core" : S_EMPTY;
863 } else if( isGLCompatibilityProfile() ) {
864 profileOpt = ctxGLSLVersion.compareTo(Version1_50) >= 0 ? " compatibility" : S_EMPTY;
865 } else {
866 throw new InternalError("Neither ES, Core nor Compat: "+this); // see validateProfileBits(..)
867 }
868 return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + profileOpt + "\n" ;
869 }
870
871 protected static final VersionNumberString getStaticGLSLVersionNumber(final int glMajorVersion, final int glMinorVersion, final int ctxOptions) {
872 if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) {
873 if( 3 == glMajorVersion ) {
874 switch ( glMinorVersion ) {
875 case 0: return new VersionNumberString(Version3_0, glsl_es_prefix+Version3_0.toString()); // ES 3.0 -> GLSL 3.00
876 case 1: return new VersionNumberString(Version3_10, glsl_es_prefix+Version3_10.toString()); // ES 3.1 -> GLSL 3.10
877 default: return new VersionNumberString(Version3_20, glsl_es_prefix+Version3_20.toString()); // ES 3.2 -> GLSL 3.20
878 }
879 } else if( 2 == glMajorVersion ) {
880 return new VersionNumberString(Version1_0, glsl_es_prefix+Version1_0.toString()); // ES 2.0 -> GLSL 1.00
881 }
882 } else if( 1 == glMajorVersion ) {
883 return new VersionNumberString(Version1_10, glsl_prefix+Version1_10.toString()); // GL 1.x -> GLSL 1.10
884 } else if( 2 == glMajorVersion ) {
885 switch ( glMinorVersion ) {
886 case 0: return new VersionNumberString(Version1_10, glsl_prefix+Version1_10.toString()); // GL 2.0 -> GLSL 1.10
887 default: return new VersionNumberString(Version1_20, glsl_prefix+Version1_20.toString()); // GL 2.1 -> GLSL 1.20
888 }
889 } else if( 3 == glMajorVersion && 2 >= glMinorVersion ) {
890 switch ( glMinorVersion ) {
891 case 0: return new VersionNumberString(Version1_30, glsl_prefix+Version1_30.toString()); // GL 3.0 -> GLSL 1.30
892 case 1: return new VersionNumberString(Version1_40, glsl_prefix+Version1_40.toString()); // GL 3.1 -> GLSL 1.40
893 default: return new VersionNumberString(Version1_50, glsl_prefix+Version1_50.toString()); // GL 3.2 -> GLSL 1.50
894 }
895 }
896 // The new default: GL >= 3.x, ES >= 3.x
897 final String prefix = 0 != ( CTX_PROFILE_ES & ctxOptions ) ? glsl_es_prefix : glsl_prefix;
898 final VersionNumber vn = new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N
899 return new VersionNumberString(vn, prefix+vn.toString()); // GL M.N -> GLSL M.N
900 }
901 private static final String glsl_prefix = "OpenGL GLSL ";
902 private static final String glsl_es_prefix = "OpenGL ES GLSL ES ";
903
904 /**
905 * @return true if this context is an ES2 context or implements
906 * the extension <code>GL_ARB_ES3_compatibility</code> or <code>GL_ARB_ES2_compatibility</code>, otherwise false
907 */
908 public final boolean isGLES2Compatible() {
909 return 0 != ( ctxOptions & ( CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ) ) ;
910 }
911
912 /**
913 * Return true if this context is an ES3 context or implements
914 * the extension <code>GL_ARB_ES3_compatibility</code>, otherwise false.
915 * <p>
916 * Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
917 * </p>
918 */
919 public final boolean isGLES3Compatible() {
920 return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ;
921 }
922
923 /**
924 * Return true if this context is an ES3 context &ge; 3.1 or implements
925 * the extension <code>GL_ARB_ES3_1_compatibility</code>, otherwise false.
926 * <p>
927 * Includes [ GL &ge; 4.5, GL &ge; 3.1 w/ GL_ARB_ES3_1_compatibility and GLES3 &ge; 3.1 ]
928 * </p>
929 */
930 public final boolean isGLES31Compatible() {
931 return 0 != ( ctxOptions & CTX_IMPL_ES31_COMPAT ) ;
932 }
933
934 /**
935 * Return true if this context is an ES3 context &ge; 3.2 or implements
936 * the extension <code>GL_ARB_ES3_2_compatibility</code>, otherwise false.
937 * <p>
938 * Includes [ GL &ge; 4.5, GL &ge; 3.1 w/ GL_ARB_ES3_2_compatibility and GLES3 &ge; 3.2 ]
939 * </p>
940 */
941 public final boolean isGLES32Compatible() {
942 return 0 != ( ctxOptions & CTX_IMPL_ES32_COMPAT ) ;
943 }
944
945 /**
946 * @return true if impl. is a hardware rasterizer, otherwise false.
947 * @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile)
948 * @see GLProfile#isHardwareRasterizer()
949 */
950 public final boolean isHardwareRasterizer() {
951 return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ;
952 }
953
954 /**
955 * @return true if context supports GLSL, i.e. is either {@link #isGLES3()}, {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} <i>and</i> major-version > 1.
956 * @see GLProfile#hasGLSL()
957 */
958 public final boolean hasGLSL() {
959 return isGLES3() ||
960 isGLES2() ||
961 isGL3() ||
962 isGL2() && ctxVersion.getMajor()>1 ;
963 }
964
965 /**
966 * Returns <code>true</code> if basic FBO support is available, otherwise <code>false</code>.
967 * <p>
968 * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= 3.0 [core, compat] or implements the extensions
969 * <code>GL_ARB_ES2_compatibility</code>, <code>GL_ARB_framebuffer_object</code>, <code>GL_EXT_framebuffer_object</code> or <code>GL_OES_framebuffer_object</code>.
970 * </p>
971 * <p>
972 * Basic FBO support may only include one color attachment and no multisampling,
973 * as well as limited internal formats for renderbuffer.
974 * </p>
975 * @see #CTX_IMPL_FBO
976 */
977 public final boolean hasBasicFBOSupport() {
978 return 0 != ( ctxOptions & CTX_IMPL_FBO ) ;
979 }
980
981 /**
982 * Returns <code>true</code> if full FBO support is available, otherwise <code>false</code>.
983 * <p>
984 * Full FBO is supported if the context is either GL >= 3.0 [ES, core, compat] or implements the extensions
985 * <code>ARB_framebuffer_object</code>, or all of
986 * <code>EXT_framebuffer_object</code>, <code>EXT_framebuffer_multisample</code>,
987 * <code>EXT_framebuffer_blit</code>, <code>GL_EXT_packed_depth_stencil</code>.
988 * </p>
989 * <p>
990 * Full FBO support includes multiple color attachments and multisampling.
991 * </p>
992 */
993 public final boolean hasFullFBOSupport() {
995 ( isGL3ES3() || // GL >= 3.0 [ES, core, compat]
996 isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object
997 ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object*
1001 )
1002 ) ;
1003 }
1004
1005 /**
1006 * Returns <code>true</code> if <code>OES_single_precision</code>, fp32, fixed function point (FFP) compatibility entry points available,
1007 * otherwise <code>false</code>.
1008 * @see #CTX_IMPL_FP32_COMPAT_API
1009 */
1010 public final boolean hasFP32CompatAPI() {
1011 return 0 != ( ctxOptions & CTX_IMPL_FP32_COMPAT_API ) ;
1012 }
1013
1014 /**
1015 * Returns the maximum number of FBO RENDERBUFFER samples
1016 * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false.
1017 */
1018 public final int getMaxRenderbufferSamples() {
1019 if( hasFullFBOSupport() ) {
1020 final GL gl = getGL();
1021 final int[] val = new int[] { 0 } ;
1022 try {
1023 gl.glGetIntegerv(GL.GL_MAX_SAMPLES, val, 0);
1024 final int glerr = gl.glGetError();
1025 if(GL.GL_NO_ERROR == glerr) {
1026 return val[0];
1027 } else if(DEBUG) {
1028 System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr));
1029 }
1030 } catch (final GLException gle) { gle.printStackTrace(); }
1031 }
1032 return 0;
1033 }
1034
1035 /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns <code>true</code>. */
1036 public boolean isNPOTTextureAvailable() {
1038 }
1039
1041 return isGL2GL3() ||
1044 }
1045
1046 /**
1047 * Indicates whether this GLContext is capable of GL4bc. <p>Includes [ GL4bc ].</p>
1048 * @see GLProfile#isGL4bc()
1049 */
1050 public final boolean isGL4bc() {
1051 return 0 != (ctxOptions & CTX_PROFILE_COMPAT) &&
1052 ctxVersion.getMajor() >= 4;
1053 }
1054
1055 /**
1056 * Indicates whether this GLContext is capable of GL4. <p>Includes [ GL4bc, GL4 ].</p>
1057 * @see GLProfile#isGL4()
1058 */
1059 public final boolean isGL4() {
1061 ctxVersion.getMajor() >= 4;
1062 }
1063
1064 /**
1065 * Indicates whether this GLContext uses a GL4 core profile. <p>Includes [ GL4 ].</p>
1066 */
1067 public final boolean isGL4core() {
1068 return 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
1069 ctxVersion.getMajor() >= 4;
1070 }
1071
1072 /**
1073 * Indicates whether this GLContext is capable of GL3bc. <p>Includes [ GL4bc, GL3bc ].</p>
1074 * @see GLProfile#isGL3bc()
1075 */
1076 public final boolean isGL3bc() {
1077 return 0 != (ctxOptions & CTX_PROFILE_COMPAT) &&
1078 ctxVersion.compareTo(Version3_1) >= 0 ;
1079 }
1080
1081 /**
1082 * Indicates whether this GLContext is capable of GL3. <p>Includes [ GL4bc, GL4, GL3bc, GL3 ].</p>
1083 * @see GLProfile#isGL3()
1084 */
1085 public final boolean isGL3() {
1087 ctxVersion.compareTo(Version3_1) >= 0 ;
1088 }
1089
1090 /**
1091 * Indicates whether this GLContext uses a GL3 core profile. <p>Includes [ GL4, GL3 ].</p>
1092 */
1093 public final boolean isGL3core() {
1094 return 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
1095 ctxVersion.compareTo(Version3_1) >= 0;
1096 }
1097
1098 /**
1099 * Indicates whether this GLContext uses a GL core profile. <p>Includes [ GL4, GL3, GLES3, GLES2 ].</p>
1100 */
1101 public final boolean isGLcore() {
1102 return ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ) ||
1103 ( 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
1104 ctxVersion.compareTo(Version3_1) >= 0
1105 ) ;
1106 }
1107
1108 /**
1109 * Indicates whether this GLContext allows CPU data sourcing (indices, vertices ..) as opposed to using a GPU buffer source (VBO),
1110 * e.g. {@link GL2#glDrawElements(int, int, int, java.nio.Buffer)}.
1111 * <p>Includes [GL2ES1, GLES2] == [ GL4bc, GL3bc, GL2, GLES1, GL2ES1, GLES2 ].</p>
1112 * <p>See Bug 852 - https://jogamp.org/bugzilla/show_bug.cgi?id=852 </p>
1113 */
1114 public final boolean isCPUDataSourcingAvail() {
1115 return isGL2ES1() || isGLES2();
1116 }
1117
1118 /**
1119 * Indicates whether this GLContext's native profile does not implement a <i>default vertex array object</i> (VAO),
1120 * starting w/ OpenGL 3.1 core.
1121 * <p>Includes [ GL4, GL3 ].</p>
1122 * <pre>
1123 Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296),
1124 GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331)
1125 there is no more default VAO buffer 0 bound, hence generating and binding one
1126 to avoid INVALID_OPERATION at VertexAttribPointer.
1127 More clear is GL 4.3 core spec: 10.4 (p 307).
1128 * </pre>
1129 * <pre>
1130 ES 3.x is <i>not</i> included here.
1131 Due to it's ES 2.0 backward compatibility it still supports the following features:
1132 <i>client side vertex arrays</i>
1133 <i>default vertex array object</i>
1134
1135 Binding a custom VAO with ES 3.0 would cause <i>client side vertex arrays</i> via {@link GL2ES1#glVertexPointer(int, int, int, java.nio.Buffer) glVertexPointer}
1136 to produce <code>GL_INVALID_OPERATION</code>.
1137
1138 However, they are marked <i>deprecated</i>:
1139 GL ES 3.0 spec F.1. Legacy Features (p 322).
1140 GL ES 3.1 spec F.1. Legacy Features (p 454).
1141 * </pre>
1142 * <p>
1143 * If no default VAO is implemented in the native OpenGL profile,
1144 * an own default VAO is being used, see {@link #getDefaultVAO()}.
1145 * </p>
1146 * @see #getDefaultVAO()
1147 */
1148 public final boolean hasNoDefaultVAO() {
1149 return // ES 3.x not included, see above. ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ) ||
1150 ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) &&
1151 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
1152 ctxVersion.compareTo(Version3_1) >= 0
1153 ) ;
1154 }
1155
1156 /**
1157 * If this GLContext does not implement a default VAO, see {@link #hasNoDefaultVAO()},
1158 * an <i>own default VAO</i> will be created and bound at context creation.
1159 * <p>
1160 * If this GLContext does implement a default VAO, i.e. {@link #hasNoDefaultVAO()}
1161 * returns <code>false</code>, this method returns <code>0</code>.
1162 * </p>
1163 * <p>
1164 * Otherwise this method returns the VAO object name
1165 * representing this GLContext's <i>own default VAO</i>.
1166 * </p>
1167 * @see #hasNoDefaultVAO()
1168 */
1169 public abstract int getDefaultVAO();
1170
1171 /**
1172 * Indicates whether this GLContext is capable of GL2. <p>Includes [ GL4bc, GL3bc, GL2 ].</p>
1173 * @see GLProfile#isGL2()
1174 */
1175 public final boolean isGL2() {
1176 return 0 != ( ctxOptions & CTX_PROFILE_COMPAT ) && ctxVersion.getMajor()>=1 ;
1177 }
1178
1179 /**
1180 * Indicates whether this GLContext is capable of GL2GL3. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].</p>
1181 * @see GLProfile#isGL2GL3()
1182 */
1183 public final boolean isGL2GL3() {
1184 return isGL2() || isGL3();
1185 }
1186
1187 /**
1188 * Indicates whether this GLContext is capable of GLES1. <p>Includes [ GLES1 ].</p>
1189 * @see GLProfile#isGLES1()
1190 */
1191 public final boolean isGLES1() {
1192 return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ;
1193 }
1194
1195 /**
1196 * Indicates whether this GLContext is capable of GLES2. <p>Includes [ GLES2, GLES3 ].</p>
1197 * @see GLProfile#isGLES2()
1198 */
1199 public final boolean isGLES2() {
1200 return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ;
1201 }
1202
1203 /**
1204 * Indicates whether this GLContext is capable of GLES3. <p>Includes [ GLES3 ].</p>
1205 * @see GLProfile#isGLES3()
1206 */
1207 public final boolean isGLES3() {
1208 return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ;
1209 }
1210
1211 /**
1212 * Indicates whether this GLContext is capable of GLES. <p>Includes [ GLES3, GLES1, GLES2 ].</p>
1213 * @see GLProfile#isGLES()
1214 */
1215 public final boolean isGLES() {
1216 return 0 != ( CTX_PROFILE_ES & ctxOptions ) ;
1217 }
1218
1219 /**
1220 * Indicates whether this GLContext is capable of GL2ES1. <p>Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].</p>
1221 * @see GLProfile#isGL2ES1()
1222 */
1223 public final boolean isGL2ES1() {
1224 return isGLES1() || isGL2();
1225 }
1226
1227 /**
1228 * Indicates whether this GLContext is capable of GL2ES2. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].</p>
1229 * @see GLProfile#isGL2ES2()
1230 */
1231 public final boolean isGL2ES2() {
1232 return isGLES2() || isGL2GL3();
1233 }
1234
1235 /**
1236 * Indicates whether this GLContext is capable of GL2ES3. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL3ES3, GL2, GL2GL3 ].</p>
1237 * @see GLProfile#isGL2ES3()
1238 * @see #isGL3ES3()
1239 * @see #isGL2GL3()
1240 */
1241 public final boolean isGL2ES3() {
1242 return isGL3ES3() || isGL2GL3();
1243 }
1244
1245 /**
1246 * Indicates whether this GLContext is capable of GL3ES3. <p>Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].</p>
1247 * @see GLProfile#isGL3ES3()
1248 */
1249 public final boolean isGL3ES3() {
1250 return isGL4ES3() || isGL3();
1251 }
1252
1253 /**
1254 * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true.
1255 * <p>Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]</p>
1256 * @see GLProfile#isGL4ES3()
1257 */
1258 public final boolean isGL4ES3() {
1259 return isGLES3Compatible() ;
1260 }
1261
1262 /**
1263 * Set the swap interval of the current context and attached <i>onscreen {@link GLDrawable}</i>.
1264 * <p>
1265 * <i>offscreen {@link GLDrawable}</i> are ignored and {@code false} is returned.
1266 * </p>
1267 * <p>
1268 * The {@code interval} semantics:
1269 * <ul>
1270 * <li><i>0</i> disables the vertical synchronization</li>
1271 * <li><i>&ge;1</i> is the number of vertical refreshes before a swap buffer occurs</li>
1272 * <li><i>&lt;0</i> enables <i>late swaps to occur without synchronization to the video frame</i>, a.k.a <i>EXT_swap_control_tear</i>.
1273 * If supported, the absolute value is the minimum number of
1274 * video frames between buffer swaps. If not supported, the absolute value is being used, see above.
1275 * </li>
1276 * </ul>
1277 * </p>
1278 * @param interval see above
1279 * @return true if the operation was successful, otherwise false
1280 * @throws GLException if the context is not current.
1281 * @see #getSwapInterval()
1282 */
1283 public /* abstract */ boolean setSwapInterval(final int interval) throws GLException {
1284 // FIXME: Make abstract for next version - just here to *not* break SEMVER!
1285 throw new InternalError("Implemented in GLContextImpl");
1286 }
1287 protected boolean setSwapIntervalImpl(final int interval) {
1288 // FIXME: Remove for next version - just here to *not* break SEMVER!
1289 throw new InternalError("Implemented in GLContextImpl");
1290 }
1291
1292 /**
1293 * Return the current swap interval.
1294 * <p>
1295 * If the context has not been made current at all,
1296 * the default value {@code 0} is returned.
1297 * </p>
1298 * <p>
1299 * For a valid context w/ an <o>onscreen {@link GLDrawable}</i> the default value is {@code 1},
1300 * otherwise the default value is {@code 0}.
1301 * </p>
1302 * @see #setSwapInterval(int)
1303 */
1304 public /* abstract */ int getSwapInterval() {
1305 // FIXME: Make abstract for next version - just here to *not* break SEMVER!
1306 throw new InternalError("Implemented in GLContextImpl");
1307 }
1308
1309 protected void setDefaultSwapInterval() {
1310 // FIXME: Remove for next version - just here to *not* break SEMVER!
1311 throw new InternalError("Implemented in GLContextImpl");
1312 }
1313
1314 public final boolean queryMaxSwapGroups(final int[] maxGroups, final int maxGroups_offset,
1315 final int[] maxBarriers, final int maxBarriers_offset) {
1317 return queryMaxSwapGroupsImpl(maxGroups, maxGroups_offset, maxBarriers, maxBarriers_offset);
1318 }
1319 protected boolean queryMaxSwapGroupsImpl(final int[] maxGroups, final int maxGroups_offset,
1320 final int[] maxBarriers, final int maxBarriers_offset) { return false; }
1321 public final boolean joinSwapGroup(final int group) {
1323 return joinSwapGroupImpl(group);
1324 }
1325 protected boolean joinSwapGroupImpl(final int group) { /** nop per default .. **/ return false; }
1326 protected int currentSwapGroup = -1; // default: not set yet ..
1327 public int getSwapGroup() {
1328 return currentSwapGroup;
1329 }
1330 public final boolean bindSwapBarrier(final int group, final int barrier) {
1332 return bindSwapBarrierImpl(group, barrier);
1333 }
1334 protected boolean bindSwapBarrierImpl(final int group, final int barrier) { /** nop per default .. **/ return false; }
1335
1336 /**
1337 * Return the framebuffer name bound to this context,
1338 * see {@link GL#glBindFramebuffer(int, int)}.
1339 * <p>
1340 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
1341 * </p>
1342 */
1343 public abstract int getBoundFramebuffer(int target);
1344
1345 /**
1346 * Return the default draw framebuffer name.
1347 * <p>
1348 * May differ from it's default <code>zero</code>
1349 * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
1350 * is being used.
1351 * </p>
1352 * <p>
1353 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
1354 * </p>
1355 */
1356 public abstract int getDefaultDrawFramebuffer();
1357
1358 /**
1359 * Return the default read framebuffer name.
1360 * <p>
1361 * May differ from it's default <code>zero</code>
1362 * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
1363 * is being used.
1364 * </p>
1365 * <p>
1366 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
1367 * </p>
1368 */
1369 public abstract int getDefaultReadFramebuffer();
1370
1371 /**
1372 * Returns the default color buffer within the current bound
1373 * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​,
1374 * which will be used as the target (output) for (fragment shader) draw commands,
1375 * settable via {@link GL2ES2#glDrawBuffers(int, int[], int)} or {@link GL2#glDrawBuffer(int)}.
1376 * <p>
1377 * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
1378 * otherwise this is {@link GL#GL_FRONT} for non-ES profile and single buffer configurations
1379 * and {@link GL#GL_BACK} for double buffer configurations or ES profiles.
1380 * </p>
1381 * <p>
1382 * Note-1: Neither ES1 nor ES2 supports selecting the draw buffer at all
1383 * and {@link GL#GL_BACK} is the default.
1384 * </p>
1385 * <p>
1386 * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
1387 * via {@link GL2ES2#glDrawBuffers(int, int[], int)}.
1388 * </p>
1389 * <p>
1390 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
1391 * </p>
1392 */
1393 public abstract int getDefaultDrawBuffer();
1394
1395 /**
1396 * Returns the default color buffer within the current bound
1397 * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​,
1398 * which will be used as the source for pixel reading commands,
1399 * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels} etc.
1400 * <p>
1401 * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
1402 * otherwise this is {@link GL#GL_FRONT} for non-ES profile and single buffer configurations
1403 * and {@link GL#GL_BACK} for double buffer configurations or ES profiles.
1404 * </p>
1405 * <p>
1406 * Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer
1407 * and {@link GL#GL_BACK} is the default.
1408 * </p>
1409 * <p>
1410 * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
1411 * </p>
1412 * <p>
1413 * Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
1414 * for read-pixels and swap-buffers implications.
1415 * </p>
1416 * <p>
1417 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
1418 * </p>
1419 */
1420 public abstract int getDefaultReadBuffer();
1421
1422 /**
1423 * Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}.
1424 * <p>
1425 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
1426 * </p>
1427 */
1428 public abstract int getDefaultPixelDataType();
1429
1430 /**
1431 * Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}.
1432 * <p>
1433 * Method is only thread-safe while context is {@link #makeCurrent() made current}.
1434 * </p>
1435 */
1436 public abstract int getDefaultPixelDataFormat();
1437
1438 /** Returns the DynamicLibraryBundle, matching context. */
1439 public abstract DynamicLibraryBundle getDynamicLibraryBundle();
1440
1441 /**
1442 * @return The extension implementing the GLDebugOutput feature,
1443 * either {@link GLExtensions#ARB_debug_output} or {@link GLExtensions#AMD_debug_output}.
1444 * If unavailable or called before initialized via {@link #makeCurrent()}, <i>null</i> is returned.
1445 */
1446 public abstract String getGLDebugMessageExtension();
1447
1448 /**
1449 * @return the current synchronous debug behavior, set via {@link #setGLDebugSynchronous(boolean)}.
1450 */
1451 public abstract boolean isGLDebugSynchronous();
1452
1453 /**
1454 * Enables or disables the synchronous debug behavior via
1455 * {@link GL2GL3#GL_DEBUG_OUTPUT_SYNCHRONOUS glEnable/glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS)},
1456 * if extension is {@link GLExtensions#ARB_debug_output}.
1457 * There is no equivalent for {@link GLExtensions#AMD_debug_output}.
1458 * <p> The default is <code>true</code>, ie {@link GL2GL3#GL_DEBUG_OUTPUT_SYNCHRONOUS}.</p>
1459 * @link {@link #isGLDebugSynchronous()}
1460 */
1461 public abstract void setGLDebugSynchronous(boolean synchronous);
1462
1463 /**
1464 * @return true if the GLDebugOutput feature is enabled or not.
1465 */
1466 public abstract boolean isGLDebugMessageEnabled();
1467
1468 /**
1469 * Enables or disables the GLDebugOutput feature of extension {@link GLExtensions#ARB_debug_output}
1470 * or {@link GLExtensions#AMD_debug_output}, if available.
1471 *
1472 * <p>To enable the GLDebugOutput feature {@link #enableGLDebugMessage(boolean) enableGLDebugMessage(true)}
1473 * or {@link #setContextCreationFlags(int) setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG})
1474 * shall be called <b>before</b> context creation via {@link #makeCurrent()}!</p>
1475 *
1476 * <p>In case {@link GLAutoDrawable} are being used,
1477 * {@link GLAutoDrawable#setContextCreationFlags(int) glAutoDrawable.setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG})
1478 * shall be issued before context creation via {@link #makeCurrent()}!</p>
1479 *
1480 * <p>After context creation, the GLDebugOutput feature may be enabled or disabled at any time using this method.</p>
1481 *
1482 * @param enable If true enables, otherwise disables the GLDebugOutput feature.
1483 *
1484 * @throws GLException if this context is not current or GLDebugOutput registration failed (enable)
1485 *
1486 * @see #setContextCreationFlags(int)
1487 * @see #addGLDebugListener(GLDebugListener)
1488 * @see GLAutoDrawable#setContextCreationFlags(int)
1489 */
1490 public abstract void enableGLDebugMessage(boolean enable) throws GLException;
1491
1492 /**
1493 * Add {@link GLDebugListener}.<br>
1494 *
1495 * @param listener {@link GLDebugListener} handling {@link GLDebugMessage}s
1496 * @see #enableGLDebugMessage(boolean)
1497 * @see #removeGLDebugListener(GLDebugListener)
1498 */
1499 public abstract void addGLDebugListener(GLDebugListener listener);
1500
1501 /**
1502 * Remove {@link GLDebugListener}.<br>
1503 *
1504 * @param listener {@link GLDebugListener} handling {@link GLDebugMessage}s
1505 * @see #enableGLDebugMessage(boolean)
1506 * @see #addGLDebugListener(GLDebugListener)
1507 */
1508 public abstract void removeGLDebugListener(GLDebugListener listener);
1509
1510 /**
1511 * Generic entry for {@link GL2GL3#glDebugMessageControl(int, int, int, int, IntBuffer, boolean)}
1512 * and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, IntBuffer, boolean)} of the GLDebugOutput feature.
1513 * @see #enableGLDebugMessage(boolean)
1514 */
1515 public abstract void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled);
1516
1517 /**
1518 * Generic entry for {@link GL2GL3#glDebugMessageControl(int, int, int, int, int[], int, boolean)}
1519 * and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, int[], int, boolean)} of the GLDebugOutput feature.
1520 * @see #enableGLDebugMessage(boolean)
1521 */
1522 public abstract void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled);
1523
1524 /**
1525 * Generic entry for {@link GL2GL3#glDebugMessageInsert(int, int, int, int, int, String)}
1526 * and {@link GL2GL3#glDebugMessageInsertAMD(int, int, int, int, String)} of the GLDebugOutput feature.
1527 * @see #enableGLDebugMessage(boolean)
1528 */
1529 public abstract void glDebugMessageInsert(int source, int type, int id, int severity, String buf);
1530
1531 public static final int GL_VERSIONS[][] = {
1532 /* 0.*/ { -1 },
1533 /* 1.*/ { 0, 1, 2, 3, 4, 5 },
1534 /* 2.*/ { 0, 1 },
1535 /* 3.*/ { 0, 1, 2, 3 },
1536 /* 4.*/ { 0, 1, 2, 3, 4, 5, 6 } };
1537
1538 public static final int ES_VERSIONS[][] = {
1539 /* 0.*/ { -1 },
1540 /* 1.*/ { 0, 1 },
1541 /* 2.*/ { 0 },
1542 /* 3.*/ { 0, 1, 2 } };
1543
1544 public static final int getMaxMajor(final int ctxProfile) {
1545 return ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ? ES_VERSIONS.length-1 : GL_VERSIONS.length-1;
1546 }
1547
1548 public static final int getMaxMinor(final int ctxProfile, final int major) {
1549 if( 1>major ) {
1550 return -1;
1551 }
1552 if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) {
1553 if( major>=ES_VERSIONS.length ) return -1;
1554 return ES_VERSIONS[major].length-1;
1555 } else {
1556 if( major>=GL_VERSIONS.length ) return -1;
1557 return GL_VERSIONS[major].length-1;
1558 }
1559 }
1560
1561 /**
1562 * Returns true, if the major.minor is not inferior to the lowest
1563 * valid version and does not exceed the highest known major number by more than one.
1564 * Otherwise returns false.
1565 * <p>
1566 * Returns false if more than one bit of the following list in {@code ctxProfile} is set
1567 * <ul>
1568 * <li>{@link GLContext#CTX_PROFILE_ES}</li>
1569 * <li>{@link GLContext#CTX_PROFILE_CORE}</li>
1570 * <li>{@link GLContext#CTX_PROFILE_COMPAT}</li>
1571 * </ul>
1572 * </p>
1573 * <p>
1574 * The minor version number is ignored by the upper limit validation
1575 * and the major version number may exceed by one.
1576 * </p>
1577 * <p>
1578 * The upper limit check is relaxed since we don't want to cut-off
1579 * unforseen new GL version since the release of JOGL.
1580 * </p>
1581 * <p>
1582 * Hence it is important to iterate through GL version from the upper limit
1583 * and {@link #decrementGLVersion(int, int[], int[])} until invalid.
1584 * </p>
1585 */
1586 public static final boolean isValidGLVersion(final int ctxProfile, final int major, final int minor) {
1587 if( 1>major || 0>minor ) {
1588 return false;
1589 }
1590 if ( 1 < Bitfield.Util.bitCount( ctxProfile & ( CTX_PROFILE_ES | CTX_PROFILE_CORE | CTX_PROFILE_COMPAT ) ) ) {
1591 return false;
1592 }
1593 if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
1594 if( major >= ES_VERSIONS.length + 1 ) return false;
1595 } else {
1596 if( major>=GL_VERSIONS.length + 1 ) return false;
1597 }
1598 return true;
1599 }
1600
1601 /**
1602 * Clip the given GL version to the maximum known valid version if exceeding.
1603 * @return true if clipped, i.e. given value exceeds maximum, otherwise false.
1604 */
1605 public static final boolean clipGLVersion(final int ctxProfile, final int major[], final int minor[]) {
1606 final int m = major[0];
1607 final int n = minor[0];
1608
1609 if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
1610 if( m >= ES_VERSIONS.length ) {
1611 major[0] = ES_VERSIONS.length - 1;
1612 minor[0] = ES_VERSIONS[major[0]].length - 1;
1613 return true;
1614 }
1615 if( n >= ES_VERSIONS[m].length ) {
1616 minor[0] = ES_VERSIONS[m].length - 1;
1617 return true;
1618 }
1619 } else if( m >= GL_VERSIONS.length ) { // !isES
1620 major[0] = GL_VERSIONS.length - 1;
1621 minor[0] = GL_VERSIONS[major[0]].length - 1;
1622 return true;
1623 } else if( n >= GL_VERSIONS[m].length ) { // !isES
1624 minor[0] = GL_VERSIONS[m].length - 1;
1625 return true;
1626 }
1627 return false;
1628 }
1629
1630 /**
1631 * Decrement the given GL version by one
1632 * and return true if still valid, otherwise false.
1633 * <p>
1634 * If the given version exceeds the maximum known valid version,
1635 * it is {@link #clipGLVersion(int, int[], int[]) clipped} and
1636 * true is returned.
1637 * </p>
1638 *
1639 * @param ctxProfile
1640 * @param major
1641 * @param minor
1642 * @return
1643 */
1644 public static final boolean decrementGLVersion(final int ctxProfile, final int major[], final int minor[]) {
1645 if( !clipGLVersion(ctxProfile, major, minor) ) {
1646 int m = major[0];
1647 int n = minor[0] - 1;
1648 if(n < 0) {
1649 if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
1650 if( m >= 3 ) {
1651 m -= 1;
1652 } else {
1653 m = 0; // major decr [1,2] -> 0
1654 }
1655 n = ES_VERSIONS[m].length-1;
1656 } else {
1657 m -= 1;
1658 n = GL_VERSIONS[m].length-1;
1659 }
1660 }
1661 if( !isValidGLVersion(ctxProfile, m, n) ) {
1662 return false;
1663 }
1664 major[0]=m;
1665 minor[0]=n;
1666 }
1667 return true;
1668 }
1669
1670 protected static int composeBits(final int a8, final int b8, final int c16) {
1671 return ( ( a8 & 0x000000FF ) << 24 ) |
1672 ( ( b8 & 0x000000FF ) << 16 ) |
1673 ( ( c16 & 0x0000FFFF ) ) ;
1674 }
1675 protected static VersionNumber decomposeBits(final int bits32, final int[] ctp) {
1676 final int major = ( bits32 & 0xFF000000 ) >>> 24 ;
1677 final int minor = ( bits32 & 0x00FF0000 ) >>> 16 ;
1678 ctp[0] = ( bits32 & 0x0000FFFF ) ;
1679 return new VersionNumber(major, minor, 0);
1680 }
1681 protected static int getCTPFromBits(final int bits32) {
1682 return ( bits32 & 0x0000FFFF );
1683 }
1684
1685 protected static void validateProfileBits(final int bits, final String argName) {
1686 int num = 0;
1687 if( 0 != ( CTX_PROFILE_COMPAT & bits ) ) { num++; }
1688 if( 0 != ( CTX_PROFILE_CORE & bits ) ) { num++; }
1689 if( 0 != ( CTX_PROFILE_ES & bits ) ) { num++; }
1690 if(1!=num) {
1691 throw new GLException("Internal Error: "+argName+": 1 != num-profiles: "+num);
1692 }
1693 }
1694
1695 //
1696 // version mapping
1697 //
1698
1699 /**
1700 * @see #getDeviceVersionAvailableKey(com.jogamp.nativewindow.AbstractGraphicsDevice, int, int)
1701 */
1702 protected static final IdentityHashMap<String, Integer> deviceVersionAvailable = new IdentityHashMap<String, Integer>();
1703
1704 /**
1705 * @see #getUniqueDeviceString(com.jogamp.nativewindow.AbstractGraphicsDevice)
1706 */
1707 private static final IdentityHashMap<String, String> deviceVersionsAvailableSet = new IdentityHashMap<String, String>();
1708
1709 /** clears the device/context mappings as well as the GL/GLX proc address tables. */
1710 protected static void shutdown() {
1711 deviceVersionAvailable.clear();
1712 deviceVersionsAvailableSet.clear();
1713 GLContextImpl.shutdownImpl(); // well ..
1714 }
1715
1716 protected static boolean getAvailableGLVersionsSet(final AbstractGraphicsDevice device) {
1717 synchronized ( deviceVersionsAvailableSet ) {
1718 return deviceVersionsAvailableSet.containsKey(device.getUniqueID());
1719 }
1720 }
1721
1722 protected static void setAvailableGLVersionsSet(final AbstractGraphicsDevice device, final boolean set) {
1723 synchronized ( deviceVersionsAvailableSet ) {
1724 final String devKey = device.getUniqueID();
1725 if( set ) {
1726 deviceVersionsAvailableSet.put(devKey, devKey);
1727 } else {
1728 deviceVersionsAvailableSet.remove(devKey);
1729 }
1730 if (DEBUG) {
1731 System.err.println(getThreadName() + ": createContextARB-MapGLVersions SET "+devKey);
1732 System.err.println(GLContext.dumpAvailableGLVersions(null).toString());
1733 }
1734 }
1735 }
1736
1737 /**
1738 * Returns a unique String object using {@link String#intern()} for the given arguments,
1739 * which object reference itself can be used as a key.
1740 */
1741 protected static String getDeviceVersionAvailableKey(final AbstractGraphicsDevice device, final int major, final int profile) {
1742 final String r = device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0));
1743 return r.intern();
1744 }
1745
1746 protected static StringBuilder dumpAvailableGLVersions(StringBuilder sb) {
1747 if(null == sb) {
1748 sb = new StringBuilder();
1749 }
1750 synchronized(deviceVersionAvailable) {
1751 final Set<String> keys = deviceVersionAvailable.keySet();
1752 boolean needsSeparator = false;
1753 for(final Iterator<String> keyI = keys.iterator(); keyI.hasNext(); ) {
1754 if(needsSeparator) {
1755 sb.append(Platform.getNewline());
1756 }
1757 final String key = keyI.next();
1758 sb.append("MapGLVersions ").append(key).append(": ");
1759 final Integer valI = deviceVersionAvailable.get(key);
1760 if(null != valI) {
1761 final int[] ctp = { 0 };
1762 final VersionNumber version = decomposeBits(valI.intValue(), ctp);
1763 GLContext.getGLVersion(sb, version, ctp[0], null);
1764 } else {
1765 sb.append("n/a");
1766 }
1767 needsSeparator = true;
1768 }
1769 }
1770 return sb;
1771 }
1772
1773 /**
1774 * @param device the device to request whether the profile is available for
1775 * @param reqMajor Key Value either 1, 2, 3 or 4
1776 * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
1777 * @return the available GL version as encoded with {@link #composeBits(int, int, int), otherwise <code>null</code>
1778 */
1779 protected static Integer getAvailableGLVersion(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile) {
1780 final String objectKey = getDeviceVersionAvailableKey(device, reqMajor, reqProfile);
1781 Integer val;
1782 synchronized(deviceVersionAvailable) {
1783 val = deviceVersionAvailable.get( objectKey );
1784 }
1785 return val;
1786 }
1787
1788 /**
1789 * @param reqMajor Key Value either 1, 2, 3 or 4
1790 * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
1791 * @param major if not null, returns the used major version
1792 * @param minor if not null, returns the used minor version
1793 * @param ctp if not null, returns the used context profile
1794 */
1795 protected static boolean getAvailableGLVersion(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile,
1796 final int[] major, final int minor[], final int ctp[]) {
1797
1798 final Integer valI = getAvailableGLVersion(device, reqMajor, reqProfile);
1799 if(null==valI) {
1800 return false;
1801 }
1802
1803 final int bits32 = valI.intValue();
1804
1805 if(null!=major) {
1806 major[0] = ( bits32 & 0xFF000000 ) >>> 24 ;
1807 }
1808 if(null!=minor) {
1809 minor[0] = ( bits32 & 0x00FF0000 ) >>> 16 ;
1810 }
1811 if(null!=ctp) {
1812 ctp[0] = ( bits32 & 0x0000FFFF ) ;
1813 }
1814 return true;
1815 }
1816
1817 /**
1818 * returns the highest GLProfile string regarding the implementation version and context profile bits.
1819 * @throws GLException if version and context profile bits could not be mapped to a GLProfile
1820 */
1821 protected static String getGLProfile(final int major, final int minor, final int ctp)
1822 throws GLException {
1823 if(0 != ( CTX_PROFILE_COMPAT & ctp )) {
1824 if(major >= 4) { return GLProfile.GL4bc; }
1825 else if(major == 3 && minor >= 1) { return GLProfile.GL3bc; }
1826 else { return GLProfile.GL2; }
1827 } else if(0 != ( CTX_PROFILE_CORE & ctp )) {
1828 if(major >= 4) { return GLProfile.GL4; }
1829 else if(major == 3 && minor >= 1) { return GLProfile.GL3; }
1830 } else if(0 != ( CTX_PROFILE_ES & ctp )) {
1831 if(major == 3) { return GLProfile.GLES3; }
1832 else if(major == 2) { return GLProfile.GLES2; }
1833 else if(major == 1) { return GLProfile.GLES1; }
1834 }
1835 throw new GLException("Unhandled OpenGL version/profile: "+GLContext.getGLVersion(major, minor, ctp, null));
1836 }
1837
1838 /**
1839 * Returns the GLProfile's major version number at reqMajorCTP[0] and it's context property (CTP) at reqMajorCTP[1] for availability mapping request.
1840 */
1841 protected static final void getRequestMajorAndCompat(final GLProfile glp, final int[/*2*/] reqMajorCTP) {
1842 final GLProfile glpImpl = glp.getImpl();
1843 if( glpImpl.isGL4() ) {
1844 reqMajorCTP[0]=4;
1845 } else if ( glpImpl.isGL3() || glpImpl.isGLES3() ) {
1846 reqMajorCTP[0]=3;
1847 } else if (glpImpl.isGLES1()) {
1848 reqMajorCTP[0]=1;
1849 } else /* if (glpImpl.isGL2() || glpImpl.isGLES2()) */ {
1850 reqMajorCTP[0]=2;
1851 }
1852 if( glpImpl.isGLES() ) {
1853 reqMajorCTP[1]=CTX_PROFILE_ES;
1854 } else if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc
1855 reqMajorCTP[1]=CTX_PROFILE_COMPAT;
1856 } else {
1857 reqMajorCTP[1]=CTX_PROFILE_CORE;
1858 }
1859 }
1860
1861 /**
1862 * @param device the device the context profile is being requested for
1863 * @param GLProfile the GLProfile the context profile is being requested for
1864 * @return the GLProfile's context property (CTP) if available, otherwise <code>0</code>
1865 */
1866 protected static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp) {
1867 final int[] reqMajorCTP = new int[] { 0, 0 };
1868 getRequestMajorAndCompat(glp, reqMajorCTP);
1869
1870 final int _major[] = { 0 };
1871 final int _minor[] = { 0 };
1872 final int _ctp[] = { 0 };
1873 if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) {
1874 return _ctp[0];
1875 }
1876 return 0; // n/a
1877 }
1878
1879 /**
1880 * @param device the device the profile is being requested
1881 * @param major Key Value either 1, 2, 3 or 4
1882 * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
1883 * @return the highest GLProfile for the device regarding availability, version and profile bits.
1884 */
1885 protected static GLProfile getAvailableGLProfile(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile)
1886 throws GLException {
1887 final String glpName = getAvailableGLProfileName(device, reqMajor, reqProfile);
1888 return null != glpName ? GLProfile.get(device, glpName) : null;
1889 }
1890
1891 /**
1892 * @param device the device the profile is being requested
1893 * @param major Key Value either 1, 2, 3 or 4
1894 * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
1895 * @return the highest GLProfile name for the device regarding availability, version and profile bits.
1896 */
1897 /* package */ static String getAvailableGLProfileName(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile)
1898 throws GLException {
1899 final int major[] = { 0 };
1900 final int minor[] = { 0 };
1901 final int ctp[] = { 0 };
1902 if(GLContext.getAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp)) {
1903 return GLContext.getGLProfile(major[0], minor[0], ctp[0]);
1904 }
1905 return null;
1906 }
1907
1908 /**
1909 * @param device the device the profile is being requested
1910 * @param major Key Value either 1, 2, 3 or 4
1911 * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
1912 */
1913 protected static String getAvailableGLVersionAsString(final AbstractGraphicsDevice device, final int major, final int profile) {
1914 final int _major[] = { 0 };
1915 final int _minor[] = { 0 };
1916 final int _ctp[] = { 0 };
1917 if(getAvailableGLVersion(device, major, profile, _major, _minor, _ctp)) {
1918 return getGLVersion(_major[0], _minor[0], _ctp[0], null);
1919 }
1920 return null;
1921 }
1922
1923 /**
1924 * Returns true if it is possible to create an <i>framebuffer object</i> (FBO).
1925 * <p>
1926 * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent.
1927 * </p>
1928 * <p>
1929 * FBO support is queried as described in {@link #hasBasicFBOSupport()}.
1930 * </p>
1931 *
1932 * @param device the device to request whether FBO is available for
1933 * @param glp {@link GLProfile} to check for FBO capabilities
1934 * @see GLContext#hasBasicFBOSupport()
1935 */
1936 public static final boolean isFBOAvailable(final AbstractGraphicsDevice device, final GLProfile glp) {
1937 return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) );
1938 }
1939
1940 /**
1941 * @return <code>1</code> if using a hardware rasterizer, <code>0</code> if using a software rasterizer and <code>-1</code> if not determined yet.
1942 * @see GLContext#isHardwareRasterizer()
1943 * @see GLProfile#isHardwareRasterizer()
1944 */
1945 public static final int isHardwareRasterizer(final AbstractGraphicsDevice device, final GLProfile glp) {
1946 final int r;
1947 final int ctp = getAvailableContextProperties(device, glp);
1948 if(0 == ctp) {
1949 r = -1;
1950 } else if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctp ) ) {
1951 r = 1;
1952 } else {
1953 r = 0;
1954 }
1955 return r;
1956 }
1957
1958 /**
1959 * @param device the device to request whether the profile is available for
1960 * @param reqMajor Key Value either 1, 2, 3 or 4
1961 * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
1962 * @param isHardware return value of one boolean, whether the profile is a hardware rasterizer or not
1963 * @return true if the requested GL version is available regardless of a software or hardware rasterizer, otherwise false.
1964 */
1965 protected static boolean isGLVersionAvailable(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile, final boolean isHardware[]) {
1966 final Integer valI = getAvailableGLVersion(device, reqMajor, reqProfile);
1967 if(null==valI) {
1968 return false;
1969 }
1970 isHardware[0] = 0 == ( valI.intValue() & GLContext.CTX_IMPL_ACCEL_SOFT ) ;
1971 return true;
1972 }
1973
1974 public static boolean isGLES1Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
1975 return isGLVersionAvailable(device, 1, GLContext.CTX_PROFILE_ES, isHardware);
1976 }
1977
1978 public static boolean isGLES2Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
1979 return isGLVersionAvailable(device, 2, GLContext.CTX_PROFILE_ES, isHardware);
1980 }
1981
1982 public static boolean isGLES3Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
1983 return isGLVersionAvailable(device, 3, GLContext.CTX_PROFILE_ES, isHardware);
1984 }
1985
1986 private static final int getGL3ctp(final AbstractGraphicsDevice device) {
1987 final int major[] = { 0 };
1988 final int minor[] = { 0 };
1989 final int ctp[] = { 0 };
1990 boolean ok;
1991
1992 ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp);
1993 if( !ok ) {
1994 ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp);
1995 }
1996 if( !ok ) {
1997 GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_COMPAT, major, minor, ctp);
1998 }
1999 return ctp[0];
2000 }
2001
2002 /**
2003 * Returns true if a ES3 compatible profile is available,
2004 * i.e. either a &ge; 4.3 context or a &ge; 3.1 context supporting <code>GL_ARB_ES3_compatibility</code>,
2005 * otherwise false.
2006 * <p>
2007 * Includes [ GL &ge; 4.3, GL &ge; 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
2008 * </p>
2009 */
2010 public static final boolean isGLES3CompatibleAvailable(final AbstractGraphicsDevice device) {
2011 return 0 != ( getGL3ctp(device) & CTX_IMPL_ES3_COMPAT );
2012 }
2013 /**
2014 * Returns true if a ES3 &ge; 3.1 compatible profile is available,
2015 * i.e. either a &ge; 4.5 context or a &ge; 3.1 context supporting <code>GL_ARB_ES3_1_compatibility</code>,
2016 * otherwise false.
2017 * <p>
2018 * Includes [ GL &ge; 4.5, GL &ge; 3.1 w/ GL_ARB_ES3_1_compatibility and GLES3 &ge; 3.1 ]
2019 * </p>
2020 */
2021 public static final boolean isGLES31CompatibleAvailable(final AbstractGraphicsDevice device) {
2022 return 0 != ( getGL3ctp(device) & CTX_IMPL_ES31_COMPAT );
2023 }
2024 /**
2025 * Returns true if a ES3 &ge; 3.2 compatible profile is available,
2026 * i.e. either a &ge; 4.5 context or a &ge; 3.1 context supporting <code>GL_ARB_ES3_2_compatibility</code>,
2027 * otherwise false.
2028 * <p>
2029 * Includes [ GL &ge; 4.5, GL &ge; 3.1 w/ GL_ARB_ES3_2_compatibility and GLES3 &ge; 3.2 ]
2030 * </p>
2031 */
2032 public static final boolean isGLES32CompatibleAvailable(final AbstractGraphicsDevice device) {
2033 return 0 != ( getGL3ctp(device) & CTX_IMPL_ES32_COMPAT );
2034 }
2035
2036 public static boolean isGL4bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[]) {
2037 return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware);
2038 }
2039
2040 public static boolean isGL4Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
2041 return isGLVersionAvailable(device, 4, CTX_PROFILE_CORE, isHardware);
2042 }
2043
2044 public static boolean isGL3bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[]) {
2045 return isGLVersionAvailable(device, 3, CTX_PROFILE_COMPAT, isHardware);
2046 }
2047
2048 public static boolean isGL3Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
2049 return isGLVersionAvailable(device, 3, CTX_PROFILE_CORE, isHardware);
2050 }
2051
2052 public static boolean isGL2Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
2053 return isGLVersionAvailable(device, 2, CTX_PROFILE_COMPAT, isHardware);
2054 }
2055
2056 protected static StringBuilder getGLProfile(final StringBuilder sb, final int ctp) {
2057 boolean needColon = false;
2058 needColon = appendString(sb, "ES profile", needColon, 0 != ( CTX_PROFILE_ES & ctp ));
2059 needColon = appendString(sb, "Compat profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp ));
2060 needColon = appendString(sb, "Core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp ));
2061 needColon = appendString(sb, "forward", needColon, 0 != ( CTX_OPTION_FORWARD & ctp ));
2062 needColon = appendString(sb, "arb", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp ));
2063 needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp ));
2064 needColon = appendString(sb, "compat[", needColon, true);
2065 {
2066 needColon = false;
2067 needColon = appendString(sb, "ES2", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp ));
2068 needColon = appendString(sb, "ES3", needColon, 0 != ( CTX_IMPL_ES3_COMPAT & ctp ));
2069 needColon = appendString(sb, "ES31", needColon, 0 != ( CTX_IMPL_ES31_COMPAT & ctp ));
2070 needColon = appendString(sb, "ES32", needColon, 0 != ( CTX_IMPL_ES32_COMPAT & ctp ));
2071 needColon = appendString(sb, "FP32", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp ));
2072 needColon = false;
2073 }
2074 needColon = appendString(sb, "]", needColon, true);
2075 needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp ));
2076 if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) {
2077 needColon = appendString(sb, "software", needColon, true);
2078 } else {
2079 needColon = appendString(sb, "hardware", needColon, true);
2080 }
2081 return sb;
2082 }
2083 protected static StringBuilder getGLVersion(final StringBuilder sb, final VersionNumber version, final int ctp, final String gl_version) {
2084 return getGLVersion(sb, version.getMajor(), version.getMinor(), ctp, gl_version);
2085 }
2086 protected static StringBuilder getGLVersion(final StringBuilder sb, final int major, final int minor, final int ctp, final String gl_version) {
2087 sb.append(major);
2088 sb.append(".");
2089 sb.append(minor);
2090 sb.append(" (");
2091 getGLProfile(sb, ctp);
2092 sb.append(")");
2093 if(null!=gl_version) {
2094 sb.append(" - ");
2095 sb.append(gl_version);
2096 }
2097 return sb;
2098 }
2099 protected static String getGLVersion(final int major, final int minor, final int ctp, final String gl_version) {
2100 return getGLVersion(new StringBuilder(), major, minor, ctp, gl_version).toString();
2101 }
2102
2103 //
2104 // internal string utils
2105 //
2106
2107 protected static String toHexString(final int hex) {
2108 return "0x" + Integer.toHexString(hex);
2109 }
2110
2111 protected static String toHexString(final long hex) {
2112 return "0x" + Long.toHexString(hex);
2113 }
2114
2115 private static boolean appendString(final StringBuilder sb, final String string, boolean needColon, final boolean condition) {
2116 if(condition) {
2117 if(needColon) {
2118 sb.append(", ");
2119 }
2120 sb.append(string);
2121 needColon=true;
2122 }
2123 return needColon;
2124 }
2125
2126 protected static String getThreadName() { return Thread.currentThread().getName(); }
2127
2128}
2129
Abstraction for an OpenGL rendering context.
Definition: GLContext.java:74
final boolean isShared()
Returns true if this GLContext is shared, otherwise false.
Definition: GLContext.java:265
static final boolean decrementGLVersion(final int ctxProfile, final int major[], final int minor[])
Decrement the given GL version by one and return true if still valid, otherwise false.
abstract void copy(GLContext source, int mask)
Copies selected groups of OpenGL state variables from the supplied source context into this one.
final boolean isGLES()
Indicates whether this GLContext is capable of GLES.
boolean bindSwapBarrierImpl(final int group, final int barrier)
final boolean isGLES31Compatible()
Return true if this context is an ES3 context ≥ 3.1 or implements the extension GL_ARB_ES3_1_compatib...
Definition: GLContext.java:930
final boolean isGLForwardCompatible()
Definition: GLContext.java:797
static final boolean isGLES3CompatibleAvailable(final AbstractGraphicsDevice device)
Returns true if a ES3 compatible profile is available, i.e.
abstract int getBoundFramebuffer(int target)
Return the framebuffer name bound to this context, see GL#glBindFramebuffer(int, int).
static final int CTX_IMPL_FP32_COMPAT_API
Context supports OES_single_precision, fp32, fixed function point (FFP) compatibility entry points,...
Definition: GLContext.java:219
final StringBuilder append(final StringBuilder sb)
Definition: GLContext.java:644
static final VersionNumber Version4_3
Version 4.3.
Definition: GLContext.java:157
static final boolean isValidGLVersion(final int ctxProfile, final int major, final int minor)
Returns true, if the major.minor is not inferior to the lowest valid version and does not exceed the ...
abstract GLDrawable getGLDrawable()
Returns the write-drawable this context uses for framebuffer operations.
abstract void setContextCreationFlags(int flags)
VersionNumberString ctxVersion
Definition: GLContext.java:235
static final int CONTEXT_NOT_CURRENT
Indicates that the context was not made current during the last call to makeCurrent,...
Definition: GLContext.java:112
final boolean isGL2()
Indicates whether this GLContext is capable of GL2.
boolean queryMaxSwapGroupsImpl(final int[] maxGroups, final int maxGroups_offset, final int[] maxBarriers, final int maxBarriers_offset)
static final VersionNumber Version1_0
Version 1.00, i.e.
Definition: GLContext.java:119
abstract int getDefaultReadBuffer()
Returns the default color buffer within the current bound getDefaultReadFramebuffer(),...
final boolean isGLDebugEnabled()
Definition: GLContext.java:798
static final int CTX_IMPL_ES2_COMPAT
GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2.
Definition: GLContext.java:193
static GLContext getCurrent()
Returns this thread current context.
Definition: GLContext.java:519
static final int CTX_IMPL_CACHE_MASK
Context option bits, cached bit mask covering 10 bits [0..9], i.e.
Definition: GLContext.java:171
static GLProfile getAvailableGLProfile(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile)
final boolean isGL4bc()
Indicates whether this GLContext is capable of GL4bc.
static StringBuilder dumpAvailableGLVersions(StringBuilder sb)
static String toHexString(final int hex)
abstract int makeCurrent()
Makes this GLContext current on the calling thread.
static final VersionNumber Version1_10
Version 1.10, i.e.
Definition: GLContext.java:121
static final boolean isGLES31CompatibleAvailable(final AbstractGraphicsDevice device)
Returns true if a ES3 ≥ 3.1 compatible profile is available, i.e.
final boolean isCreated()
Indicates whether the underlying native OpenGL context has been created.
Definition: GLContext.java:608
boolean isTextureFormatBGRA8888Available()
final String getGLSLVersionString()
Returns the matching GLSL version number, queried by this context GL via GL2ES2#GL_SHADING_LANGUAGE_V...
Definition: GLContext.java:853
static void validateProfileBits(final int bits, final String argName)
static int composeBits(final int a8, final int b8, final int c16)
abstract boolean isGLDebugMessageEnabled()
abstract boolean isGLDebugSynchronous()
VersionNumberString ctxVendorVersion
Definition: GLContext.java:238
final boolean hasFullFBOSupport()
Returns true if full FBO support is available, otherwise false.
Definition: GLContext.java:993
static final boolean DEBUG_TRACE_SWITCH
Definition: GLContext.java:78
static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp)
abstract int getDefaultDrawFramebuffer()
Return the default draw framebuffer name.
static final int CONTEXT_CURRENT
Indicates that the context was made current during the last call to makeCurrent, value {@value}.
Definition: GLContext.java:114
static boolean isGL3Available(final AbstractGraphicsDevice device, final boolean isHardware[])
static StringBuilder getGLProfile(final StringBuilder sb, final int ctp)
static final VersionNumber Version1_30
Version 1.30, i.e.
Definition: GLContext.java:125
static String getGLProfile(final int major, final int minor, final int ctp)
returns the highest GLProfile string regarding the implementation version and context profile bits.
final boolean joinSwapGroup(final int group)
static final int CTX_PROFILE_COMPAT
ARB_create_context related: desktop compatibility profile.
Definition: GLContext.java:176
final boolean isGL2GL3()
Indicates whether this GLContext is capable of GL2GL3.
final int getMaxRenderbufferSamples()
Returns the maximum number of FBO RENDERBUFFER samples if full FBO is supported, otherwise false.
final boolean isGLES32Compatible()
Return true if this context is an ES3 context ≥ 3.2 or implements the extension GL_ARB_ES3_2_compatib...
Definition: GLContext.java:941
static final boolean clipGLVersion(final int ctxProfile, final int major[], final int minor[])
Clip the given GL version to the maximum known valid version if exceeding.
static Integer getAvailableGLVersion(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile)
abstract void addGLDebugListener(GLDebugListener listener)
Add GLDebugListener.
static String getDeviceVersionAvailableKey(final AbstractGraphicsDevice device, final int major, final int profile)
Returns a unique String object using String#intern() for the given arguments, which object reference ...
abstract GL setGL(GL gl)
Sets the GL pipeline object for this GLContext.
final GLContext getSharedMaster()
Returns the shared master GLContext of this GLContext if shared, otherwise return null.
Definition: GLContext.java:276
final List< GLContext > getDestroyedShares()
Returns a new list of destroyed GLContext shared with this GLContext.
Definition: GLContext.java:286
static boolean isGLES2Available(final AbstractGraphicsDevice device, final boolean isHardware[])
final boolean isGL4core()
Indicates whether this GLContext uses a GL4 core profile.
final boolean isGL3()
Indicates whether this GLContext is capable of GL3.
static final VersionNumber Version1_20
Version 1.20, i.e.
Definition: GLContext.java:123
static final boolean DEBUG_GL
Reflects property jogl.debug.DebugGL.
Definition: GLContext.java:107
boolean isNPOTTextureAvailable()
Note: The GL impl.
static boolean isGLVersionAvailable(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile, final boolean isHardware[])
final boolean isCreatedWithARBMethod()
Definition: GLContext.java:799
final boolean isGL2ES2()
Indicates whether this GLContext is capable of GL2ES2.
static final String makeCurrentResultToString(final int res)
Returns a String representation of the makeCurrent() result.
Definition: GLContext.java:540
static final VersionNumber Version1_2
Version 1.2, i.e.
Definition: GLContext.java:135
static final VersionNumber Version1_50
Version 1.50, i.e.
Definition: GLContext.java:129
abstract int getDefaultPixelDataFormat()
Get the default pixel data format, as required by e.g.
abstract int getDefaultDrawBuffer()
Returns the default color buffer within the current bound getDefaultReadFramebuffer(),...
final boolean isGLES3Compatible()
Return true if this context is an ES3 context or implements the extension GL_ARB_ES3_compatibility,...
Definition: GLContext.java:919
static boolean isGL4bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[])
abstract void setGLDebugSynchronous(boolean synchronous)
Enables or disables the synchronous debug behavior via glEnable/glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS...
static boolean getAvailableGLVersionsSet(final AbstractGraphicsDevice device)
static final int CTX_IMPL_ES31_COMPAT
GL_ARB_ES3_1_compatibility implementation related: Context is compatible w/ ES 3.1.
Definition: GLContext.java:199
static boolean isGL3bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[])
static final VersionNumber Version1_40
Version 1.40, i.e.
Definition: GLContext.java:127
final boolean hasBasicFBOSupport()
Returns true if basic FBO support is available, otherwise false.
Definition: GLContext.java:977
static final VersionNumber Version3_20
Version 3.20.
Definition: GLContext.java:148
final Object getAttachedObject(final String name)
Returns the attached user object for the given name to this GLContext.
Definition: GLContext.java:615
abstract void release()
Releases control of this GLContext from the current thread.
boolean joinSwapGroupImpl(final int group)
abstract boolean isFunctionAvailable(String glFunctionName)
Returns true if the specified OpenGL core- or extension-function can be successfully called using thi...
static final VersionNumber Version8_0
Definition: GLContext.java:159
final boolean isGLCoreProfile()
Definition: GLContext.java:795
static String toHexString(final long hex)
static final VersionNumber Version3_0
Version 3.0.
Definition: GLContext.java:144
static final int getMaxMajor(final int ctxProfile)
abstract void enableGLDebugMessage(boolean enable)
Enables or disables the GLDebugOutput feature of extension GLExtensions#ARB_debug_output or GLExtensi...
static final int GL_VERSIONS[][]
abstract DynamicLibraryBundle getDynamicLibraryBundle()
Returns the DynamicLibraryBundle, matching context.
abstract String getGLExtensionsString()
Returns a non-null (but possibly empty) string containing the space-separated list of available exten...
static final boolean DEBUG
Definition: GLContext.java:76
boolean setSwapInterval(final int interval)
Set the swap interval of the current context and attached onscreen GLDrawable.
static final int CTX_IMPL_FBO
Context supports basic FBO, details see hasBasicFBOSupport().
Definition: GLContext.java:210
final Object detachObject(final String name)
Definition: GLContext.java:627
final boolean bindSwapBarrier(final int group, final int barrier)
static final int isHardwareRasterizer(final AbstractGraphicsDevice device, final GLProfile glp)
static final int CTX_OPTION_FORWARD
ARB_create_context related: flag forward compatible.
Definition: GLContext.java:182
final boolean isGLESProfile()
Definition: GLContext.java:796
final boolean hasRendererQuirk(final int quirk)
Returns true if the quirk exist in getRendererQuirks(), otherwise false.
Definition: GLContext.java:308
boolean setSwapIntervalImpl(final int interval)
void resetStates(final boolean isInit)
Definition: GLContext.java:248
final VersionNumberString getGLVersionNumber()
Returns this context OpenGL version.
Definition: GLContext.java:781
boolean drawableRetargeted
Did the drawable association changed ? see GLRendererQuirks#NoSetSwapIntervalPostRetarget.
Definition: GLContext.java:243
final Object attachObject(final String name, final Object obj)
Sets the attached user object for the given name to this GLContext.
Definition: GLContext.java:623
static String getAvailableGLVersionAsString(final AbstractGraphicsDevice device, final int major, final int profile)
abstract void destroy()
Destroys this OpenGL context and frees its associated resources.
static final VersionNumber Version1_1
Version 1.1, i.e.
Definition: GLContext.java:132
abstract void removeGLDebugListener(GLDebugListener listener)
Remove GLDebugListener.
final List< GLContext > getCreatedShares()
Returns a new list of created GLContext shared with this GLContext.
Definition: GLContext.java:281
static final VersionNumber Version3_2
Version 3.2.
Definition: GLContext.java:154
abstract void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled)
Generic entry for GL2GL3#glDebugMessageControl(int, int, int, int, IntBuffer, boolean) and GL2GL3#glD...
static final VersionNumber Version1_5
Version 1.5, i.e.
Definition: GLContext.java:141
final boolean isGL3ES3()
Indicates whether this GLContext is capable of GL3ES3.
final boolean isGLES2()
Indicates whether this GLContext is capable of GLES2.
static boolean getAvailableGLVersion(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile, final int[] major, final int minor[], final int ctp[])
abstract GL getRootGL()
Returns the implementing root GL instance of this GLContext's GL object, considering a wrapped pipeli...
final boolean hasFP32CompatAPI()
Returns true if OES_single_precision, fp32, fixed function point (FFP) compatibility entry points ava...
String toString()
Classname, GL, GLDrawable.
Definition: GLContext.java:635
final boolean isGL2ES3()
Indicates whether this GLContext is capable of GL2ES3.
static final int getMaxMinor(final int ctxProfile, final int major)
static final boolean isGLES32CompatibleAvailable(final AbstractGraphicsDevice device)
Returns true if a ES3 ≥ 3.2 compatible profile is available, i.e.
static String getGLVersion(final int major, final int minor, final int ctp, final String gl_version)
static boolean isGL4Available(final AbstractGraphicsDevice device, final boolean isHardware[])
static final int CTX_IMPL_FULL_MASK
Context option bits, full bit mask covering 16 bits [0..15], i.e.
Definition: GLContext.java:168
final boolean isCPUDataSourcingAvail()
Indicates whether this GLContext allows CPU data sourcing (indices, vertices ..) as opposed to using ...
static void setCurrent(final GLContext cur)
Sets the thread-local variable returned by getCurrent and has no other side-effects.
Definition: GLContext.java:554
final boolean isGLES3()
Indicates whether this GLContext is capable of GLES3.
abstract String getGLDebugMessageExtension()
final GLRendererQuirks getRendererQuirks()
Returns the instance of GLRendererQuirks, allowing one to determine workarounds.
Definition: GLContext.java:294
static final int CTX_IMPL_ES3_COMPAT
GL_ARB_ES3_compatibility implementation related: Context is compatible w/ ES3.
Definition: GLContext.java:196
static boolean isGLES3Available(final AbstractGraphicsDevice device, final boolean isHardware[])
static final boolean isFBOAvailable(final AbstractGraphicsDevice device, final GLProfile glp)
Returns true if it is possible to create an framebuffer object (FBO).
static boolean isGL2Available(final AbstractGraphicsDevice device, final boolean isHardware[])
abstract int getDefaultPixelDataType()
Get the default pixel data type, as required by e.g.
static final int CTX_OPTION_DEBUG
ARB_create_context related: flag debug.
Definition: GLContext.java:184
final boolean isGL3core()
Indicates whether this GLContext uses a GL3 core profile.
static final void getRequestMajorAndCompat(final GLProfile glp, final int[] reqMajorCTP)
Returns the GLProfile's major version number at reqMajorCTP[0] and it's context property (CTP) at req...
static final VersionNumberString getStaticGLSLVersionNumber(final int glMajorVersion, final int glMinorVersion, final int ctxOptions)
Definition: GLContext.java:871
abstract int getContextCreationFlags()
abstract GL getGL()
Returns the GL pipeline object for this GLContext.
static final VersionNumber Version3_1
Version 3.1.
Definition: GLContext.java:151
static final VersionNumber Version1_4
Version 1.4, i.e.
Definition: GLContext.java:138
static final IdentityHashMap< String, Integer > deviceVersionAvailable
final VersionNumberString getGLVendorVersionNumber()
Returns the vendor's version, i.e.
Definition: GLContext.java:793
static boolean isGLES1Available(final AbstractGraphicsDevice device, final boolean isHardware[])
static void setAvailableGLVersionsSet(final AbstractGraphicsDevice device, final boolean set)
static void shutdown()
clears the device/context mappings as well as the GL/GLX proc address tables.
final boolean hasNoDefaultVAO()
Indicates whether this GLContext's native profile does not implement a default vertex array object (V...
VersionNumberString ctxGLSLVersion
Definition: GLContext.java:239
abstract GLDrawable setGLReadDrawable(GLDrawable read)
Set the read-Drawable for read framebuffer operations.
int getSwapInterval()
Return the current swap interval.
static final int CTX_PROFILE_ES
ARB_create_context related: ES profile.
Definition: GLContext.java:180
static final boolean TRACE_GL
Reflects property jogl.debug.TraceGL.
Definition: GLContext.java:109
final boolean isGLES2Compatible()
Definition: GLContext.java:908
static final int CTX_IS_ARB_CREATED
ARB_create_context related: created via ARB_create_context.
Definition: GLContext.java:174
static final int CTX_IMPL_ES32_COMPAT
GL_ARB_ES3_2_compatibility implementation related: Context is compatible w/ ES 3.2.
Definition: GLContext.java:202
static final int CONTEXT_CURRENT_NEW
Indicates that a newly-created context was made current during the last call to makeCurrent,...
Definition: GLContext.java:116
final boolean isGL2ES1()
Indicates whether this GLContext is capable of GL2ES1.
final long getHandle()
Returns the underlying native OpenGL context handle.
Definition: GLContext.java:603
final RecursiveLock lock
Definition: GLContext.java:226
static GL getCurrentGL()
Returns the GL object bound to this thread current context.
Definition: GLContext.java:504
abstract String getPlatformExtensionsString()
Returns a non-null (but possibly empty) string containing the space-separated list of available platf...
final boolean isGLcore()
Indicates whether this GLContext uses a GL core profile.
final boolean isGLES1()
Indicates whether this GLContext is capable of GLES1.
abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly)
Sets the read/write drawable for framebuffer operations, i.e.
volatile long contextHandle
The underlying native OpenGL context.
Definition: GLContext.java:229
final String getGLVersion()
Returns a valid OpenGL version string, ie
Definition: GLContext.java:773
static final int CTX_PROFILE_CORE
ARB_create_context related: desktop core profile.
Definition: GLContext.java:178
final boolean isGL4()
Indicates whether this GLContext is capable of GL4.
abstract boolean isExtensionAvailable(String glExtensionName)
Returns true if the specified OpenGL extension can be successfully called using this GL context given...
final boolean isGL3bc()
Indicates whether this GLContext is capable of GL3bc.
final boolean isGLCompatibilityProfile()
Definition: GLContext.java:794
abstract int getDefaultVAO()
If this GLContext does not implement a default VAO, see hasNoDefaultVAO(), an own default VAO will be...
static StringBuilder getGLVersion(final StringBuilder sb, final int major, final int minor, final int ctp, final String gl_version)
static StringBuilder getGLVersion(final StringBuilder sb, final VersionNumber version, final int ctp, final String gl_version)
abstract void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled)
Generic entry for GL2GL3#glDebugMessageControl(int, int, int, int, int[], int, boolean) and GL2GL3#gl...
static final boolean TRACE_SWITCH
Definition: GLContext.java:77
static int getCTPFromBits(final int bits32)
final boolean isGL4ES3()
Returns true if this profile is capable of GL4ES3, i.e.
abstract int getGLExtensionCount()
Returns the number of OpenGL extensions.
static final VersionNumber Version3_10
Version 3.10.
Definition: GLContext.java:146
static final int ES_VERSIONS[][]
final boolean isHardwareRasterizer()
Definition: GLContext.java:950
final boolean queryMaxSwapGroups(final int[] maxGroups, final int maxGroups_offset, final int[] maxBarriers, final int maxBarriers_offset)
abstract GLDrawable getGLReadDrawable()
Returns the read-Drawable this context uses for read framebuffer operations.
static VersionNumber decomposeBits(final int bits32, final int[] ctp)
static final boolean PROFILE_ALIASING
If true (default), bootstrapping the available GL profiles will use the highest compatible GL context...
Definition: GLContext.java:104
GLRendererQuirks glRendererQuirks
Definition: GLContext.java:240
final boolean isCurrent()
Definition: GLContext.java:526
abstract boolean isGLReadDrawableAvailable()
Query whether using a distinguished read-drawable is supported.
abstract int getPlatformExtensionCount()
Returns the number of platform extensions.
abstract void glDebugMessageInsert(int source, int type, int id, int severity, String buf)
Generic entry for GL2GL3#glDebugMessageInsert(int, int, int, int, int, String) and GL2GL3#glDebugMess...
static final int CTX_IMPL_ACCEL_SOFT
Context uses software rasterizer, otherwise hardware rasterizer.
Definition: GLContext.java:186
abstract int getDefaultReadFramebuffer()
Return the default read framebuffer name.
static String getThreadName()
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Class holding OpenGL extension strings, commonly used by JOGL's implementation.
static final String ARB_framebuffer_object
static final String ARB_texture_non_power_of_two
static final String EXT_texture_format_BGRA8888
static final String EXT_packed_depth_stencil
static final String IMG_texture_format_BGRA8888
static final String EXT_framebuffer_object
static final String EXT_framebuffer_blit
static final String EXT_framebuffer_multisample
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
final boolean isGLES3()
Indicates whether this profile is capable of GLES3.
static final String GLES3
The embedded OpenGL profile ES 3.x, with x >= 0.
Definition: GLProfile.java:588
static final String GL3
The desktop OpenGL core profile 3.x, with x >= 1.
Definition: GLProfile.java:576
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
Definition: GLProfile.java:585
final GLProfile getImpl()
return this profiles implementation, eg.
static final String GL4bc
The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.
Definition: GLProfile.java:566
final boolean isGLES1()
Indicates whether this profile is capable of GLES1.
final boolean isGL4()
Indicates whether this profile is capable of GL4.
final boolean isGLES()
Indicates whether this profile is capable of GLES.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL3bc
The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.
Definition: GLProfile.java:573
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
static final String GL4
The desktop OpenGL core profile 4.x, with x >= 0.
Definition: GLProfile.java:569
final boolean isGL3()
Indicates whether this profile is capable of GL3.
final boolean isGL2()
Indicates whether this profile is capable of GL2 .
GLRendererQuirks contains information of known bugs of various GL renderer.
final boolean exist(final int quirkBit)
Method tests whether the given quirk exists.
static final int NoFullFBOSupport
No full FBO support, i.e.
final StringBuilder toString(StringBuilder sb)
A interface describing a graphics device in a toolkit-independent manner.
String getUniqueID()
Returns a unique ID object of this device using type, connection and unitID as it's key components.
Listener for GLDebugMessages.
An abstraction for an OpenGL rendering target.
Definition: GLDrawable.java:51
void glGetIntegerv(int pname, IntBuffer data)
Entry point to C language function: void {@native glGetIntegerv}(GLenum pname, GLint * data) Part ...
static final int GL_NO_ERROR
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_NO_ERROR" with expres...
Definition: GL.java:481
int glGetError()
Entry point to C language function: GLenum {@native glGetError}() Part of GL_ES_VERSION_2_0,...
static final int GL_MAX_SAMPLES
GL_ES_VERSION_3_0, GL_ARB_framebuffer_object, GL_VERSION_3_0, GL_NV_framebuffer_multisample,...
Definition: GL.java:63