Revision c5369f1b
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/library/DistortedRenderable.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library; |
21 | 21 |
|
22 |
import android.opengl.GLES30; |
|
23 |
|
|
24 | 22 |
import java.util.Iterator; |
25 | 23 |
import java.util.LinkedList; |
26 | 24 |
|
27 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
28 | 26 |
/** |
29 |
* Abstract class which represents a Renderable Object, i.e. something that we can take an skin our Mesh with. |
|
30 |
* <p> |
|
31 |
* Currently a DistortedTexture or a DistortedFramebuffer are Renderables. |
|
32 |
*/ |
|
33 |
public abstract class DistortedRenderable |
|
27 |
* Keep all objects created in a static LinkedList. The point: we need to be able to mark |
|
28 |
* Objects for deletion, and delete all marked Objects later at a convenient time (that's |
|
29 |
* because we can only delete from a thread that holds the OpenGL context so here we provide a |
|
30 |
* framework where one is able to mark for deletion at any time and actual deletion takes place |
|
31 |
* on the next render). |
|
32 |
*/ |
|
33 |
abstract class DistortedRenderable implements DistortedSurface |
|
34 | 34 |
{ |
35 | 35 |
static final int FAILED_TO_CREATE = -1; |
36 | 36 |
static final int NOT_CREATED_YET = -2; |
... | ... | |
45 | 45 |
|
46 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
47 | 47 |
|
48 |
abstract void create(); |
|
48 |
public abstract void create();
|
|
49 | 49 |
abstract void delete(); |
50 | 50 |
abstract void destroy(); |
51 | 51 |
|
... | ... | |
75 | 75 |
} |
76 | 76 |
} |
77 | 77 |
|
78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
79 |
|
|
80 |
long getID() |
|
81 |
{ |
|
82 |
return mColorH[0]; |
|
83 |
} |
|
84 |
|
|
85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
86 |
|
|
87 |
boolean setAsInput() |
|
88 |
{ |
|
89 |
if( mColorH[0]>0 ) |
|
90 |
{ |
|
91 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]); |
|
92 |
return true; |
|
93 |
} |
|
94 |
|
|
95 |
return false; |
|
96 |
} |
|
97 |
|
|
98 | 78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
99 | 79 |
|
100 | 80 |
static synchronized void onDestroy() |
... | ... | |
131 | 111 |
mMarked = true; |
132 | 112 |
} |
133 | 113 |
|
114 |
//////////////////////////////////////////////////////////////////////////////////////////////////// |
|
115 |
/** |
|
116 |
* Return unique ID of the Renderable. |
|
117 |
*/ |
|
118 |
public long getID() |
|
119 |
{ |
|
120 |
return mColorH[0]; |
|
121 |
} |
|
122 |
|
|
134 | 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
135 | 124 |
|
136 | 125 |
/** |
Also available in: Unified diff
Major: change of API.
Split DFramebuffer into Framebuffer and Screen; introduce the 'DistortedInputSurface' and 'DistortedOutputSurface' interfaces.