Project

General

Profile

« Previous | Next » 

Revision 94f6d472

Added by Leszek Koltunski about 7 years ago

Make it more flexible; now it can run almost all apps on OpenGL 2.0 contexts; OpenGL 3.0 ( with GLSL 3.00) required for POSTPROCESSING.

View differences:

src/main/java/org/distorted/library/program/DistortedProgram.java
35 35
 */
36 36
public class DistortedProgram
37 37
  {
38
  private int mProgramHandle;
38
  private String mAttributeStr;
39
  private int mAttributeLen;
39 40

  
41
  private int mProgramHandle;
40 42
  private int mNumAttributes;
41 43
  private String[] mAttributeName;
42 44

  
......
105 107
      if( currChar==';') break;
106 108
      }
107 109

  
108
    if( semicolon<len && semicolon-whiteSpace>=4 )   // "in a;" --> 4
110
    if( semicolon<len && semicolon-whiteSpace>=mAttributeLen+1 )
109 111
      {
110 112
      String subline = line.substring(whiteSpace,semicolon);
111 113
      int subLen = semicolon-whiteSpace;
112 114

  
113
      if( subline.startsWith("in "))
115
      if( subline.startsWith(mAttributeStr))
114 116
        {
115 117
        //android.util.Log.e("program", "GOOD LINE: " +subline+" subLen="+subLen);
116 118

  
117
        for(nameBegin=subLen-1; nameBegin>1; nameBegin--)
119
        for(nameBegin=subLen-1; nameBegin>mAttributeLen-2; nameBegin--)
118 120
          {
119 121
          currChar=subline.charAt(nameBegin);
120 122

  
......
260 262
   * @throws LinkingException
261 263
   */
262 264

  
263
  public DistortedProgram(final InputStream vertex, final InputStream fragment, final String vertexHeader, final String fragmentHeader)
265
  public DistortedProgram(final InputStream vertex, final InputStream fragment, final String vertexHeader, final String fragmentHeader, int glslVersion)
264 266
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
265 267
    {
268
    mAttributeStr = (glslVersion == 100 ? "attribute " : "in ");
269
    mAttributeLen = mAttributeStr.length();
270

  
266 271
    mNumAttributes = 0;
267 272

  
268 273
    final String vertexShader   = readTextFileFromRawResource(vertex  , true );

Also available in: Unified diff