summaryrefslogtreecommitdiffstats
path: root/src/redbook/src/glredbook10/GLSkeleton.java
blob: 6b147fa3834876a7ba5fcc091ee7bca665cc8b78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package glredbook10;


import com.jogamp.opengl.util.FPSAnimator;
import javax.media.opengl.*;

public abstract class GLSkeleton<D extends GLAutoDrawable> {

    public final D drawable;

    protected FPSAnimator animator;
    protected int FramePerSecond = 24;


    public GLSkeleton() {
        drawable = createDrawable();
    }

    protected abstract D createDrawable();

    /**
     * Call the reference canvas's display methods. Should be called after
     * handling of input events.
     */
    public final void refresh() {
        if (drawable == null)
            throw new RuntimeException("GLDrawable is not set.");
        drawable.display();
    }//


    public final void setAnimator(FPSAnimator animator) {
        this.animator = animator;
    }//

    public final void runExit() {
        new Thread(new Runnable() {
            public void run() {
                if(animator!=null)
                    animator.stop();
                drawable.destroy();
            }
        }).start();

    }//

}//