Revision 95c441a2
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/library/DistortedOutputSurface.java | ||
---|---|---|
30 | 30 |
private ArrayList<DistortedNode> mChildren; |
31 | 31 |
private int mNumChildren; // ==mChildren.length(), but we only create mChildren if the first one gets added |
32 | 32 |
|
33 |
private long mTime; |
|
33 | 34 |
private float mFOV; |
34 | 35 |
int mWidth,mHeight,mDepth; |
35 | 36 |
float mDistance, mNear; |
... | ... | |
61 | 62 |
mFBOH[0] = fbo; |
62 | 63 |
mDepthH[0] = 0; |
63 | 64 |
|
65 |
mTime = 0; |
|
66 |
|
|
64 | 67 |
createProjection(); |
65 | 68 |
} |
66 | 69 |
|
... | ... | |
111 | 114 |
int numRenders = 0; |
112 | 115 |
DistortedNode child; |
113 | 116 |
DistortedFramebuffer fbo; |
114 |
DistortedOutputSurface buffer;
|
|
117 |
DistortedOutputSurface surface;
|
|
115 | 118 |
|
116 | 119 |
// 1. Render all children that have postprocessing effects to their own buffer FBOs |
117 | 120 |
|
... | ... | |
130 | 133 |
// 2. If we have rendered anything so far, and we are a Screen, then render to an |
131 | 134 |
// intermediate FBO instead. |
132 | 135 |
|
133 |
buffer = numRenders>0 ? getBuffer() : this;
|
|
136 |
surface = this;//numRenders>0 ? getBuffer() : this;
|
|
134 | 137 |
|
135 | 138 |
// 3. Render all children without postprocessing effects to buffer |
136 | 139 |
|
... | ... | |
141 | 144 |
|
142 | 145 |
if( fbo==null ) |
143 | 146 |
{ |
144 |
numRenders += child.draw(time,buffer);
|
|
147 |
numRenders += child.draw(time,surface);
|
|
145 | 148 |
} |
146 | 149 |
} |
147 | 150 |
|
... | ... | |
149 | 152 |
// postprocess fbo |
150 | 153 |
// merge to buffer |
151 | 154 |
|
152 |
// TODO |
|
155 |
for(int i=0; i<num; i++) |
|
156 |
{ |
|
157 |
numRenders += children.get(i).postprocess(time,surface); |
|
158 |
} |
|
153 | 159 |
|
154 | 160 |
// 5. finally blit to this if we have to |
155 | 161 |
|
156 |
if( buffer!=this && ((DistortedFramebuffer)buffer).setAsInput() )
|
|
162 |
if( surface!=this && ((DistortedFramebuffer)surface).setAsInput() )
|
|
157 | 163 |
{ |
158 | 164 |
numRenders++; |
159 | 165 |
DistortedEffects.blitPriv(this); |
... | ... | |
215 | 221 |
numRenders += mChildren.get(i).renderRecursive(time); |
216 | 222 |
} |
217 | 223 |
|
218 |
setAsOutput(); |
|
224 |
setAsOutput(time);
|
|
219 | 225 |
numRenders += renderChildren(time,mNumChildren,mChildren); |
220 | 226 |
|
221 | 227 |
return numRenders; |
... | ... | |
225 | 231 |
/** |
226 | 232 |
* Bind this Surface as a Framebuffer we can render to. |
227 | 233 |
*/ |
228 |
public void setAsOutput() |
|
234 |
public void setAsOutput(long time)
|
|
229 | 235 |
{ |
230 | 236 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]); |
237 |
|
|
238 |
if( mTime!=time ) |
|
239 |
{ |
|
240 |
mTime = time; |
|
241 |
DistortedRenderState.colorDepthOn(); |
|
242 |
GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
|
243 |
GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT); |
|
244 |
} |
|
231 | 245 |
} |
232 | 246 |
|
233 | 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Progress with Multiblur.
This introduces some regressions with transparency (see: 'Different Bitmaps' and 'Around the world' )