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