Project

General

Profile

« Previous | Next » 

Revision f8686932

Added by Leszek Koltunski about 8 years ago

Minor.

View differences:

src/main/java/org/distorted/library/Distorted.java
70 70
   */
71 71
  public static final int CLONE_CHILDREN= 0x10;
72 72

  
73
  private static boolean mInitialized = false;
74

  
75 73
  static int[] mMainProgramAttributes;
76 74

  
77 75
///////////////////////////////////////////////////////////////////////////////////////////////////
......
85 83

  
86 84
  static boolean isInitialized()
87 85
    {
88
    return mInitialized;
86
    return (mMainProgramAttributes!=null);
89 87
    }
90 88

  
91 89
///////////////////////////////////////////////////////////////////////////////////////////////////
......
105 103
  public static void onCreate(final Context context)
106 104
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
107 105
    { 
108
    mInitialized = true;  
109

  
110 106
    final InputStream vertexStream   = context.getResources().openRawResource(R.raw.main_vertex_shader);
111 107
    final InputStream fragmentStream = context.getResources().openRawResource(R.raw.main_fragment_shader);
112 108

  
......
116 112
    mainProgram.bindAndEnableAttributes();
117 113
    mMainProgramAttributes = mainProgram.getAttributes();
118 114

  
119
    int textureUniformH = GLES20.glGetUniformLocation(programH, "u_Texture");
120

  
121 115
    GLES20.glEnable (GLES20.GL_DEPTH_TEST);
122 116
    GLES20.glDepthFunc(GLES20.GL_LEQUAL);
123 117
    GLES20.glEnable(GLES20.GL_BLEND);
......
125 119
    GLES20.glEnable(GLES20.GL_CULL_FACE);
126 120
    GLES20.glCullFace(GLES20.GL_BACK);
127 121
    GLES20.glFrontFace(GLES20.GL_CW);
128
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
129
    GLES20.glUniform1i(textureUniformH, 0);
130 122

  
131 123
    EffectQueueFragment.getUniforms(programH);
132 124
    EffectQueueVertex.getUniforms(programH);
133 125
    EffectQueueMatrix.getUniforms(programH);
126
    DistortedTexture.getUniforms(programH);
134 127

  
135 128
    DistortedTree.reset();
136 129
    EffectMessageSender.startSending();
......
149 142
    EffectQueue.onDestroy();
150 143
    DistortedEffects.onDestroy();
151 144
    EffectMessageSender.stopSending();
152
   
153
    mInitialized = false;
145

  
146
    mMainProgramAttributes = null;
154 147
    }
155 148
  }
src/main/java/org/distorted/library/DistortedTexture.java
44 44
  private static boolean mListMarked = false;
45 45
  private static LinkedList<DistortedTexture> mList = new LinkedList<>();
46 46

  
47
  private static int mTextureH;
48

  
47 49
  private int mSizeX, mSizeY;  // in screen space
48 50
  float mHalfX, mHalfY;        // halves of the above
49 51
  private long mID;
......
118 120
    return mID;
119 121
    }
120 122

  
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

  
125
  static void getUniforms(int mProgramH)
126
    {
127
    mTextureH= GLES20.glGetUniformLocation( mProgramH, "u_Texture");
128

  
129
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
130
    GLES20.glUniform1i(mTextureH, 0);
131
    }
132

  
121 133
///////////////////////////////////////////////////////////////////////////////////////////////////
122 134

  
123 135
  static synchronized void onDestroy()

Also available in: Unified diff