Android Open Source - OpenGLAndroid-Camera My Open G L Shaders






From Project

Back to project page OpenGLAndroid-Camera.

License

The source code is released under:

Apache License

If you think the Android project OpenGLAndroid-Camera listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.andrewtremblay.openglandroidcamera;
//  ww w .  java  2  s  . c  o  m
public final class MyOpenGLShaders {
    public static class ExampleShader {
        public static final String VertexShader =
                "uniform mat4 uMVPMatrix;\n" +
                "uniform mat4 uSTMatrix;\n" +
                "uniform float uCRatio;\n" +
                "attribute vec4 aPosition;\n" +
                "attribute vec4 aTextureCoord;\n" +
                "varying vec2 vTextureCoord;\n" +
                "varying vec2 vTextureNormCoord;\n" +
                "void main() {\n" +
                "  vec4 scaledPos = aPosition;\n" +
                "  scaledPos.x = scaledPos.x * uCRatio;\n" +
                "  gl_Position = uMVPMatrix * scaledPos;\n" +
                "  vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" +
                "  vTextureNormCoord = aTextureCoord.xy;\n" +
                "}\n";
        public static final String FragmentShader =
                "#extension GL_OES_EGL_image_external : require\n" +
                "precision mediump float;\n" +
                "varying vec2 vTextureCoord;\n" +
                "varying vec2 vTextureNormCoord;\n" +
                "uniform samplerExternalOES sTexture;\n" +
                "void main() {\n" +
                "  gl_FragColor = texture2D(sTexture, vTextureCoord);\n" +
                "  gl_FragColor.a = 1.0-min(length(vTextureNormCoord-0.5)*2.0,1.0);\n" +
                "}\n";
    } 
  
    public static class FlippedShader {
        public static final String VertexShader =
                "uniform mat4 uMVPMatrix;\n" +
                "uniform mat4 uSTMatrix;\n" +
                "uniform float uCRatio;\n" +
                "attribute vec4 aPosition;\n" +
                "attribute vec4 aTextureCoord;\n" +
                "varying vec2 vTextureCoord;\n" +
                "varying vec2 vTextureNormCoord;\n" +
                "void main() {\n" +
                "  vec4 scaledPos = aPosition;\n" +
                "  scaledPos.x = scaledPos.x * uCRatio;\n" +
                "  scaledPos.y = -scaledPos.y;\n" +
                "  gl_Position = uMVPMatrix * scaledPos;\n" +
                "  vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" +
                "  vTextureNormCoord = aTextureCoord.xy;\n" +
                "}\n";
        public static final String FragmentShader =
                "#extension GL_OES_EGL_image_external : require\n" +
                "precision mediump float;\n" +
                "varying vec2 vTextureCoord;\n" +
                "varying vec2 vTextureNormCoord;\n" +
                "uniform samplerExternalOES sTexture;\n" +
                "void main() {\n" +
                "  gl_FragColor = texture2D(sTexture, vTextureCoord);\n" +
                "}\n";
    } 
}




Java Source Code List

com.andrewtremblay.openglandroidcamera.CamGLSurfaceView.java
com.andrewtremblay.openglandroidcamera.CamRenderer.java
com.andrewtremblay.openglandroidcamera.CameraFilterActivity.java
com.andrewtremblay.openglandroidcamera.CameraPreview.java
com.andrewtremblay.openglandroidcamera.MyOpenGLShaders.java
com.andrewtremblay.openglandroidcamera.helpers.CameraHelpers.java
com.andrewtremblay.openglandroidcamera.helpers.DebugHelpers.java
com.andrewtremblay.openglandroidcamera.helpers.ImageHelpers.java
com.andrewtremblay.openglandroidcamera.helpers.MediaStorageHelpers.java
com.bigflake.androidmediacodecstuff.ExtractMpegFramesTest.java