Revision b2939df4
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/library/DistortedNode.java | ||
|---|---|---|
| 238 | 238 | DistortedEffects.blitPriv(mData.mFBO); | 
| 239 | 239 | } | 
| 240 | 240 |  | 
| 241 | // 'renderChildren' | |
| 242 | for(int i=0; i<mNumChildren[0]; i++) | |
| 243 |         {
 | |
| 244 | numRenders += mChildren.get(i).draw(currTime,mData.mFBO); | |
| 245 | } | |
| 241 | numRenders += mData.mFBO.renderChildren(currTime,mNumChildren[0],mChildren); | |
| 246 | 242 | } | 
| 247 | 243 |  | 
| 248 | 244 | return numRenders; | 
| 249 | 245 | } | 
| 250 | 246 |  | 
| 251 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 252 | // return the total number of render calls issued | |
| 253 |  | |
| 254 | int drawRecursive(long currTime, DistortedOutputSurface surface) | |
| 255 |     {
 | |
| 256 | int ret = 0; | |
| 257 |  | |
| 258 | if( mNumChildren[0]>0 && mData.currTime!=currTime ) | |
| 259 |       {
 | |
| 260 | mData.currTime = currTime; | |
| 261 | mData.mFBO.setAsOutput(); | |
| 262 |  | |
| 263 | GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
| 264 | GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT); | |
| 265 |  | |
| 266 | if( mSurface.setAsInput() ) | |
| 267 |         {
 | |
| 268 | ret++; | |
| 269 | DistortedEffects.blitPriv(mData.mFBO); | |
| 270 | } | |
| 271 |  | |
| 272 | for(int i=0; i<mNumChildren[0]; i++) | |
| 273 |         {
 | |
| 274 | ret += mChildren.get(i).drawRecursive(currTime, mData.mFBO); | |
| 275 | } | |
| 276 | } | |
| 277 |  | |
| 278 | DistortedInputSurface input = mNumChildren[0]==0 ? mSurface : mData.mFBO; | |
| 279 |  | |
| 280 | if( input.setAsInput() ) | |
| 281 |       {
 | |
| 282 | ret++; | |
| 283 | mState.apply(); | |
| 284 | mEffects.drawPriv(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime); | |
| 285 | } | |
| 286 |  | |
| 287 | return ret; | |
| 288 | } | |
| 289 |  | |
| 290 | 247 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 291 | 248 | // PUBLIC API | 
| 292 | 249 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| src/main/java/org/distorted/library/DistortedOutputSurface.java | ||
|---|---|---|
| 101 | 101 | } | 
| 102 | 102 |  | 
| 103 | 103 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 104 | // PUBLIC API | |
| 105 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 106 | /** | |
| 107 | * Draws all the attached children to this OutputSurface. | |
| 108 | * <p> | |
| 109 | * Must be called from a thread holding OpenGL Context. | |
| 110 | * | |
| 111 | * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the children Nodes. | |
| 112 | * @return Number of objects rendered. | |
| 113 | */ | |
| 114 | public int render(long time) | |
| 115 |     {
 | |
| 116 | DistortedAttachDaemon.toDo(); | |
| 117 | toDo(); | |
| 118 | DistortedRenderState.reset(); | |
| 119 |  | |
| 120 | int numRenders=0; | |
| 121 | 104 |  | 
| 122 | for(int i=0; i<mNumChildren; i++) | |
| 123 |       {
 | |
| 124 | numRenders += mChildren.get(i).renderRecursive(time); | |
| 125 | } | |
| 126 |  | |
| 127 | setAsOutput(); | |
| 105 | int renderChildren(long time, int num, ArrayList<DistortedNode> children) | |
| 106 |     {
 | |
| 107 | int numRenders = 0; | |
| 128 | 108 |  | 
| 129 | // 'renderChildren' | |
| 130 | for(int i=0; i<mNumChildren; i++) | |
| 109 | for(int i=0; i<num; i++) | |
| 131 | 110 |       {
 | 
| 132 |       numRenders += mChildren.get(i).draw(time,this);
 | |
| 111 |       numRenders += children.get(i).draw(time,this);
 | |
| 133 | 112 | } | 
| 134 | 113 |  | 
| 135 | 114 | return numRenders; | 
| 136 | 115 | } | 
| 137 | 116 |  | 
| 117 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 118 | // PUBLIC API | |
| 138 | 119 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 139 | 120 | /** | 
| 140 | 121 | * Draws all the attached children to this OutputSurface. | 
| ... | ... | |
| 144 | 125 | * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the children Nodes. | 
| 145 | 126 | * @return Number of objects rendered. | 
| 146 | 127 | */ | 
| 147 |   public int renderOld(long time)
 | |
| 128 | public int render(long time) | |
| 148 | 129 |     {
 | 
| 149 | 130 | // change tree topology (attach and detach children) | 
| 150 | 131 | /* | 
| ... | ... | |
| 179 | 160 | // mark OpenGL state as unknown | 
| 180 | 161 | DistortedRenderState.reset(); | 
| 181 | 162 |  | 
| 182 |     int numRenders = 0;
 | |
| 163 |     int numRenders=0;
 | |
| 183 | 164 |  | 
| 184 | 165 | for(int i=0; i<mNumChildren; i++) | 
| 185 | 166 |       {
 | 
| 186 |       numRenders += mChildren.get(i).drawRecursive(time,this);
 | |
| 167 |       numRenders += mChildren.get(i).renderRecursive(time);
 | |
| 187 | 168 | } | 
| 188 | 169 |  | 
| 170 | setAsOutput(); | |
| 171 | numRenders += renderChildren(time,mNumChildren,mChildren); | |
| 172 |  | |
| 189 | 173 | return numRenders; | 
| 190 | 174 | } | 
| 191 | 175 |  | 
Also available in: Unified diff
Now there's a single place one can have a look at all the Meshes being rendered to a OutputSurface: OutputSurface.renderChildren().
This will need to get modified for per-object post-processing.