Project

General

Profile

« Previous | Next » 

Revision 4782b4e6

Added by Leszek Koltunski about 7 years ago

Progress with moving the Transform Feedback functionality from the APP to the library.

View differences:

src/main/java/org/distorted/library/program/DistortedProgram.java
46 46

  
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
48 48

  
49
  private int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes)
49
  private int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes, final String[] feedbackVaryings)
50 50
  throws LinkingException
51 51
    {
52 52
    int programHandle = GLES30.glCreateProgram();
......
56 56
      GLES30.glAttachShader(programHandle, vertexShaderHandle);
57 57
      GLES30.glAttachShader(programHandle, fragmentShaderHandle);
58 58

  
59
      if( feedbackVaryings!=null )
60
        {
61
        GLES30.glTransformFeedbackVaryings(programHandle, feedbackVaryings, GLES30.GL_INTERLEAVED_ATTRIBS);
62
        }
63

  
59 64
      if (attributes != null)
60 65
        {
61 66
        final int size = attributes.length;
......
246 251
    }
247 252

  
248 253
///////////////////////////////////////////////////////////////////////////////////////////////////
249
// PUBLIC API
250
///////////////////////////////////////////////////////////////////////////////////////////////////
251
  /**
252
   * Create a new Shader Program from source stored in resource files.
253
   * <p>
254
   * Needs to be called from a thread holding the OpenGL context.
255
   *
256
   * @param vertex   InputStream containing the opened Resource file from where to read vertex shader code.
257
   * @param fragment InputStream containing the opened Resource file from where to read fragment shader code.
258
   * @throws FragmentCompilationException
259
   * @throws VertexCompilationException
260
   * @throws VertexUniformsException
261
   * @throws FragmentUniformsException
262
   * @throws LinkingException
263
   */
254
// feedback: List of 'out' variables (OpenGL ES >= 3.0 only!) that will be transferred back to CPU
255
// using Transform Feedback.
264 256

  
265
  public DistortedProgram(final InputStream vertex, final InputStream fragment, final String vertexHeader, final String fragmentHeader, int glslVersion)
257
  public DistortedProgram(final InputStream vertex, final InputStream fragment, final String vertexHeader, final String fragmentHeader, int glslVersion, final String[] feedback )
266 258
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
267 259
    {
268 260
    mAttributeStr = (glslVersion == 100 ? "attribute " : "in ");
......
278 270
    final int vertexShaderHandle   = compileShader(GLES30.GL_VERTEX_SHADER  , vertexHeader   + vertexShader  );
279 271
    final int fragmentShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragmentHeader + fragmentShader);
280 272

  
281
    mProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, mAttributeName);
273
    mProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, mAttributeName, feedback);
282 274

  
283 275
    mAttribute = new int[mNumAttributes];
284 276

  
......
288 280
      }
289 281
    }
290 282

  
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284
// PUBLIC API
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286
  /**
287
   * Create a new Shader Program from source stored in resource files.
288
   * <p>
289
   * Needs to be called from a thread holding the OpenGL context.
290
   *
291
   * @param vertex   InputStream containing the opened Resource file from where to read vertex shader code.
292
   * @param fragment InputStream containing the opened Resource file from where to read fragment shader code.
293
   * @throws FragmentCompilationException
294
   * @throws VertexCompilationException
295
   * @throws VertexUniformsException
296
   * @throws FragmentUniformsException
297
   * @throws LinkingException
298
   */
299

  
300
  public DistortedProgram(final InputStream vertex, final InputStream fragment, final String vertexHeader, final String fragmentHeader, int glslVersion )
301
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
302
    {
303
    this(vertex,fragment,vertexHeader,fragmentHeader,glslVersion,null);
304
    }
305

  
291 306
///////////////////////////////////////////////////////////////////////////////////////////////////
292 307
/**
293 308
 * Return the handle of the created program so that we can later, say, call glUseProgram.

Also available in: Unified diff