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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/**
* @(#) GLRunnable.java
*/
package gl4java;
import java.lang.*;
/**
* This is the interface for a threaded renderer (animator thread).
*
* If an animation class, e.g. {@link gl4java.awt.GLAnimCanvas},
* implements {@link gl4java.drawable.GLDrawable} and this interface,
* you will benefit from the new context handling {@link gl4java.GLContext#gljFree}.
*
* @see gl4java.GLContext
* @see gl4java.drawable.GLDrawable
* @see gl4java.awt.GLAnimCanvas
*/
public interface GLRunnable extends Runnable
{
/**
* This creates and start one singleton unique thread !
*/
public void start();
/**
* This stops and destroys (deferred) our singleton unique thread !
*/
public void stop();
/**
* Identifies this object with the given thread ..
* If this object owns this thread, it must return true !
*/
public boolean ownsThread(Thread thread);
/**
* The running loop for animations
* which initiates the call of display
*
* Be sure to force freeing the GL context
* with {@link gl4java.GLContext#gljFree}(true), if:
* <pre>
- you exit this run loop
- you suspend your thread -> wait
- you kill your thread ..
* </pre>
*
* Also be sure, to implement this Runnable as Java2 does recomends !
* Look at the example implementation {@link gl4java.awt.GLAnimCanvas#run} !
*
* @see gl4java.awt.GLAnimCanvas#run
* @see #setSuspended
*/
public void run();
/**
* Here we can (re)start or suspend animation ...
*
* If the thread should be (re)started and is not alive -> killed,
* or never be started, it will be started !
*
* @param suspend if true the thread will be suspended,
* if false, the thread will be (re)started
*
* @see #isAlive
* @see #start
*/
public void setSuspended(boolean suspend);
/**
* Here we can (re)start or suspend animation ...
*
* If the thread should be (re)started and is not alive -> killed,
* or never be started, it will be started !
*
* @param suspend if true the thread will be suspended,
* if false, the thread will be (re)started
*
* @param reInit if true the ReInit will be called additionally,
* where the user can set additional initialisations
*
* @see #ReInit
* @see #isAlive
* @see #start
* @see #run
*/
public void setSuspended(boolean suspend, boolean reInit);
/**
* is the thread alive, means is started and not died ?
*
* @see #run
* @see #setSuspended
* @see #start
* @see #stop
*/
public boolean isAlive();
/**
* is the thread suspended, means is started but waiting,
* or not alive (ok :-| - but it is practical)
*
* @see #run
* @see #setSuspended
* @see #start
* @see #stop
*/
public boolean isSuspended();
/**
* ReInit should be overwritten by you,
* to enter your re-initialisation within setSuspended(false)
*
* @see #setSuspended
*/
public void ReInit();
/**
* Forces this thread to release it's GLContext !
*
* To ensure this, this thread enables itself,
* and calls gljFree(true) to force the release !
*
* @see #setSuspended
* @see #run
*/
public void freeGLContext();
}
|