JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
DefaultAnimatorImpl.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
3 * Copyright (c) 2010 JogAmp Community. 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
34package com.jogamp.opengl.util;
35
36import java.util.ArrayList;
37
38import com.jogamp.opengl.GLAutoDrawable;
39
40import com.jogamp.opengl.util.AnimatorBase.UncaughtAnimatorException;
41
42/** Abstraction to factor out AWT dependencies from the Animator's
43 implementation in a way that still allows the FPSAnimator to pick
44 up this behavior if desired. */
45
46class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl {
47 @Override
48 public void display(final ArrayList<GLAutoDrawable> drawables,
49 final boolean ignoreExceptions,
50 final boolean printExceptions) throws UncaughtAnimatorException {
51 boolean hasException = false;
52 for (int i=0; !hasException && i<drawables.size(); i++) {
53 boolean catch1 = true;
54 GLAutoDrawable drawable = null;
55 try {
56 drawable = drawables.get(i);
57 catch1 = false;
58 drawable.display();
59 } catch (final Throwable t) {
60 if( catch1 && t instanceof IndexOutOfBoundsException ) {
61 // concurrent pulling of GLAutoDrawables ..
62 hasException = true;
63 } else if (ignoreExceptions) {
64 if (printExceptions) {
65 t.printStackTrace();
66 }
67 } else {
68 throw new UncaughtAnimatorException(drawable, t);
69 }
70 }
71 }
72 }
73
74 @Override
75 public boolean blockUntilDone(final Thread thread) {
76 return Thread.currentThread() != thread;
77 }
78}