Project

General

Profile

« Previous | Next » 

Revision a436ccc5

Added by Leszek Koltunski about 7 years ago

1. Make it possible to enable/disable DEPTH test when rendering to a Screen
2. Using this, remove the 'Root' Node from StarWars.

View differences:

src/main/java/org/distorted/library/DistortedOutputSurface.java
19 19

  
20 20
package org.distorted.library;
21 21

  
22
import android.opengl.GLES30;
22 23
import android.opengl.Matrix;
23 24
import java.util.ArrayList;
24 25

  
......
34 35
  float mDistance;
35 36
  float[] mProjectionMatrix;
36 37

  
38
  boolean mDepthEnabled;
39
  int[] mDepthH = new int[1];
40
  int[] mFBOH   = new int[1];
41

  
37 42
///////////////////////////////////////////////////////////////////////////////////////////////////
38 43

  
39
  DistortedOutputSurface(int width, int height, int color, boolean system)
44
  DistortedOutputSurface(int width, int height, int color, int fbo, boolean system, boolean depth)
40 45
    {
41 46
    super(width,height,color,system);
42 47

  
......
49 54
    mX   =  0.0f;
50 55
    mY   =  0.0f;
51 56

  
57
    mDepthEnabled= depth;
58
    mFBOH[0]     = fbo;
59
    mDepthH[0]   = color;
60

  
52 61
    createProjection();
53 62
    }
54 63

  
......
136 145
/**
137 146
 * Bind this Surface as a Framebuffer we can render to.
138 147
 */
139
  public abstract void setAsOutput();
148
  public void setAsOutput()
149
    {
150
    GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
151

  
152
    if( mDepthEnabled && mDepthH[0]!=NOT_CREATED_YET )
153
      {
154
      GLES30.glEnable(GLES30.GL_DEPTH_TEST);
155
      GLES30.glDepthMask(true);
156
      }
157
    else
158
      {
159
      GLES30.glDisable(GLES30.GL_DEPTH_TEST);
160
      GLES30.glDepthMask(false);
161
      }
162
    }
140 163

  
141 164
///////////////////////////////////////////////////////////////////////////////////////////////////
142 165
/**
......
181 204
      }
182 205
    }
183 206

  
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208
/**
209
 * Create a new DEPTH buffer and attach it or (param=false) detach an existing DEPTH attachment and recreate it.
210
 *
211
 * @param enable <bold>true</bold> if we want to attach a new DEPTH buffer to the FBO.<br>
212
 *               <bold>false</bold> if we want to detach the DEPTH attachment.
213
 */
214
  public void enableDepth(boolean enable)
215
    {
216
    if( mDepthEnabled!=enable )
217
      {
218
      mDepthEnabled = enable;
219
      moveToToDo();
220
      }
221
    }
222

  
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224
/**
225
 * Return true if the Surface contains a DEPTH attachment.
226
 *
227
 * @return <bold>true</bold> if the FBO contains a DEPTH attachment.
228
 */
229
  public boolean hasDepth()
230
    {
231
    return mDepthEnabled;
232
    }
233

  
184 234
///////////////////////////////////////////////////////////////////////////////////////////////////
185 235
/**
186 236
 * Adds a new child to the last position in the list of our Surface's children.

Also available in: Unified diff