// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/base/SimpleFragmentShaderFilter.java
// public class SimpleFragmentShaderFilter extends AbsFilter {
// 
//     protected GLSimpleProgram glSimpleProgram;
//     protected Plane plane;
// 
//     public SimpleFragmentShaderFilter(Context context,
//                                       final String fragmentShaderPath) {
//         glSimpleProgram=new GLSimpleProgram(context, "filter/vsh/simple.glsl",fragmentShaderPath);
//         plane =new Plane(true);
//     }
// 
//     @Override
//     public void init() {
//         glSimpleProgram.create();
//     }
// 
//     @Override
//     public void onPreDrawElements() {
//         super.onPreDrawElements();
//         glSimpleProgram.use();
//         plane.uploadTexCoordinateBuffer(glSimpleProgram.getTextureCoordinateHandle());
//         plane.uploadVerticesBuffer(glSimpleProgram.getPositionHandle());
//     }
// 
//     @Override
//     public void destroy() {
//         glSimpleProgram.onDestroy();
//     }
// 
//     @Override
//     public void onDrawFrame(int textureId) {
//         onPreDrawElements();
//         TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glSimpleProgram.getTextureSamplerHandle(),0);
//         GLES20.glViewport(0,0,surfaceWidth,surfaceHeight);
//         plane.draw();
//     }
// }
// 
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/TextureUtils.java
// public class TextureUtils {
//     private static final String TAG = "TextureUtils";
// 
//     public static void bindTexture2D(int textureId,int activeTextureID,int handle,int idx){
//         if (textureId != GLEtc.NO_TEXTURE) {
//             GLES20.glActiveTexture(activeTextureID);
//             GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
//             GLES20.glUniform1i(handle, idx);
//         }
//     }
// 
//     public static void bindTextureOES(int textureId,int activeTextureID,int handle,int idx){
//         if (textureId != GLEtc.NO_TEXTURE) {
//             GLES20.glActiveTexture(activeTextureID);
//             GLES20.glBindTexture(GLEtc.GL_TEXTURE_EXTERNAL_OES, textureId);
//             GLES20.glUniform1i(handle, idx);
//         }
//     }
// 
//     public static int loadTextureFromResources(Context context, int resourceId,int imageSize[]){
//         return getTextureFromBitmap(
//                 BitmapUtils.loadBitmapFromRaw(context,resourceId),
//                 imageSize);
//     }
// 
//     public static int loadTextureFromAssets(Context context, String filePath,int imageSize[]){
//         return getTextureFromBitmap(
//                 BitmapUtils.loadBitmapFromAssets(context,filePath),
//                 imageSize);
//     }
// 
//     //bitmap will be recycled after calling this method
//     public static int getTextureFromBitmap(Bitmap bitmap,int imageSize[]){
//         final int[] textureObjectIds=new int[1];
//         GLES20.glGenTextures(1,textureObjectIds,0);
//         if (textureObjectIds[0]==0){
//             Log.d(TAG,"Failed at glGenTextures");
//             return 0;
//         }
// 
//         if (bitmap==null){
//             Log.d(TAG,"Failed at decoding bitmap");
//             GLES20.glDeleteTextures(1,textureObjectIds,0);
//             return 0;
//         }
// 
//         if(imageSize!=null && imageSize.length>=2){
//             imageSize[0]=bitmap.getWidth();
//             imageSize[1]=bitmap.getHeight();
//         }
// 
//         GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textureObjectIds[0]);
// 
//         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
//                 GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
//         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
//                 GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
//         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
//                 GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
//         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
//                 GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
//         GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,bitmap,0);
//         bitmap.recycle();
// 
//         GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0);
//         return textureObjectIds[0];
//     }
// }


import android.content.Context;
import android.opengl.GLES20;
import com.martin.ads.vrlib.filters.base.SimpleFragmentShaderFilter;
import com.martin.ads.vrlib.utils.TextureUtils;
package com.martin.ads.vrlib.filters.advanced.mx;




/**
 * Created by Ads on 2017/2/1.
 * MxLomoFilter (LOMO)
 */

public class MxLomoFilter extends SimpleFragmentShaderFilter {
    public MxLomoFilter(Context context) {
        super(context, "filter/fsh/mx_lomo.glsl");
    }

    @Override
    public void onDrawFrame(int textureId) {
        onPreDrawElements();
        setUniform1f(glSimpleProgram.getProgramId(),"rOffset",1.0f);
        setUniform1f(glSimpleProgram.getProgramId(),"gOffset",1.0f);
        setUniform1f(glSimpleProgram.getProgramId(),"bOffset",1.0f);
// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/base/SimpleFragmentShaderFilter.java
// public class SimpleFragmentShaderFilter extends AbsFilter {
// 
//     protected GLSimpleProgram glSimpleProgram;
//     protected Plane plane;
// 
//     public SimpleFragmentShaderFilter(Context context,
//                                       final String fragmentShaderPath) {
//         glSimpleProgram=new GLSimpleProgram(context, "filter/vsh/simple.glsl",fragmentShaderPath);
//         plane =new Plane(true);
//     }
// 
//     @Override
//     public void init() {
//         glSimpleProgram.create();
//     }
// 
//     @Override
//     public void onPreDrawElements() {
//         super.onPreDrawElements();
//         glSimpleProgram.use();
//         plane.uploadTexCoordinateBuffer(glSimpleProgram.getTextureCoordinateHandle());
//         plane.uploadVerticesBuffer(glSimpleProgram.getPositionHandle());
//     }
// 
//     @Override
//     public void destroy() {
//         glSimpleProgram.onDestroy();
//     }
// 
//     @Override
//     public void onDrawFrame(int textureId) {
//         onPreDrawElements();
//         TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glSimpleProgram.getTextureSamplerHandle(),0);
//         GLES20.glViewport(0,0,surfaceWidth,surfaceHeight);
//         plane.draw();
//     }
// }
// 
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/TextureUtils.java
// public class TextureUtils {
//     private static final String TAG = "TextureUtils";
// 
//     public static void bindTexture2D(int textureId,int activeTextureID,int handle,int idx){
//         if (textureId != GLEtc.NO_TEXTURE) {
//             GLES20.glActiveTexture(activeTextureID);
//             GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
//             GLES20.glUniform1i(handle, idx);
//         }
//     }
// 
//     public static void bindTextureOES(int textureId,int activeTextureID,int handle,int idx){
//         if (textureId != GLEtc.NO_TEXTURE) {
//             GLES20.glActiveTexture(activeTextureID);
//             GLES20.glBindTexture(GLEtc.GL_TEXTURE_EXTERNAL_OES, textureId);
//             GLES20.glUniform1i(handle, idx);
//         }
//     }
// 
//     public static int loadTextureFromResources(Context context, int resourceId,int imageSize[]){
//         return getTextureFromBitmap(
//                 BitmapUtils.loadBitmapFromRaw(context,resourceId),
//                 imageSize);
//     }
// 
//     public static int loadTextureFromAssets(Context context, String filePath,int imageSize[]){
//         return getTextureFromBitmap(
//                 BitmapUtils.loadBitmapFromAssets(context,filePath),
//                 imageSize);
//     }
// 
//     //bitmap will be recycled after calling this method
//     public static int getTextureFromBitmap(Bitmap bitmap,int imageSize[]){
//         final int[] textureObjectIds=new int[1];
//         GLES20.glGenTextures(1,textureObjectIds,0);
//         if (textureObjectIds[0]==0){
//             Log.d(TAG,"Failed at glGenTextures");
//             return 0;
//         }
// 
//         if (bitmap==null){
//             Log.d(TAG,"Failed at decoding bitmap");
//             GLES20.glDeleteTextures(1,textureObjectIds,0);
//             return 0;
//         }
// 
//         if(imageSize!=null && imageSize.length>=2){
//             imageSize[0]=bitmap.getWidth();
//             imageSize[1]=bitmap.getHeight();
//         }
// 
//         GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textureObjectIds[0]);
// 
//         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
//                 GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
//         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
//                 GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
//         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
//                 GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
//         GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
//                 GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
//         GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,bitmap,0);
//         bitmap.recycle();
// 
//         GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0);
//         return textureObjectIds[0];
//     }
// }


// Path: vrlib/src/main/java/com/martin/ads/vrlib/filters/advanced/mx/MxLomoFilter.java
import android.content.Context;
import android.opengl.GLES20;
import com.martin.ads.vrlib.filters.base.SimpleFragmentShaderFilter;
import com.martin.ads.vrlib.utils.TextureUtils;

package com.martin.ads.vrlib.filters.advanced.mx;




/**
 * Created by Ads on 2017/2/1.
 * MxLomoFilter (LOMO)
 */

public class MxLomoFilter extends SimpleFragmentShaderFilter {
    public MxLomoFilter(Context context) {
        super(context, "filter/fsh/mx_lomo.glsl");
    }

    @Override
    public void onDrawFrame(int textureId) {
        onPreDrawElements();
        setUniform1f(glSimpleProgram.getProgramId(),"rOffset",1.0f);
        setUniform1f(glSimpleProgram.getProgramId(),"gOffset",1.0f);
        setUniform1f(glSimpleProgram.getProgramId(),"bOffset",1.0f);
        TextureUtils.bindTexture2D(textureId, GLES20.GL_TEXTURE0,glSimpleProgram.getTextureSamplerHandle(),0);