Project

General

Profile

« Previous | Next » 

Revision d9706fd2

Added by Leszek Koltunski almost 8 years ago

Change the the render() API!

THis introduces some regressions with the Effects3D app.

View differences:

src/main/java/org/distorted/library/DistortedOutputSurface.java
91 91
// PUBLIC API
92 92
///////////////////////////////////////////////////////////////////////////////////////////////////
93 93
/**
94
 * Draw the (texture,mesh,effects) object to the Framebuffer.
94
 * Draws all the attached children to this OutputSurface.
95 95
 * <p>
96 96
 * Must be called from a thread holding OpenGL Context.
97 97
 *
98
 * @param surface InputSurface to skin our Mesh with.
99
 * @param mesh Class descendant from MeshObject
100
 * @param effects The DistortedEffects to use when rendering
101
 * @param time Current time, in milliseconds.
98
 * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the children Nodes.
102 99
 */
103
  public void renderTo(DistortedInputSurface surface, MeshObject mesh, DistortedEffects effects, long time)
100
  public void render(long time)
104 101
    {
105
    surface.create();  // Watch out  - this needs to be before
106
    create();          // the 'setAsInput' because this has side-effects!
102
    DistortedSurface.deleteAllMarked();
103
    create();
107 104

  
108
    if( surface.setAsInput() )
105
    for(int i=0; i<mNumChildren; i++)
109 106
      {
110
      DistortedSurface.deleteAllMarked();
111
      effects.drawPriv(surface.getWidth()/2.0f, surface.getHeight()/2.0f, mesh, this, time);
107
      mChildren.get(i).drawRecursive(time,this);
112 108
      }
113 109
    }
114 110

  
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116
/**
117
 * Draws the Tree, and all its children, to the Framebuffer.
118
 * <p>
119
 * Must be called from a thread holding OpenGL Context.
120
 *
121
 * @param dt DistortedNode to render.
122
 * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the Tree.
123
 */
124
  public void renderTo(DistortedNode dt, long time)
125
    {
126
    DistortedSurface.deleteAllMarked();
127
    create();
128
    dt.drawRecursive(time,this);
129
    }
130

  
131 111
///////////////////////////////////////////////////////////////////////////////////////////////////
132 112
/**
133 113
 * Bind this Surface as a Framebuffer we can render to.
......
212 192
 */
213 193
  public synchronized boolean detach(DistortedNode node)
214 194
    {
215
    if( mChildren.remove(node) )
195
    if( mNumChildren>0 && mChildren.remove(node) )
216 196
      {
217 197
      mNumChildren--;
218 198
      return true;
......
227 207
 */
228 208
  public synchronized void detachAll()
229 209
    {
230
    mNumChildren = 0;
231
    mChildren.clear();
210
    if( mNumChildren>0 )
211
      {
212
      mNumChildren = 0;
213
      mChildren.clear();
214
      }
232 215
    }
233 216
}

Also available in: Unified diff