@@ -38,6 +38,9 @@ public class BaseFilter {
3838 protected FloatBuffer mVertexBuffer ;
3939 protected FloatBuffer mTextureBuffer ;
4040
41+ private int mOverlayTexture ;
42+ private int [] mOverlayTextureId ;
43+
4144 public BaseFilter (String vertexShader , String fragmentShader ) {
4245 mRunnableDraw = new LinkedList <>();
4346 mVertexShader = vertexShader ;
@@ -72,6 +75,12 @@ public void init() {
7275 onInitialized ();
7376 }
7477
78+ protected void initOverlayTexture () {
79+ mOverlayTexture = GLES30 .glGetUniformLocation (mProgramId , "inputImageTexture2" );
80+ mOverlayTextureId = new int [1 ];
81+ GLES30 .glGenTextures (1 , mOverlayTextureId , 0 );
82+ }
83+
7584 protected void onDestroy () {
7685
7786 }
@@ -124,6 +133,12 @@ public int onDrawFrame(final int textureId, FloatBuffer vertexBuffer, FloatBuffe
124133 GLES30 .glUniform1i (mUniformTexture , 0 );
125134 }
126135
136+ if (mOverlayTextureId != null && mOverlayTextureId [0 ] != OpenGLUtil .NO_TEXTURE ) {
137+ GLES30 .glActiveTexture (GLES30 .GL_TEXTURE1 );
138+ GLES30 .glBindTexture (GLES30 .GL_TEXTURE_2D , mOverlayTextureId [0 ]);
139+ GLES30 .glUniform1i (mOverlayTexture , 0 );
140+ }
141+
127142 onDrawArrayBefore ();
128143 GLES30 .glDrawArrays (GLES30 .GL_TRIANGLE_STRIP , 0 , 4 );
129144 GLES30 .glDisableVertexAttribArray (mAttributePosition );
@@ -147,6 +162,15 @@ protected void runOnDraw(final Runnable runnable) {
147162 }
148163 }
149164
165+ public void setInteger (final int location , final int intVal ) {
166+ runOnDraw (new Runnable () {
167+ @ Override
168+ public void run () {
169+ GLES30 .glUniform1i (location , intVal );
170+ }
171+ });
172+ }
173+
150174 public void setFloat (final int location , final float floatVal ) {
151175 runOnDraw (new Runnable () {
152176 @ Override
0 commit comments