├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── cry │ │ └── zerotoopengl │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── cry │ │ │ └── zerotoopengl │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── cry │ └── zerotoopengl │ └── ExampleUnitTest.java ├── art ├── camera_with_opengl.png ├── cmp_camera_video.png ├── complete_video_src.png ├── cover.png ├── frameBuffer.png ├── opengl_draw_process.png ├── process-add-filter.png ├── process-draw-display-encoder.png ├── process-offscreen-render.png ├── process1.png ├── process_encoder.png ├── process_filter.png ├── process_summary.png ├── simple_video_src.png ├── video_decoder_config.png ├── video_decoder_decode.png └── video_source_process.png ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── zero-camera ├── .gitignore ├── README.md ├── blog │ ├── CAMERA_SOURCE.md │ └── VIDEO_SOURCE.md ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── cry │ │ └── zero_camera │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── shader │ │ │ ├── base_fragment.glsl │ │ │ ├── base_vertex.glsl │ │ │ ├── oes_base_fragment.glsl │ │ │ └── oes_base_vertex.glsl │ │ ├── texture_fragment_shader.glsl │ │ └── texture_vertex_shader.glsl │ ├── java │ │ └── com │ │ │ └── cry │ │ │ └── zero_camera │ │ │ ├── activity │ │ │ ├── camera_filter │ │ │ │ ├── CameraCaptureFilterActivity.java │ │ │ │ ├── CameraCaptureFilterView.java │ │ │ │ └── CameraFilterRender.java │ │ │ ├── capture │ │ │ │ ├── CameraCaptureActivity.java │ │ │ │ ├── CameraCaptureView.java │ │ │ │ └── CameraRender.java │ │ │ ├── double_input │ │ │ │ ├── DecodeThread2.java │ │ │ │ ├── DoubleInput2Activity.java │ │ │ │ ├── DoubleInputRender.java │ │ │ │ ├── DoubleInputView.java │ │ │ │ ├── HalfFilter.java │ │ │ │ ├── SpeedControlCallback.java │ │ │ │ └── VideoDecoderCore.java │ │ │ ├── movie │ │ │ │ ├── GenerateMovieActivity.java │ │ │ │ ├── MovieEngine.java │ │ │ │ ├── MovieMaker.java │ │ │ │ └── maker │ │ │ │ │ ├── AnimateGroupPhotoMaker.java │ │ │ │ │ ├── AnimatePhotoMaker.java │ │ │ │ │ └── StaticPhotoMaker.java │ │ │ ├── ppt │ │ │ │ ├── PhotoAnimateSimpleActivity.java │ │ │ │ ├── PickMorePicsActivity.java │ │ │ │ ├── RecordStateManager.java │ │ │ │ ├── TextureMovieEncoder2D.java │ │ │ │ ├── ccc │ │ │ │ │ ├── RecordFBOActivity.java │ │ │ │ │ └── TextureMovieEncoder2.java │ │ │ │ └── render │ │ │ │ │ ├── AnimateAlphaFilter.java │ │ │ │ │ ├── AnimateAlphaFilter2.java │ │ │ │ │ ├── AnimateFilter.java │ │ │ │ │ ├── SimpleRender.java │ │ │ │ │ ├── SimpleRender2.java │ │ │ │ │ └── SimpleRender3.java │ │ │ └── video │ │ │ │ ├── DecodeThread.java │ │ │ │ ├── SpeedControlCallback.java │ │ │ │ ├── VideoCaptureFilterActivity.java │ │ │ │ ├── VideoCaptureFilterView.java │ │ │ │ ├── VideoDecoderCore.java │ │ │ │ └── VideoFilterRender.java │ │ │ ├── camera │ │ │ ├── AspectRatio.java │ │ │ ├── CameraApi14.java │ │ │ ├── CameraSize.java │ │ │ └── ICamera.java │ │ │ ├── preview │ │ │ ├── CameraActivity.java │ │ │ ├── CameraDrawer.java │ │ │ └── CameraView.java │ │ │ ├── ref │ │ │ ├── MiscUtils.java │ │ │ ├── MoviePlayer.java │ │ │ ├── SpeedControlCallback.java │ │ │ ├── TextureMovieEncoder.java │ │ │ ├── TextureMovieEncoder2D.java │ │ │ ├── VideoEncoderCore.java │ │ │ └── gles │ │ │ │ ├── Drawable2d.java │ │ │ │ ├── EglCore.java │ │ │ │ ├── EglSurfaceBase.java │ │ │ │ ├── FlatShadedProgram.java │ │ │ │ ├── FullFrameRect.java │ │ │ │ ├── GeneratedTexture.java │ │ │ │ ├── GlUtil.java │ │ │ │ ├── OffscreenSurface.java │ │ │ │ ├── Sprite2d.java │ │ │ │ ├── Texture2dProgram.java │ │ │ │ └── WindowSurface.java │ │ │ └── render │ │ │ ├── ColorFiler.java │ │ │ ├── OesFilter.java │ │ │ ├── OesRecordFilter.java │ │ │ ├── PhotoFilter.java │ │ │ └── fliter │ │ │ ├── I2DFilter.java │ │ │ ├── PhotoAlphaFilter.java │ │ │ ├── PhotoAlphaFilter2.java │ │ │ ├── PhotoFilter.java │ │ │ ├── PhotoFilter2.java │ │ │ └── Show2DFilter.java │ └── res │ │ ├── layout │ │ ├── activity_camera.xml │ │ ├── activity_decode.xml │ │ ├── activity_double.xml │ │ ├── activity_generate_movie.xml │ │ ├── activity_photo.xml │ │ ├── activity_photo_simple.xml │ │ ├── activity_pick_more_pics.xml │ │ ├── activity_record_fbo.xml │ │ └── simple_photo.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── cry │ └── zero_camera │ └── ExampleUnitTest.java └── zero-common ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── cry │ └── zero_common │ └── ExampleInstrumentedTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── cry │ │ └── zero_common │ │ ├── BitmapHelper.java │ │ ├── FileUtils.java │ │ ├── opengl │ │ ├── Camera1Helper.java │ │ ├── EasyGlUtils.java │ │ ├── GLESUtils.java │ │ ├── GLEnvironment.java │ │ ├── Gl2Utils.java │ │ ├── MatrixUtils.java │ │ ├── PermissionUtils.java │ │ └── VaryTools.java │ │ └── permission │ │ └── ConfirmationDialogFragment.java └── res │ └── values │ └── strings.xml └── test └── java └── com └── cry └── zero_common └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepsadness/ZeroToOpenGL/d4b26b08ecc988a9aa808f8a6e7e44f3686a4ec4/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZeroToOpenGL 2 | OpenGL Tutorial 3 | 4 | 1. [相机使用OpenGL进行预览](https://github.com/deepsadness/ZeroToOpenGL/blob/master/zero-camera/src/main/java/com/cry/zero_camera/CameraActivity.java) 5 | 6 | 2. [相机使用OpenGL进行预览,同时使用MediaCodec进行录制](https://github.com/deepsadness/ZeroToOpenGL/blob/master/zero-camera/src/main/java/com/cry/zero_camera/activity/capture/CameraCaptureActivity.java) 7 | 8 | 3. [相机使用OpenGL进行预览,添加滤镜,同时使用MediaCodec进行录制](https://github.com/deepsadness/ZeroToOpenGL/blob/master/zero-camera/src/main/java/com/cry/zero_camera/activity/camera_filter/CameraCaptureFilterActivity.java) 9 | 10 | 3. [解码视频,添加滤镜,同时使用MediaCodec进行录制](https://github.com/deepsadness/ZeroToOpenGL/blob/master/zero-camera/src/main/java/com/cry/zero_camera/activity/video/CameraCaptureFilterActivity.java) 11 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.cry.zerotoopengl" 7 | minSdkVersion 18 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | compileOptions { 20 | sourceCompatibility 1.8 21 | targetCompatibility 1.8 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(include: ['*.jar'], dir: 'libs') 27 | implementation 'com.android.support:appcompat-v7:28.0.0-rc02' 28 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 29 | testImplementation 'junit:junit:4.12' 30 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 31 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 32 | implementation project(':zero-camera') 33 | } 34 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/cry/zerotoopengl/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.cry.zerotoopengl; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.cry.zerotoopengl", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/cry/zerotoopengl/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cry.zerotoopengl; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | 8 | import com.cry.zero_camera.activity.camera_filter.CameraCaptureFilterActivity; 9 | import com.cry.zero_camera.activity.capture.CameraCaptureActivity; 10 | import com.cry.zero_camera.activity.double_input.DoubleInput2Activity; 11 | import com.cry.zero_camera.activity.movie.GenerateMovieActivity; 12 | import com.cry.zero_camera.activity.video.VideoCaptureFilterActivity; 13 | import com.cry.zero_camera.preview.CameraActivity; 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | } 22 | 23 | public void ToZeroCamera(View view) { 24 | startActivity(new Intent(this, CameraActivity.class)); 25 | } 26 | 27 | public void ToZeroCameraCapture(View view) { 28 | startActivity(new Intent(this, CameraCaptureActivity.class)); 29 | } 30 | 31 | public void ToZeroCameraCaptureFilter(View view) { 32 | startActivity(new Intent(this, CameraCaptureFilterActivity.class)); 33 | } 34 | 35 | public void ToZeroVideoCaptureFilter(View view) { 36 | startActivity(new Intent(this, VideoCaptureFilterActivity.class)); 37 | } 38 | 39 | public void ToZeroDoubleInput2(View view) { 40 | startActivity(new Intent(this, DoubleInput2Activity.class)); 41 | } 42 | 43 | // public void ToPhotoAnimate(View view) { 44 | // startActivity(new Intent(this, PhotoAnimateSimpleActivity.class)); 45 | // } 46 | // 47 | // public void ToRecordFBOActivity(View view) { 48 | // startActivity(new Intent(this, RecordFBOActivity.class)); 49 | // } 50 | 51 | 52 | public void startGenerate(View view) { 53 | startActivity(new Intent(this, GenerateMovieActivity.class)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 |