Revision a0397f32
Added by Leszek Koltunski about 5 years ago
src/main/java/org/distorted/library/main/EffectQueue.java | ||
---|---|---|
96 | 96 |
DistortedMaster.newSlave(this); // of uniforms later, on first render. |
97 | 97 |
} |
98 | 98 |
|
99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
100 |
// queues - guaranteed to be an array of EffectType.LENGTH length. |
|
101 |
// Change this when creating a new ty[e of effect! |
|
102 |
|
|
103 |
static void allocateQueues(EffectQueue[] queues, EffectQueue[] from, int flags, long id) |
|
104 |
{ |
|
105 |
queues[0] = (flags & Distorted.CLONE_MATRIX ) != 0 ? from[0] : new EffectQueueMatrix(id); |
|
106 |
queues[1] = (flags & Distorted.CLONE_VERTEX ) != 0 ? from[1] : new EffectQueueVertex(id); |
|
107 |
queues[2] = (flags & Distorted.CLONE_FRAGMENT ) != 0 ? from[2] : new EffectQueueFragment(id); |
|
108 |
queues[3] = (flags & Distorted.CLONE_POSTPROCESS) != 0 ? from[3] : new EffectQueuePostprocess(id); |
|
109 |
} |
|
110 |
|
|
111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
112 |
// queues - guaranteed to be an array of EffectType.LENGTH length. |
|
113 |
// Change this when creating a new ty[e of effect! |
|
114 |
|
|
115 |
static void compute(EffectQueue[] queues, long currTime, float halfW, float halfH, float halfZ ) |
|
116 |
{ |
|
117 |
((EffectQueueMatrix )queues[0]).compute(currTime); |
|
118 |
((EffectQueueVertex )queues[1]).compute(currTime,halfW,halfH,halfZ); |
|
119 |
((EffectQueueFragment )queues[2]).compute(currTime,halfW,halfH,halfZ); |
|
120 |
((EffectQueuePostprocess)queues[3]).compute(currTime); |
|
121 |
} |
|
122 |
|
|
123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
124 |
// queues - guaranteed to be an array of EffectType.LENGTH length. |
|
125 |
// Change this when creating a new ty[e of effect! |
|
126 |
|
|
127 |
static void send(EffectQueue[] queues, DistortedOutputSurface surface, float inflate, float halfW, float halfH, float halfZ, int variant ) |
|
128 |
{ |
|
129 |
((EffectQueueMatrix )queues[0]).send(surface,halfW,halfH,halfZ, variant); |
|
130 |
((EffectQueueVertex )queues[1]).send(inflate, variant); |
|
131 |
((EffectQueueFragment)queues[2]).send(variant); |
|
132 |
} |
|
133 |
|
|
134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
135 |
// queues - guaranteed to be an array of EffectType.LENGTH length. |
|
136 |
// Change this when creating a new ty[e of effect! |
|
137 |
|
|
138 |
static float[] getMVP(EffectQueue[] queues) |
|
139 |
{ |
|
140 |
return ((EffectQueueMatrix )queues[0]).getMVP(); |
|
141 |
} |
|
142 |
|
|
143 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
144 |
// queues - guaranteed to be an array of EffectType.LENGTH length. |
|
145 |
// Change this when creating a new ty[e of effect! |
|
146 |
|
|
147 |
static void newNode(EffectQueue[] queues, DistortedNode node) |
|
148 |
{ |
|
149 |
queues[3].newNode(node); |
|
150 |
} |
|
151 |
|
|
152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
153 |
// queues - guaranteed to be an array of EffectType.LENGTH length. |
|
154 |
// Change this when creating a new ty[e of effect! |
|
155 |
|
|
156 |
static void removeNode(EffectQueue[] queues, DistortedNode node) |
|
157 |
{ |
|
158 |
queues[3].removeNode(node); |
|
159 |
} |
|
160 |
|
|
161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
162 |
// queues - guaranteed to be an array of EffectType.LENGTH length. |
|
163 |
// Change this when creating a new ty[e of effect! |
|
164 |
|
|
165 |
static void getUniforms(int programH, int variant) |
|
166 |
{ |
|
167 |
EffectQueueFragment.getUniforms(programH,variant); |
|
168 |
EffectQueueVertex .getUniforms(programH,variant); |
|
169 |
EffectQueueMatrix .getUniforms(programH,variant); |
|
170 |
} |
|
171 |
|
|
99 | 172 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
100 | 173 |
// Every effect queue has an ID, which should be the same iff two queues hold the same effects. |
101 | 174 |
// (this is a speedup: then both queues can be applied once, which seriously speeds up stuff - |
... | ... | |
130 | 203 |
|
131 | 204 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
132 | 205 |
|
133 |
void newNode(DistortedNode node) |
|
206 |
private void newNode(DistortedNode node)
|
|
134 | 207 |
{ |
135 | 208 |
if( mNodes==null ) mNodes = new ArrayList<>(); |
136 | 209 |
|
... | ... | |
139 | 212 |
|
140 | 213 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
141 | 214 |
|
142 |
void removeNode(DistortedNode node) |
|
215 |
private void removeNode(DistortedNode node)
|
|
143 | 216 |
{ |
144 | 217 |
mNodes.remove(node); |
145 | 218 |
} |
Also available in: Unified diff
Make DistortedEffects oblivious of the effect types.