Android-Opengl 实现图片滤镜功能

  在GPUIMage里面已经实现了2D图片滤镜功能,由于项目的是全景图片,所以只好将GPUImage里面的滤镜功能的shader文件拿来自己用。

  在此记录一下每次切换滤镜的时候纹理加载的流程

  GLES20.glUseProgram(mProgram);
  GLES20.glDetachShader(mProgram, oldFshId);//detach old shader id
   int fshId = this.loadShader(GLES20.GL_FRAGMENT_SHADER, newFragmentShader);//load new fragment shader
   GLES20.glAttachShader(mProgram, fshId);// attach new shader id
   GLES20.glLinkProgram(mProgram);
   GLES20.glDeleteShader(fshId);
   filterInputTextureUniform2 = GLES20.glGetUniformLocation(mProgram, "inputImageTexture2");
   filterInputTextureUniform3 = GLES20.glGetUniformLocation(mProgram, "inputImageTexture3");
   filterInputTextureUniform4 = GLES20.glGetUniformLocation(mProgram, "inputImageTexture4");
   filterInputTextureUniform5 = GLES20.glGetUniformLocation(mProgram, "inputImageTexture5");
   filterInputTextureUniform6 = GLES20.glGetUniformLocation(mProgram, "inputImageTexture6");
   GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
   GLES20.glBindTexture(GL_TEXTURE_2D, msTextureId);
   GLES20.glUniform1i(msTextureLoc, 0);

因为只是修改滤镜,所以只需要重新加载纹理坐标,顶点坐标不需要修改。

你可能感兴趣的:(Android,Android,OpenGL,ES,2.0)