├── .gitignore
├── LICENSE
├── README.md
├── cge.podspec
├── demo
├── cgeDemo.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── cgeDemo
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Base.lproj
│ │ ├── LaunchScreen.xib
│ │ └── Main.storyboard
│ ├── CameraDemoViewController.h
│ ├── CameraDemoViewController.m
│ ├── FilterDemoViewController.h
│ ├── FilterDemoViewController.m
│ ├── GifDemoViewController.h
│ ├── GifDemoViewController.m
│ ├── Images.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Info.plist
│ ├── MainViewController.h
│ ├── MainViewController.m
│ ├── PlayerDemoController.h
│ ├── PlayerDemoController.m
│ ├── SimpleTestCasesViewController.h
│ ├── SimpleTestCasesViewController.m
│ ├── demoUtils.h
│ ├── demoUtils.m
│ ├── main.m
│ └── res
│ │ ├── 1.mp4
│ │ ├── edgy_amber.png
│ │ ├── filmstock.png
│ │ ├── foggy_night.png
│ │ ├── gitTest0.gif
│ │ ├── gitTest1.gif
│ │ ├── late_sunset.png
│ │ ├── mapping0.jpg
│ │ ├── mask1.png
│ │ ├── soft_warming.png
│ │ ├── test.jpg
│ │ ├── test.mp4
│ │ ├── test1.jpg
│ │ ├── test2.jpg
│ │ ├── wildbird.png
│ │ └── yanzhilei.m4a
└── cgeDemoStatic.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ └── contents.xcworkspacedata
├── demo_ios11
├── cgeDemo
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Base.lproj
│ │ ├── LaunchScreen.xib
│ │ └── Main.storyboard
│ ├── CameraDemoViewController.h
│ ├── CameraDemoViewController.mm
│ ├── Images.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Info.plist
│ ├── MainViewController.h
│ ├── MainViewController.m
│ ├── demoUtils.h
│ ├── demoUtils.m
│ └── main.m
└── demo4ios11.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ └── contents.xcworkspacedata
├── library
├── README.md
├── cge.framework
│ ├── Headers
│ │ ├── cge.h
│ │ ├── cgeAction.h
│ │ ├── cgeAdvancedEffects.h
│ │ ├── cgeAdvancedEffectsCommon.h
│ │ ├── cgeAnimation.h
│ │ ├── cgeAnimationParser.h
│ │ ├── cgeBeautifyFilter.h
│ │ ├── cgeBilateralBlurFilter.h
│ │ ├── cgeBlendFilter.h
│ │ ├── cgeBrightnessAdjust.h
│ │ ├── cgeCVUtilTexture.h
│ │ ├── cgeCameraDevice.h
│ │ ├── cgeCameraFrameRecorder.h
│ │ ├── cgeColorBalanceAdjust.h
│ │ ├── cgeColorLevelAdjust.h
│ │ ├── cgeColorMappingFilter.h
│ │ ├── cgeCommonDefine.h
│ │ ├── cgeContrastAdjust.h
│ │ ├── cgeCrosshatchFilter.h
│ │ ├── cgeCurveAdjust.h
│ │ ├── cgeDataParsingEngine.h
│ │ ├── cgeDynamicFilters.h
│ │ ├── cgeDynamicImageViewHandler.h
│ │ ├── cgeDynamicWaveFilter.h
│ │ ├── cgeEdgeFilter.h
│ │ ├── cgeEmbossFilter.h
│ │ ├── cgeExposureAdjust.h
│ │ ├── cgeFilterBasic.h
│ │ ├── cgeFilters.h
│ │ ├── cgeFrameRecorder.h
│ │ ├── cgeFrameRenderer.h
│ │ ├── cgeGLFunctions.h
│ │ ├── cgeGlobal.h
│ │ ├── cgeHalftoneFilter.h
│ │ ├── cgeHazeFilter.h
│ │ ├── cgeHueAdjust.h
│ │ ├── cgeImageFilter.h
│ │ ├── cgeImageHandler.h
│ │ ├── cgeImageHandlerIOS.h
│ │ ├── cgeImageViewHandler.h
│ │ ├── cgeLerpblurFilter.h
│ │ ├── cgeLiquidationFilter.h
│ │ ├── cgeLookupFilter.h
│ │ ├── cgeMat.h
│ │ ├── cgeMaxValueFilter.h
│ │ ├── cgeMidValueFilter.h
│ │ ├── cgeMinValueFilter.h
│ │ ├── cgeMonochromeAdjust.h
│ │ ├── cgeMosaicBlurFilter.h
│ │ ├── cgeMotionBlurAdjust.h
│ │ ├── cgeMotionFlowFilter.h
│ │ ├── cgeMultipleEffects.h
│ │ ├── cgeMultipleEffectsCommon.h
│ │ ├── cgePlatform_iOS.h
│ │ ├── cgePolarPixellateFilter.h
│ │ ├── cgePolkaDotFilter.h
│ │ ├── cgeProcessingContext.h
│ │ ├── cgeRandomBlurFilter.h
│ │ ├── cgeSaturationAdjust.h
│ │ ├── cgeScene.h
│ │ ├── cgeShaderFunctions.h
│ │ ├── cgeShadowHighlightAdjust.h
│ │ ├── cgeSharedGLContext.h
│ │ ├── cgeSharpenBlurAdjust.h
│ │ ├── cgeSketchFilter.h
│ │ ├── cgeSlideshow.h
│ │ ├── cgeSlideshowSprite2d.h
│ │ ├── cgeSlideshowSprite2dWith3dSpace.h
│ │ ├── cgeSoulStuffFilter.h
│ │ ├── cgeSprite2d.h
│ │ ├── cgeSprite3d.h
│ │ ├── cgeSpriteCommon.h
│ │ ├── cgeStaticAssert.h
│ │ ├── cgeTextureUtils.h
│ │ ├── cgeThread.h
│ │ ├── cgeTiltshiftAdjust.h
│ │ ├── cgeUtilFunctions.h
│ │ ├── cgeVec.h
│ │ ├── cgeVideoCameraViewHandler.h
│ │ ├── cgeVideoFrameRecorder.h
│ │ ├── cgeVideoHandlerCV.h
│ │ ├── cgeVideoPlayer.h
│ │ ├── cgeVideoPlayerViewHandler.h
│ │ ├── cgeVideoWriter.h
│ │ ├── cgeVignetteAdjust.h
│ │ ├── cgeWhiteBalanceAdjust.h
│ │ ├── cgeZoomBlurAdjust.h
│ │ └── libCGE-Prefix.pch
│ ├── Info.plist
│ ├── Modules
│ │ └── module.modulemap
│ └── cge
├── cge
│ ├── include
│ │ ├── cge.h
│ │ ├── cgeAction.h
│ │ ├── cgeAnimation.h
│ │ ├── cgeCommonDefine.h
│ │ ├── cgeFilters.h
│ │ ├── cgeGLFunctions.h
│ │ ├── cgeGlobal.h
│ │ ├── cgeImageFilter.h
│ │ ├── cgeImageHandler.h
│ │ ├── cgeMat.h
│ │ ├── cgeParticleSystem.h
│ │ ├── cgePlatform_iOS.h
│ │ ├── cgeScene.h
│ │ ├── cgeShaderFunctions.h
│ │ ├── cgeSlideshow.h
│ │ ├── cgeSlideshowSprite2d.h
│ │ ├── cgeSlideshowSprite2dWith3dSpace.h
│ │ ├── cgeSprite2d.h
│ │ ├── cgeSprite3d.h
│ │ ├── cgeSpriteCommon.h
│ │ ├── cgeStaticAssert.h
│ │ ├── cgeTextureUtils.h
│ │ ├── cgeThread.h
│ │ ├── cgeVec.h
│ │ └── filters
│ │ │ ├── cgeAdvancedEffects.h
│ │ │ ├── cgeAdvancedEffectsCommon.h
│ │ │ ├── cgeBeautifyFilter.h
│ │ │ ├── cgeBilateralBlurFilter.h
│ │ │ ├── cgeBlendFilter.h
│ │ │ ├── cgeBrightnessAdjust.h
│ │ │ ├── cgeColorBalanceAdjust.h
│ │ │ ├── cgeColorLevelAdjust.h
│ │ │ ├── cgeColorMappingFilter.h
│ │ │ ├── cgeContrastAdjust.h
│ │ │ ├── cgeCrosshatchFilter.h
│ │ │ ├── cgeCurveAdjust.h
│ │ │ ├── cgeDataParsingEngine.h
│ │ │ ├── cgeDynamicFilters.h
│ │ │ ├── cgeDynamicWaveFilter.h
│ │ │ ├── cgeEdgeFilter.h
│ │ │ ├── cgeEmbossFilter.h
│ │ │ ├── cgeExposureAdjust.h
│ │ │ ├── cgeFilterBasic.h
│ │ │ ├── cgeHalftoneFilter.h
│ │ │ ├── cgeHazeFilter.h
│ │ │ ├── cgeHueAdjust.h
│ │ │ ├── cgeLerpblurFilter.h
│ │ │ ├── cgeLiquidationFilter.h
│ │ │ ├── cgeLookupFilter.h
│ │ │ ├── cgeMaxValueFilter.h
│ │ │ ├── cgeMidValueFilter.h
│ │ │ ├── cgeMinValueFilter.h
│ │ │ ├── cgeMonochromeAdjust.h
│ │ │ ├── cgeMosaicBlurFilter.h
│ │ │ ├── cgeMotionBlurAdjust.h
│ │ │ ├── cgeMotionFlowFilter.h
│ │ │ ├── cgeMultipleEffects.h
│ │ │ ├── cgeMultipleEffectsCommon.h
│ │ │ ├── cgePolarPixellateFilter.h
│ │ │ ├── cgePolkaDotFilter.h
│ │ │ ├── cgeRandomBlurFilter.h
│ │ │ ├── cgeSaturationAdjust.h
│ │ │ ├── cgeSelectiveColorAdjust.h
│ │ │ ├── cgeShadowHighlightAdjust.h
│ │ │ ├── cgeSharpenBlurAdjust.h
│ │ │ ├── cgeSketchFilter.h
│ │ │ ├── cgeSoulStuffFilter.h
│ │ │ ├── cgeTiltshiftAdjust.h
│ │ │ ├── cgeVignetteAdjust.h
│ │ │ ├── cgeWhiteBalanceAdjust.h
│ │ │ └── cgeZoomBlurAdjust.h
│ ├── interfaces
│ │ ├── cgeAnimationParser.h
│ │ ├── cgeAnimationParser.mm
│ │ ├── cgeCVUtilTexture.h
│ │ ├── cgeCVUtilTexture.m
│ │ ├── cgeCameraDevice.h
│ │ ├── cgeCameraDevice.m
│ │ ├── cgeCameraFrameRecorder.h
│ │ ├── cgeCameraFrameRecorder.mm
│ │ ├── cgeDynamicImageViewHandler.h
│ │ ├── cgeDynamicImageViewHandler.mm
│ │ ├── cgeFrameRecorder.h
│ │ ├── cgeFrameRecorder.mm
│ │ ├── cgeFrameRenderer.h
│ │ ├── cgeFrameRenderer.mm
│ │ ├── cgeImageHandlerIOS.h
│ │ ├── cgeImageHandlerIOS.mm
│ │ ├── cgeImageViewHandler.h
│ │ ├── cgeImageViewHandler.mm
│ │ ├── cgeProcessingContext.h
│ │ ├── cgeProcessingContext.m
│ │ ├── cgeSharedGLContext.h
│ │ ├── cgeSharedGLContext.m
│ │ ├── cgeUtilFunctions.h
│ │ ├── cgeUtilFunctions.mm
│ │ ├── cgeVideoCameraViewHandler.h
│ │ ├── cgeVideoCameraViewHandler.m
│ │ ├── cgeVideoFrameRecorder.h
│ │ ├── cgeVideoFrameRecorder.mm
│ │ ├── cgeVideoHandlerCV.h
│ │ ├── cgeVideoHandlerCV.mm
│ │ ├── cgeVideoPlayer.h
│ │ ├── cgeVideoPlayer.mm
│ │ ├── cgeVideoPlayerViewHandler.h
│ │ ├── cgeVideoPlayerViewHandler.m
│ │ ├── cgeVideoWriter.h
│ │ └── cgeVideoWriter.mm
│ ├── libCGE-Prefix.pch
│ ├── models
│ │ ├── cgeBuiltinModels.h
│ │ ├── cgeModelCube.h
│ │ └── cgeModelTeapot.h
│ └── src
│ │ ├── animation
│ │ └── cgeAction.cpp
│ │ ├── common
│ │ ├── cgeCommonDefine.cpp
│ │ ├── cgeGLFunctions.cpp
│ │ ├── cgeGlobal.cpp
│ │ ├── cgeImageFilter.cpp
│ │ ├── cgeImageHandler.cpp
│ │ ├── cgeShaderFunctions.cpp
│ │ └── cgeTextureUtils.cpp
│ │ ├── extends
│ │ └── cgeThread.cpp
│ │ ├── filters
│ │ ├── cgeAdvancedEffects.cpp
│ │ ├── cgeAdvancedEffectsCommon.cpp
│ │ ├── cgeBeautifyFilter.cpp
│ │ ├── cgeBilateralBlurFilter.cpp
│ │ ├── cgeBlendFilter.cpp
│ │ ├── cgeBrightnessAdjust.cpp
│ │ ├── cgeColorBalanceAdjust.cpp
│ │ ├── cgeColorLevelAdjust.cpp
│ │ ├── cgeColorMappingFilter.cpp
│ │ ├── cgeContrastAdjust.cpp
│ │ ├── cgeCrosshatchFilter.cpp
│ │ ├── cgeCurveAdjust.cpp
│ │ ├── cgeDataParsingEngine.cpp
│ │ ├── cgeDynamicFilters.cpp
│ │ ├── cgeDynamicWaveFilter.cpp
│ │ ├── cgeEdgeFilter.cpp
│ │ ├── cgeEmbossFilter.cpp
│ │ ├── cgeExposureAdjust.cpp
│ │ ├── cgeFilterBasic.cpp
│ │ ├── cgeHalftoneFilter.cpp
│ │ ├── cgeHazeFilter.cpp
│ │ ├── cgeHueAdjust.cpp
│ │ ├── cgeLerpblurFilter.cpp
│ │ ├── cgeLiquidationFilter.cpp
│ │ ├── cgeLookupFilter.cpp
│ │ ├── cgeMaxValueFilter.cpp
│ │ ├── cgeMidValueFilter.cpp
│ │ ├── cgeMinValueFilter.cpp
│ │ ├── cgeMonochromeAdjust.cpp
│ │ ├── cgeMosaicBlurFilter.cpp
│ │ ├── cgeMotionBlurAdjust.cpp
│ │ ├── cgeMotionFlowFilter.cpp
│ │ ├── cgeMultipleEffects.cpp
│ │ ├── cgeMultipleEffectsCommon.cpp
│ │ ├── cgePolarPixellateFilter.cpp
│ │ ├── cgePolkaDotFilter.cpp
│ │ ├── cgeRandomBlurFilter.cpp
│ │ ├── cgeSaturationAdjust.cpp
│ │ ├── cgeSelectiveColorAdjust.cpp
│ │ ├── cgeShadowHighlightAdjust.cpp
│ │ ├── cgeSharpenBlurAdjust.cpp
│ │ ├── cgeSketchFilter.cpp
│ │ ├── cgeSoulStuffFilter.cpp
│ │ ├── cgeTiltshiftAdjust.cpp
│ │ ├── cgeVignetteAdjust.cpp
│ │ ├── cgeWhiteBalanceAdjust.cpp
│ │ └── cgeZoomBlurAdjust.cpp
│ │ └── sprite
│ │ ├── cgeSprite2d.cpp
│ │ ├── cgeSprite3d.cpp
│ │ └── cgeSpriteCommon.cpp
├── cgeFramework.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── cgeFramework
│ └── Info.plist
├── cgeStatic.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
├── filterLib.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ └── contents.xcworkspacedata
└── filterLib
│ ├── CustomFilter_0.cpp
│ ├── CustomFilter_0.h
│ ├── CustomFilter_N.cpp
│ ├── CustomFilter_N.h
│ ├── CustomHelper.cpp
│ ├── CustomHelper.h
│ ├── cgeCustomFilters.h
│ └── cgeCustomFilters.mm
└── screenshots
├── 0.jpg
├── 1.jpg
├── 2.jpg
├── 3.jpg
└── alipay.jpg
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Wang Yang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/cge.podspec:
--------------------------------------------------------------------------------
1 |
2 | Pod::Spec.new do |s|
3 |
4 | s.name = "cge"
5 | s.version = "3.0.0"
6 | s.summary = "cge source code"
7 | s.description = <<-DESC
8 | libCGE
9 | DESC
10 |
11 | s.homepage = "https://github.com/wysaid/ios-gpuimage-plus"
12 |
13 | s.license = "MIT"
14 | s.author = { "wysaid" => "admin@wysaid.org" }
15 | s.platform = :ios, "7.0"
16 |
17 | s.source = { :git => "https://github.com/wysaid/ios-gpuimage-plus.git", :tag => "#{s.version}" }
18 |
19 | s.prefix_header_file = 'library/cge/libCGE-Prefix.pch'
20 |
21 | s.source_files = 'library/cge/**/*.{h,hpp,c,cpp,mm,m}'
22 | s.ios.framework = 'MobileCoreServices'
23 | end
24 |
--------------------------------------------------------------------------------
/demo/cgeDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demo/cgeDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // cgeDemo
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/demo/cgeDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // cgeDemo
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/demo/cgeDemo/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/demo/cgeDemo/CameraDemoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CameraDemoViewController.h
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/8/31.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CameraDemoViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/demo/cgeDemo/FilterDemoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // cgeDemo
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface FilterDemoViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/demo/cgeDemo/GifDemoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // GifDemoViewController.h
3 | // cgeDemo
4 | //
5 | // Created by wysaid on 15/12/29.
6 | // Copyright © 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface GifDemoViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/demo/cgeDemo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "83.5x83.5",
66 | "scale" : "2x"
67 | }
68 | ],
69 | "info" : {
70 | "version" : 1,
71 | "author" : "xcode"
72 | }
73 | }
--------------------------------------------------------------------------------
/demo/cgeDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 2.4.9
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | NSCameraUsageDescription
26 | just use camera
27 | NSMicrophoneUsageDescription
28 | just use mic
29 | NSPhotoLibraryAddUsageDescription
30 | just use gallery
31 | NSPhotoLibraryUsageDescription
32 | just use album
33 | UILaunchStoryboardName
34 | LaunchScreen
35 | UIMainStoryboardFile
36 | Main
37 | UIRequiredDeviceCapabilities
38 |
39 | armv7
40 |
41 | UISupportedInterfaceOrientations
42 |
43 | UIInterfaceOrientationPortrait
44 |
45 | UISupportedInterfaceOrientations~ipad
46 |
47 | UIInterfaceOrientationPortrait
48 | UIInterfaceOrientationPortraitUpsideDown
49 | UIInterfaceOrientationLandscapeLeft
50 | UIInterfaceOrientationLandscapeRight
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/demo/cgeDemo/MainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.h
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/8/31.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/demo/cgeDemo/MainViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.m
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/8/31.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import "MainViewController.h"
10 | #import "demoUtils.h"
11 | #import "cgeUtilFunctions.h"
12 |
13 | @interface MainViewController()
14 | @property (weak, nonatomic) IBOutlet UIButton *filterDemoBtn;
15 | @property (weak, nonatomic) IBOutlet UIButton *cameraDemoBtn;
16 | @property (weak, nonatomic) IBOutlet UIButton *playerDemoBtn;
17 | @property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
18 |
19 |
20 | @end
21 |
22 | @implementation MainViewController
23 | - (IBAction)filterDemoClicked:(id)sender {
24 | NSLog(@"filter demo clicked!");
25 | }
26 | - (IBAction)cameraDemoClicked:(id)sender {
27 | NSLog(@"camera demo clicked!");
28 | }
29 | - (IBAction)playerDemoClicked:(id)sender {
30 | NSLog(@"player demo clicked!");
31 | }
32 | - (IBAction)testCasesDemoClicked:(id)sender {
33 | NSLog(@"test cases' demo clicked!");
34 | }
35 |
36 |
37 | - (void)viewDidLoad
38 | {
39 | [super viewDidLoad];
40 | NSLog(@"flash screen loaded!");
41 | cgeSetLoadImageCallback(loadImageCallback, loadImageOKCallback, nil);
42 |
43 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
44 | [UIView performWithoutAnimation:^{
45 |
46 | CGRect rt = [[UIScreen mainScreen] bounds];
47 | [_scrollView setFrame:rt];
48 | [_scrollView setScrollEnabled:YES];
49 |
50 | NSArray* subviews = [_scrollView subviews];
51 |
52 | int index = 0;
53 | int buttonWidth = rt.size.width / 2, buttonHeight = 40;
54 |
55 | for(UIView* view in subviews)
56 | {
57 | [view setFrame:CGRectMake(20.0, 80 + index * (buttonHeight + 25), buttonWidth, buttonHeight)];
58 | // [view setBackgroundColor:[UIColor redColor]];
59 | [view.layer setShadowColor:[UIColor redColor].CGColor];
60 | [view.layer setShadowOffset:CGSizeMake(2, 2)];
61 | [view.layer setBorderWidth:1.5];
62 | [view.layer setBorderColor:[UIColor blueColor].CGColor];
63 | [view.layer setShadowOpacity:1.0];
64 | ++index;
65 | }
66 | }];
67 | });
68 |
69 | }
70 |
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/demo/cgeDemo/PlayerDemoController.h:
--------------------------------------------------------------------------------
1 | //
2 | // PlayerDemoController.h
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/8/31.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface PlayerDemoController : UIViewController
12 |
13 | @property(nonatomic)NSURL* defaultVideoURL;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/demo/cgeDemo/SimpleTestCasesViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SimpleTestCasesViewController.h
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/11/30.
6 | // Copyright © 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SimpleTestCasesViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/demo/cgeDemo/demoUtils.h:
--------------------------------------------------------------------------------
1 | //
2 | // demoUtils.h
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/9/6.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | UIImage* loadImageCallback(const char* name, void* arg);
13 |
14 | void loadImageOKCallback(UIImage* img, void* arg);
15 |
16 | extern const char* g_effectConfig[];
17 | extern int g_configNum;
18 |
19 | @interface DemoUtils : NSObject
20 |
21 | + (void)saveVideo :(NSURL*)videoURL;
22 | + (void)saveImage :(UIImage*)image;
23 | + (void)saveImage :(UIImage*)image completionBlock:(void (^)(NSURL*, NSError*))block;
24 |
25 | @end
26 |
27 |
28 | @interface MyButton : UIButton
29 | @property (nonatomic) int index;
30 | @end
31 |
--------------------------------------------------------------------------------
/demo/cgeDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // cgeDemo
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/demo/cgeDemo/res/1.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/1.mp4
--------------------------------------------------------------------------------
/demo/cgeDemo/res/edgy_amber.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/edgy_amber.png
--------------------------------------------------------------------------------
/demo/cgeDemo/res/filmstock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/filmstock.png
--------------------------------------------------------------------------------
/demo/cgeDemo/res/foggy_night.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/foggy_night.png
--------------------------------------------------------------------------------
/demo/cgeDemo/res/gitTest0.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/gitTest0.gif
--------------------------------------------------------------------------------
/demo/cgeDemo/res/gitTest1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/gitTest1.gif
--------------------------------------------------------------------------------
/demo/cgeDemo/res/late_sunset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/late_sunset.png
--------------------------------------------------------------------------------
/demo/cgeDemo/res/mapping0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/mapping0.jpg
--------------------------------------------------------------------------------
/demo/cgeDemo/res/mask1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/mask1.png
--------------------------------------------------------------------------------
/demo/cgeDemo/res/soft_warming.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/soft_warming.png
--------------------------------------------------------------------------------
/demo/cgeDemo/res/test.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/test.jpg
--------------------------------------------------------------------------------
/demo/cgeDemo/res/test.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/test.mp4
--------------------------------------------------------------------------------
/demo/cgeDemo/res/test1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/test1.jpg
--------------------------------------------------------------------------------
/demo/cgeDemo/res/test2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/test2.jpg
--------------------------------------------------------------------------------
/demo/cgeDemo/res/wildbird.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/wildbird.png
--------------------------------------------------------------------------------
/demo/cgeDemo/res/yanzhilei.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/demo/cgeDemo/res/yanzhilei.m4a
--------------------------------------------------------------------------------
/demo/cgeDemoStatic.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // cgeDemo
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // cgeDemo
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/CameraDemoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CameraDemoViewController.h
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/8/31.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CameraDemoViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "83.5x83.5",
66 | "scale" : "2x"
67 | }
68 | ],
69 | "info" : {
70 | "version" : 1,
71 | "author" : "xcode"
72 | }
73 | }
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 2.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | NSCameraUsageDescription
26 | just use camera
27 | NSMicrophoneUsageDescription
28 | just use mic
29 | NSPhotoLibraryAddUsageDescription
30 | Just save to gallery
31 | NSPhotoLibraryUsageDescription
32 | just use album
33 | UILaunchStoryboardName
34 | LaunchScreen
35 | UIMainStoryboardFile
36 | Main
37 | UIRequiredDeviceCapabilities
38 |
39 | armv7
40 |
41 | UISupportedInterfaceOrientations
42 |
43 | UIInterfaceOrientationPortrait
44 |
45 | UISupportedInterfaceOrientations~ipad
46 |
47 | UIInterfaceOrientationPortrait
48 | UIInterfaceOrientationPortraitUpsideDown
49 | UIInterfaceOrientationLandscapeLeft
50 | UIInterfaceOrientationLandscapeRight
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/MainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainViewController.h
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/8/31.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/demoUtils.h:
--------------------------------------------------------------------------------
1 | //
2 | // demoUtils.h
3 | // cgeDemo
4 | //
5 | // Created by WangYang on 15/9/6.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | UIImage* loadImageCallback(const char* name, void* arg);
13 |
14 | void loadImageOKCallback(UIImage* img, void* arg);
15 |
16 | extern const char* g_effectConfig[];
17 | extern int g_configNum;
18 |
19 | @interface DemoUtils : NSObject
20 |
21 | + (void)saveVideo :(NSURL*)videoURL;
22 | + (void)saveImage :(UIImage*)image;
23 | + (void)saveImage :(UIImage*)image completionBlock:(void (^)(NSURL*, NSError*))block;
24 |
25 | @end
26 |
27 |
28 | @interface MyButton : UIButton
29 | @property (nonatomic) int index;
30 | @end
31 |
--------------------------------------------------------------------------------
/demo_ios11/cgeDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // cgeDemo
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/demo_ios11/demo4ios11.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/library/README.md:
--------------------------------------------------------------------------------
1 | # Abstract #
2 |
3 | "filterLib" project is a demo that shows you how to create custom filers with shader.
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeAdvancedEffects.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeAdvancedEffects.h
3 | *
4 | * Created on: 2013-12-13
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEADVANCEDEFFECTS_H_
9 | #define _CGEADVANCEDEFFECTS_H_
10 |
11 | #include "cgeEmbossFilter.h"
12 | #include "cgeEdgeFilter.h"
13 | #include "cgeRandomBlurFilter.h"
14 | #include "cgeBilateralBlurFilter.h"
15 | #include "cgeMosaicBlurFilter.h"
16 | #include "cgeLiquidationFilter.h"
17 | #include "cgeHalftoneFilter.h"
18 | #include "cgePolarPixellateFilter.h"
19 | #include "cgePolkaDotFilter.h"
20 | #include "cgeCrosshatchFilter.h"
21 | #include "cgeHazeFilter.h"
22 | #include "cgeLerpblurFilter.h"
23 |
24 | #include "cgeSketchFilter.h"
25 | #include "cgeBeautifyFilter.h"
26 |
27 | namespace CGE
28 | {
29 | CGEEmbossFilter* createEmbossFilter();
30 | CGEEdgeFilter* createEdgeFilter();
31 | CGEEdgeSobelFilter* createEdgeSobelFilter();
32 | CGERandomBlurFilter* createRandomBlurFilter();
33 | CGEBilateralBlurFilter* createBilateralBlurFilter();
34 | CGEBilateralBlurBetterFilter* createBilateralBlurBetterFilter();
35 | CGEMosaicBlurFilter* createMosaicBlurFilter();
36 | CGELiquidationFilter* getLiquidationFilter(float ratio, float stride);
37 | CGELiquidationFilter* getLiquidationFilter(float width, float height , float stride);
38 |
39 | CGELiquidationNicerFilter* getLiquidationNicerFilter(float ratio, float stride);
40 | CGELiquidationNicerFilter* getLiquidationNicerFilter(float width, float height , float stride);
41 |
42 | CGEHalftoneFilter* createHalftoneFilter();
43 | CGEPolarPixellateFilter* createPolarPixellateFilter();
44 | CGEPolkaDotFilter* createPolkaDotFilter();
45 | CGECrosshatchFilter* createCrosshatchFilter();
46 | CGEHazeFilter* createHazeFilter();
47 | CGELerpblurFilter* createLerpblurFilter();
48 |
49 | CGESketchFilter* createSketchFilter();
50 |
51 | CGEBeautifyFilter* createBeautifyFilter();
52 | }
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeAdvancedEffectsCommon.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeAdvancedEffectsCommon.h
3 | *
4 | * Created on: 2013-12-13
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEADVANCEDEFFECTSCOMMON_H_
9 | #define _CGEADVANCEDEFFECTSCOMMON_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEAdvancedEffectOneStepFilterHelper : public CGEImageFilterInterface
18 | {
19 | public:
20 | CGEAdvancedEffectOneStepFilterHelper(){}
21 | ~CGEAdvancedEffectOneStepFilterHelper(){}
22 | virtual void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
23 |
24 | protected:
25 | static CGEConstString paramStepsName;
26 | };
27 |
28 | class CGEAdvancedEffectTwoStepFilterHelper : public CGEImageFilterInterface
29 | {
30 | public:
31 | CGEAdvancedEffectTwoStepFilterHelper() {}
32 | ~CGEAdvancedEffectTwoStepFilterHelper() {}
33 |
34 | virtual void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
35 |
36 | protected:
37 | static CGEConstString paramStepsName;
38 | };
39 |
40 | }
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeAnimationParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeAnimationParser.h
3 | *
4 | * Created on: 2016-5-16
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #if !defined(cgeAnimationParser_h) && !defined(_CGE_ONLY_FILTERS_)
10 | #define cgeAnimationParser_h
11 |
12 | #import
13 |
14 | namespace CGE
15 | {
16 | //返回值类型为 TimeLine. 避免头文件混乱, 这里使用 void* 作为返回值
17 | void* createSlideshowByConfig(id config, float totalTime);
18 | }
19 |
20 |
21 | #endif /* cgeAnimationParser_h */
22 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeBeautifyFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeBeautifyFilter.h
3 | *
4 | * Created on: 2016-3-22
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_BEAUTIFYFILTER_H_
9 | #define _CGE_BEAUTIFYFILTER_H_
10 |
11 | #include "cgeImageFilter.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEBeautifyFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | bool init();
20 |
21 | void setIntensity(float intensity);
22 |
23 | void setImageSize(float width, float height, float mul = 1.5f);
24 |
25 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
26 |
27 | protected:
28 | float m_intensity;
29 | };
30 | }
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeBilateralBlurFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeBilateralBlurFilter.h
3 | *
4 | * Created on: 2014-4-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_BLIATERALBLUR_H_
9 | #define _CGE_BLIATERALBLUR_H_
10 |
11 | #include "cgeAdvancedEffectsCommon.h"
12 |
13 | namespace CGE
14 | {
15 | //blur with fixed radius.
16 | class CGEBilateralBlurFilter : public CGEAdvancedEffectTwoStepFilterHelper
17 | {
18 | public:
19 | CGEBilateralBlurFilter() {}
20 | ~CGEBilateralBlurFilter() {}
21 |
22 | bool init();
23 |
24 | //Range: value >= 0.0, and 0.0 for the origin. Default: 4.0
25 | virtual void setBlurScale(float value);
26 |
27 | //Range: [1.0, 20.0], none for the origin. Default: 8.0 (It'll show the origin when blurScale value is 1.0
28 | void setDistanceNormalizationFactor(float value);
29 |
30 | protected:
31 | static CGEConstString paramDistanceFactorName;
32 | static CGEConstString paramBlurSamplerScaleName;
33 | static CGEConstString paramBlurFactorsName;
34 | };
35 |
36 | //not blur with fixed radius.
37 | class CGEBilateralBlurBetterFilter : public CGEBilateralBlurFilter
38 | {
39 | public:
40 | bool init();
41 | void setSamplerRadiusLimit(int limit);
42 | virtual void setBlurScale(float value);
43 |
44 | protected:
45 | static CGEConstString paramBlurRadiusName;
46 | int m_limit;
47 | };
48 |
49 | //特殊用法
50 | class CGEBilateralWrapperFilter : public CGEImageFilterInterface
51 | {
52 | public:
53 |
54 | CGEBilateralWrapperFilter() : m_repeatTimes(1) {}
55 | ~CGEBilateralWrapperFilter() { delete m_proc; }
56 |
57 | bool init();
58 |
59 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
60 |
61 |
62 | //Range: [-100, 100]. the value would be transformed basing on the input image size.
63 | void setBlurScale(float value)
64 | {
65 | m_blurScale = value;
66 | }
67 |
68 | //Range: [1.0, 20.0], none for the origin. Default: 8.0 (It'll show the origin when blurScale value is 1.0
69 | void setDistanceNormalizationFactor(float value)
70 | {
71 | m_proc->setDistanceNormalizationFactor(value);
72 | }
73 |
74 | void setRepeatTimes(int n)
75 | {
76 | m_repeatTimes = n;
77 | }
78 |
79 | CGEBilateralBlurFilter *m_proc;
80 | float m_blurScale;
81 | int m_repeatTimes;
82 | };
83 | }
84 |
85 | #endif
86 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeBrightnessAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeBrightnessAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEBRIGHTNESSADJUST_H_
9 | #define _CGEBRIGHTNESSADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEBrightnessFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | void setIntensity(float value); // range: [-1, 1]
20 |
21 | bool init();
22 |
23 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
24 |
25 | protected:
26 | static CGEConstString paramName;
27 |
28 | private:
29 | float m_intensity;
30 | };
31 |
32 | class CGEBrightnessFastFilter : public CGEFastAdjustRGBFilter
33 | {
34 | public:
35 |
36 | void setIntensity(float value);
37 | bool init();
38 | };
39 |
40 | }
41 |
42 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeCVUtilTexture.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeCVUtilTexture.h
3 | *
4 | * Created on: 2015-11-6
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 |
10 | #import
11 | #import
12 | #import
13 |
14 | @interface CGECVUtilTexture : NSObject
15 |
16 | @property(nonatomic, readonly)int textureWidth;
17 | @property(nonatomic, readonly)int textureHeight;
18 |
19 | - (id)initWithSize:(int)width height:(int)height;
20 | - (id)initWithSize:(int)width height:(int)height bufferPool:(CVPixelBufferPoolRef)bufferPool;
21 | - (void)clear;
22 |
23 | - (CVPixelBufferRef)pixelBufferRef;
24 | - (CVOpenGLESTextureRef)textureRef;
25 | - (CVOpenGLESTextureCacheRef)textureCacheRef;
26 | - (GLenum)textureTarget;
27 | - (GLuint)textureID;
28 |
29 | ////////////////////////
30 |
31 | //+ (BOOL)supportsFastTextureUpload;
32 | //
33 | //+ (NSInteger)maximumTextureSizeForThisDevice;
34 | //+ (NSInteger)maximumTextureUnitsForThisDevice;
35 | //
36 | //+ (BOOL)deviceSupportsOpenGLESExtension:(NSString *)extension;
37 | //+ (BOOL)deviceSupportsRedTextures;
38 | //+ (BOOL)deviceSupportsFramebufferReads;
39 |
40 | ////////////////////////
41 |
42 | //便捷方法, 生成较常用的 pixelBufferPoolRef
43 | //此处生成的 CVPixelBufferPoolRef 需要手动调用下方的 release 方法来释放
44 | + (CVPixelBufferPoolRef)makePixelBufferPoolRef:(int)width height:(int)height;
45 | + (void)releasePixelBufferPoolRef:(CVPixelBufferPoolRef)bufferPoolRef;
46 |
47 | //当 bufferPoolRef 为 nil 时, 将额外创建新的bufferPool.
48 | + (instancetype)makeCVTexture:(int)width height:(int)height bufferPool:(CVPixelBufferPoolRef)bufferPoolRef;
49 |
50 | @end
51 |
52 | ////////////////////////////////////////////////
53 |
54 | typedef struct CGECVBufferData
55 | {
56 | void* data;
57 | int width, height;
58 | int bytesPerRow; //May not be the same with (width * channels)
59 | int channels; //'channels' is always 4 for now.
60 |
61 | }CGECVBufferData;
62 |
63 | @interface CGECVUtilTextureWithFramebuffer : CGECVUtilTexture
64 |
65 | - (GLuint)framebuffer;
66 |
67 | - (void)bindTextureFramebuffer;
68 |
69 | //'lockFlag' = 1 (kCVPixelBufferLock_ReadOnly) for readOnly, 0 for read&write.
70 | //glFinish should be called if any gl functions are not finished.
71 | - (CGECVBufferData)mapBuffer:(CVPixelBufferLockFlags)lockFlag;
72 | - (void)unmapBuffer:(CVPixelBufferLockFlags)lockFlag;
73 |
74 | + (instancetype)makeCVTexture:(int)width height:(int)height bufferPool:(CVPixelBufferPoolRef)bufferPoolRef;
75 |
76 | @end
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeColorBalanceAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeColorBalanceAdjust.h
3 | *
4 | * Created on: 2015-3-30
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGECOLORBALANCEADJUST_H_
9 | #define _CGECOLORBALANCEADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEColorBalanceFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | bool init();
20 |
21 | //Range[-1, 1], cyan to red
22 | void setRedShift(float value);
23 |
24 | //Range[-1, 1], magenta to green
25 | void setGreenShift(float value);
26 |
27 | //Range[-1, 1], yellow to blue
28 | void setBlueShift(float value);
29 |
30 | protected:
31 | static CGEConstString paramRedShiftName;
32 | static CGEConstString paramGreenShiftName;
33 | static CGEConstString paramBlueShiftName;
34 |
35 | };
36 |
37 |
38 |
39 | }
40 |
41 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeColorLevelAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeColorLevelAdjust.h
3 | *
4 | * Created on: 2014-1-20
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGECOLORLEVELADJUST_H_
9 | #define _CGECOLORLEVELADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEColorLevelFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 | CGEColorLevelFilter() {}
19 | ~CGEColorLevelFilter() {}
20 |
21 | bool init();
22 |
23 | void setLevel(float dark, float light); // range [0, 1], dark < light
24 | void setGamma(float value); // range [0, 3], default: 1 (origin)
25 |
26 | protected:
27 | static CGEConstString paramLevelName;
28 | static CGEConstString paramGammaName;
29 | };
30 | }
31 |
32 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeColorMappingFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeColorMappingFilter.h
3 | *
4 | * Created on: 2016-8-5
5 | * Author: Wang Yang
6 | * Description: 色彩映射
7 | */
8 |
9 | #ifndef _CGE_COLOR_MAPPING_FILTER_H_
10 | #define _CGE_COLOR_MAPPING_FILTER_H_
11 |
12 | #include "cgeGLFunctions.h"
13 | #include
14 | #include "cgeVec.h"
15 |
16 | namespace CGE
17 | {
18 | class CGEColorMappingFilter : public CGEImageFilterInterface
19 | {
20 | public:
21 | CGEColorMappingFilter();
22 | ~CGEColorMappingFilter();
23 |
24 | enum MapingMode
25 | {
26 | MAPINGMODE_DEFAULT = 0,
27 | MAPINGMODE_BUFFERED_AREA = 0,
28 | MAPINGMODE_SINGLE = 1,
29 | };
30 |
31 | struct MappingArea
32 | {
33 | Vec4f area;
34 | float weight;
35 |
36 | bool operator<(const MappingArea& m) const
37 | {
38 | return weight < m.weight;
39 | }
40 |
41 | };
42 |
43 | static CGEColorMappingFilter* createWithMode(MapingMode mode = MAPINGMODE_DEFAULT);
44 |
45 | virtual void pushMapingArea(const MappingArea& area);
46 | virtual void endPushing(); //pushMapingArea 结束之后调用
47 |
48 | //texWith, texHeight 表示纹理大小
49 | //texUnitWidth, texUnitHeight 表示每个映射单元映射后的分辨率
50 | virtual void setupMapping(GLuint mappingTex, int texWidth, int texHeight, int texUnitWidth, int texUnitHeight);
51 |
52 |
53 | protected:
54 |
55 | GLuint m_mappingTexture;
56 | CGESizei m_texSize; //纹理像素尺寸
57 | CGESizei m_texUnitResolution;
58 | std::vector m_mappingAreas;
59 | };
60 |
61 | }
62 |
63 | #endif // !_CGE_COLOR_MAPPING_FILTER_H_
64 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeContrastAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeContrastAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGECONTRAST_ADJUST_H_
9 | #define _CGECONTRAST_ADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEContrastFilter : public CGEImageFilterInterface
18 | {
19 | public:
20 | CGEContrastFilter(){}
21 | ~CGEContrastFilter(){}
22 |
23 | void setIntensity(float value); //range > 0, and 1 for origin
24 |
25 | bool init();
26 |
27 | protected:
28 | static CGEConstString paramName;
29 | };
30 | }
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeCrosshatchFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeCrosshatchFilter.h
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_CROSSHATCH_H_
9 | #define _CGE_CROSSHATCH_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGECrosshatchFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: (0, 0.1], default: 0.03
20 | void setCrosshatchSpacing(float value);
21 | //Range: (0, 0.01], default: 0.003
22 | void setLineWidth(float value);
23 |
24 | bool init();
25 |
26 | protected:
27 | static CGEConstString paramCrosshatchSpacing;
28 | static CGEConstString paramLineWidth;
29 | };
30 |
31 | }
32 |
33 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeDataParsingEngine.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMultipleEffects.h
3 | *
4 | * Created on: 2013-12-13
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEDATAPARSINGENGINE_H_
9 | #define _CGEDATAPARSINGENGINE_H_
10 |
11 | #include "cgeMultipleEffects.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEDataParsingEngine
16 | {
17 | public:
18 | static CGEImageFilterInterface* adjustParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
19 | static CGEImageFilterInterface* curveParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
20 | static CGEImageFilterInterface* lomoWithCurveParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
21 | static CGEImageFilterInterface* lomoParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
22 | static CGEImageFilterInterface* blendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
23 | static CGEImageFilterInterface* vignetteBlendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
24 | static CGEImageFilterInterface* colorScaleParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
25 | static CGEImageFilterInterface* pixblendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
26 | static CGEImageFilterInterface* krblendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
27 | static CGEImageFilterInterface* vignetteParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
28 | static CGEImageFilterInterface* selfblendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
29 | static CGEImageFilterInterface* colorMulParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
30 | static CGEImageFilterInterface* selectiveColorParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
31 | static CGEImageFilterInterface* blendTileParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
32 | static CGEImageFilterInterface* advancedStyleParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
33 | static CGEImageFilterInterface* beautifyParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
34 | static CGEImageFilterInterface* blurParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
35 | static CGEImageFilterInterface* dynamicParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
36 |
37 | };
38 |
39 | }
40 | #endif /* _CGEDATAPARSINGENGINE_H_ */
41 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeDynamicFilters.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicFilters.h
3 | *
4 | * Created on: 2015-11-18
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEDYNAMICFILTERS_H_
9 | #define _CGEDYNAMICFILTERS_H_
10 |
11 | #include "cgeDynamicWaveFilter.h"
12 | #include "cgeMotionFlowFilter.h"
13 | #include "cgeSoulStuffFilter.h"
14 |
15 | namespace CGE
16 | {
17 | CGEDynamicWaveFilter* createDynamicWaveFilter();
18 | CGEMotionFlowFilter* createMotionFlowFilter();
19 | CGEMotionFlow2Filter* createMotionFlow2Filter();
20 | CGESoulStuffFilter* createSoulStuffFilter();
21 | }
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeDynamicImageViewHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicImageViewHandler.h
3 | *
4 | * Created on: 2015-12-28
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 |
10 | #import "cgeImageViewHandler.h"
11 |
12 | //不适于图片帧特别多且图片分辨率较大的情况(当图片帧过多时将导致内存占用过多)
13 |
14 | @interface CGEDynamicImageViewHandler : CGEImageViewHandler
15 |
16 | @property (nonatomic)int currentImageIndex;
17 | - (size_t)totalImages;
18 |
19 | #pragma mark - 图片相关接口
20 |
21 | /*
22 |
23 | imageConfig (NSDictionary*)
24 |
25 | @{
26 |
27 | @"images" : (NSArray*)images, //要用到的图片 (UIImage*), 分辨率以第一张为准
28 | @"delayTimes" : (NSArray*)delayTimes, //每一张图片的单独持续显示时间 (float), 单位 秒 (与 stableDelayTime 二选一)
29 | @"stableDelayTime" : (float)delayTime, //所有图片的持续显示时间 (与 delayTimes 二选一)
30 |
31 | }
32 |
33 | */
34 |
35 | - (BOOL)setUIImagesWithConfig: (NSDictionary*)imageConfig startAnimation:(BOOL)doAnimation;
36 |
37 | - (BOOL)setGifImage:(CFURLRef)gifUrl;
38 |
39 | - (BOOL)saveAsGif:(NSURL*)gifUrl loopCount:(int)loopCount; //loopCount <= 0 表示不断循环
40 |
41 | /*
42 |
43 | getResultImages返回值: (NSDictionary*)
44 |
45 | @{
46 | @"images" : (NSArray*)images, //结果图片 (UIImage*)
47 | @"delayTimes" : (NSArray*)delayTimes, //每一张图片的单独持续显示时间 (float), 单位 秒
48 |
49 | }
50 |
51 | */
52 |
53 | - (NSDictionary*)getResultImages;
54 |
55 | #pragma mark - 显示相关的接口
56 |
57 | - (BOOL)startAnimation; //当图像少于2张时无法启动动画。
58 | - (void)stopAnimation;
59 |
60 | - (BOOL)jumpToFrame:(int)frameIndex; //直接跳转到指定帧 frameIndex 介于 [0, totalImages-1]
61 |
62 |
63 |
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeDynamicWaveFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicWaveFilter.h
3 | *
4 | * Created on: 2015-11-12
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEDYNAMICWAVE_H_
9 | #define _CGEDYNAMICWAVE_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEDynamicWaveFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | void setIntensity(float value); // The same to setAutoMotionSpeed
20 |
21 | bool init();
22 |
23 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
24 |
25 | void setWaveMotion(float motion);
26 | void setWaveAngle(float angle); //default: 20 (从左往右, 从上往下 包含 angle / PI 个周期)
27 | void setStrength(float strength); //default: 0.01 强度(百分比), 范围 (0, 1)
28 |
29 | void setAutoMotionSpeed(float speed); // Auto motion would be disabled if speed <= 0.
30 |
31 | protected:
32 | static CGEConstString paramMotion;
33 | static CGEConstString paramAngle;
34 | static CGEConstString paramStrength;
35 |
36 | private:
37 |
38 | GLint m_motionLoc;
39 | GLint m_angleLoc;
40 | GLint m_strengthLoc;
41 |
42 | GLfloat m_motion;
43 | GLfloat m_motionSpeed;
44 | GLfloat m_angle;
45 | GLfloat m_strength;
46 | bool m_autoMotion;
47 | };
48 |
49 | }
50 |
51 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeEdgeFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeEdgeFilter.h
3 | *
4 | * Created on: 2013-12-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEEDGE_H_
9 | #define _CGEEDGE_H_
10 |
11 | #include "cgeEmbossFilter.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEEdgeFilter : public CGEEmbossFilter
16 | {
17 | public:
18 | bool init();
19 |
20 | //Intensity Range:[0, 1], 0 for origin, and 1 for the best effect
21 | //Stride: [0, 5]. Default: 2
22 | };
23 |
24 | class CGEEdgeSobelFilter : public CGEEmbossFilter
25 | {
26 | public:
27 |
28 | bool init();
29 |
30 | protected:
31 | //hide
32 | void setAngle(float value) {}
33 | };
34 | }
35 |
36 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeEmbossFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeEmbossFilter.h
3 | *
4 | * Created on: 2013-12-27
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEEMBOSS_H_
9 | #define _CGEEMBOSS_H_
10 |
11 | #include "cgeAdvancedEffectsCommon.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEEmbossFilter : public CGEAdvancedEffectOneStepFilterHelper
16 | {
17 | public:
18 | CGEEmbossFilter(){}
19 | ~CGEEmbossFilter(){}
20 |
21 | //Range: [0, 1], and 0 for the origin, 1 for the best effect.
22 | void setIntensity(float value);
23 |
24 | //Range: [1, 5], default: 2.0. The 'stride' would never affect the speed.
25 | //You should set this when you want to keep the effects
26 | // between two image with the same content but different sizes.
27 | void setStride(float value);
28 |
29 | void setAngle(float value);
30 |
31 | bool init();
32 |
33 | protected:
34 | static CGEConstString paramIntensity;
35 | static CGEConstString paramStride;
36 | static CGEConstString paramNorm;
37 | };
38 |
39 | }
40 |
41 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeExposureAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeExposureAdjust.h
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEEXPOSUREADJUST_H_
9 | #define _CGEEXPOSUREADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEExposureFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: [-10, 10]
20 | void setIntensity(float value);
21 |
22 | bool init();
23 |
24 | protected:
25 | static CGEConstString paramName;
26 |
27 | };
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeFilters.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeFilters.h
3 | *
4 | * Created on: 2014-11-11
5 | * Author: Wang Yang
6 | */
7 |
8 |
9 | #ifndef _CGEFILTERS_H_
10 | #define _CGEFILTERS_H_
11 |
12 | #include "cgeFilterBasic.h"
13 | #include "cgeAdvancedEffects.h"
14 | #include "cgeBlendFilter.h"
15 | #include "cgeDynamicFilters.h"
16 |
17 | #include "cgeMultipleEffectsCommon.h"
18 | #include "cgeMultipleEffects.h"
19 |
20 |
21 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeFrameRecorder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeFrameRecorder.h
3 | *
4 | * Created on: 2015-12-1
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | // 主要作为辅助类使用
10 |
11 | #ifndef _CGE_FRAME_RECORDER_H_
12 | #define _CGE_FRAME_RECORDER_H_
13 |
14 | #import
15 | #import "cgeVideoWriter.h"
16 | #import "cgeFrameRenderer.h"
17 |
18 | @interface CGEFrameRecorder : CGEFrameRenderer
19 |
20 | @property(nonatomic, readonly) NSURL* outputVideoURL;
21 | @property(nonatomic, readonly) NSURL* cacheVideoURL;
22 |
23 | @property(nonatomic, weak) id updateDelegate;
24 | @property(nonatomic, readonly) CGEVideoWriter* videoWriter;
25 | @property(nonatomic, readonly) BOOL isRecording;
26 | @property(nonatomic) BOOL shouldPassthroughAudio;
27 |
28 | #pragma mark - 初始化相关
29 |
30 | - (id)initWithContext :(CGESharedGLContext*)sharedContext;
31 |
32 | // 手动调用释放
33 | - (void)clear;
34 |
35 |
36 | #pragma mark - 录像相关接口
37 |
38 | /*
39 | For example:
40 |
41 | outputSettings = @{
42 |
43 | AVVideoCodecKey : AVVideoCodecH264,
44 | AVVideoWidthKey : @(_videoSize.width),
45 | AVVideoHeightKey : @(_videoSize.height),
46 | AVVideoCompressionPropertiesKey : @{ AVVideoAverageBitRateKey : @(1650000),
47 | AVVideoExpectedSourceFrameRateKey : @(30),
48 | AVVideoMaxKeyFrameIntervalKey : @(30),
49 | "EncodingLiveVideo" : @(YES), //此处必填, 相机实时录制必然为 YES, 已录制视频转录应该为 NO
50 |
51 | "mute" : @(NO) //可选参数, 可不填
52 |
53 | }
54 |
55 | */
56 |
57 | - (void)startRecording :(NSURL*)videoURL size:(CGSize)videoSize;
58 | - (void)startRecording :(NSURL*)videoURL size:(CGSize)videoSize outputSetting:(NSDictionary*)ouputSetting;
59 | - (void)endRecording :(void (^)(void))completionHandler; //默认 压缩程度 中等
60 | - (void)endRecording :(void (^)(void))completionHandler withCompressionLevel:(int)level; //level 取值范围为 [0, 3], 0为不压缩, 1 清晰度较高, 文件较大, 2 中等, 3 清晰度较低, 文件较小
61 |
62 | - (void)endRecording:(void (^)(void))completionHandler withQuality:(NSString*)quality shouldOptimizeForNetworkUse:(BOOL)shouldOptimize; //quality为 AVAssetExportPreset*
63 |
64 | - (void)cancelRecording;
65 |
66 | @end
67 |
68 |
69 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeGlobal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeGlobal.h
3 | *
4 | * Created on: 2014-9-9
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGEGLOBAL_H_
10 | #define _CGEGLOBAL_H_
11 |
12 | #if defined(__APPLE__)
13 | #include
14 | #endif
15 |
16 | #ifdef GLEW_USED
17 | #include "cgePlatform_GLEW.h"
18 | #elif defined(ANDROID_NDK)
19 | #include "cgePlatform_ANDROID.h"
20 | #elif defined(IOS_SDK) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
21 | #include "cgePlatform_iOS.h"
22 | #elif defined(LIBCGE4QT_LIB)
23 | #include "cgePlatform_QT.h"
24 | #endif
25 |
26 |
27 | #ifdef __cplusplus
28 |
29 | namespace CGE
30 | {
31 | //辅助类,全局可用。
32 | class CGEGlobalConfig
33 | {
34 | public:
35 | static int viewWidth, viewHeight;
36 |
37 | #if _CGE_USE_GLOBAL_GL_CACHE_
38 | static GLuint sVertexBufferCommon;
39 | #endif
40 | static float sVertexDataCommon[8];
41 |
42 | enum InitArguments
43 | {
44 | CGE_INIT_LEAST = 0,
45 | CGE_INIT_COMMONVERTEXBUFFER = 0x1,
46 | CGE_INIT_SPRITEBUILTIN = 0x3,
47 | CGE_INIT_DEFAULT = 0xffffffff,
48 | };
49 |
50 | static InitArguments sInitArugment;
51 | };
52 |
53 | //CGE 全局初始化函数。
54 | bool cgeInitialize(int w = CGEGlobalConfig::viewWidth, int h = CGEGlobalConfig::viewHeight, CGEGlobalConfig::InitArguments arg = CGEGlobalConfig::CGE_INIT_DEFAULT);
55 |
56 | inline bool cgeInitialize(int w, int h, GLenum arg)
57 | {
58 | return cgeInitialize(w, h, CGEGlobalConfig::InitArguments(arg));
59 | }
60 |
61 | void cgeInitFilterStatus();
62 |
63 | //CGE 全局清除函数
64 | void cgeCleanup();
65 |
66 | //设置画面显示尺寸
67 | void cgeSetGlobalViewSize(int width, int height);
68 |
69 | }
70 |
71 | #endif
72 |
73 | #ifdef __cplusplus
74 | extern "C" {
75 | #endif
76 |
77 | void cgePrintGLInfo(void);
78 | const char* cgeQueryGLExtensions(void);
79 | bool cgeCheckGLExtension(const char* ext);
80 |
81 | GLuint cgeGenCommonQuadArrayBuffer(void);
82 |
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif
88 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeHalftoneFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHalftoneFilter.h
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEHALFTONEFILTER_H_
9 | #define _CGEHALFTONEFILTER_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEHalftoneFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | bool init();
20 |
21 | //Range: >= 1.
22 | void setDotSize(float value);
23 |
24 | void render2Texture(CGE::CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
25 |
26 | protected:
27 | static CGEConstString paramAspectRatio;
28 | static CGEConstString paramDotPercent;
29 | float m_dotSize;
30 | };
31 |
32 |
33 | }
34 |
35 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeHazeFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHazeFilter.h
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_HAZEFILTER_H_
9 | #define _CGE_HAZEFILTER_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEHazeFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: [-0.5, 0.5], default: 0.2
20 | void setDistance(float value);
21 | //Range: [-0.5, 0.5] defualt: 0
22 | void setSlope(float value);
23 |
24 | //Range: [0, 1], Defualt: all 1
25 | void setHazeColor(float r, float g, float b);
26 |
27 | bool init();
28 |
29 | protected:
30 | static CGEConstString paramDistance;
31 | static CGEConstString paramSlope;
32 | static CGEConstString paramHazeColor;
33 | };
34 | }
35 |
36 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeHueAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHueAdjust.h
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEHUEADJUST_H_
9 | #define _CGEHUEADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEHueAdjustFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: [0, 2π]
20 | void setHue(float value);
21 |
22 | bool init();
23 |
24 | protected:
25 | static CGEConstString paramName;
26 | };
27 |
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeImageHandlerIOS.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeImageHandlerIOS.h
3 | *
4 | * Created on: 2015-8-23
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef __cge__cgeImageHandlerIOS__
10 | #define __cge__cgeImageHandlerIOS__
11 |
12 | #import
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEImageHandlerIOS : public CGE::CGEImageHandler
18 | {
19 | public:
20 |
21 | CGEImageHandlerIOS();
22 | ~CGEImageHandlerIOS();
23 |
24 | bool initWithUIImage(UIImage* uiimage, bool useImageBuffer = true, bool enableRevision = false);
25 |
26 | UIImage* getResultUIImage();
27 |
28 | void processingFilters();
29 |
30 | void swapBufferFBO();
31 |
32 | void enableImageBuffer(bool useBuffer);
33 | bool isImageBufferEnabled() { return m_imageBuffer != nullptr;}
34 |
35 | protected:
36 |
37 | unsigned char* m_imageBuffer;
38 | int m_imageBufferLen;
39 | CGFloat m_imageScale;
40 | };
41 |
42 | }
43 |
44 |
45 | #endif /* defined(__cge__cgeImageHandlerIOS__) */
46 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeImageViewHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeImageViewHandler.h
3 | *
4 | * Created on: 2015-11-18
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #import
10 | #import "cgeSharedGLContext.h"
11 |
12 | #define CGE_IMAGEVIEW_IMAGEHANDLER_IOS CGEImageHandlerIOS
13 |
14 | typedef enum CGEImageViewDisplayMode
15 | {
16 | CGEImageViewDisplayModeScaleToFill,
17 | CGEImageViewDisplayModeAspectFill,
18 | CGEImageViewDisplayModeAspectFit,
19 | CGEImageViewDisplayModeDefault = CGEImageViewDisplayModeScaleToFill
20 | }CGEImageViewDisplayMode;
21 |
22 | @interface CGEImageViewHandler : NSObject
23 |
24 | @property (weak, nonatomic) GLKView* glkView;
25 | @property (nonatomic, readonly)CGESharedGLContext* sharedContext;
26 | @property (nonatomic)CGSize imageSize;
27 | @property (nonatomic)float currentIntensity;
28 |
29 | // 初始化接口
30 |
31 | - (id)initWithGLKView:(GLKView*)glkView;
32 | - (id)initWithGLKView:(GLKView*)glkView withImage:(UIImage*)image;//image 将作为默认使用图像(附加滤镜等)
33 |
34 | #pragma mark - 滤镜设定相关接口
35 |
36 | //通用滤镜配置接口
37 | - (BOOL)setFilterWithConfig :(const char*) config;
38 |
39 | //扩展用法, 设置的filter必须与当前view在同一OpenGL环境下, 否则将出错
40 | - (BOOL)setFilter :(void*)filter;
41 | - (BOOL)setFilterWithWrapper :(void*)filter;
42 |
43 | - (void)flush; //flush filters.
44 |
45 | //通用滤镜强度设定接口, 取值范围 [0, 1]
46 | //注意, 当强度低于1时取得相反效果, 强度高于1时得到增强效果(某些滤镜无效, 如Lerp blur
47 | - (void)setFilterIntensity :(float)value;
48 |
49 | #pragma mark - 图片相关接口
50 |
51 | - (BOOL)setUIImage:(UIImage*) image; //切换图像
52 | - (UIImage*)resultImage; //获取计算结果
53 |
54 | #pragma mark - 显示相关的接口
55 |
56 | - (void)setViewDisplayMode :(CGEImageViewDisplayMode)mode;
57 |
58 | #pragma mark - 其他接口
59 |
60 | //清除view
61 | - (void)clear;
62 |
63 | //辅助接口 (子类使用, 非对外)
64 | - (void*)_getHandler;
65 | - (void)_setupView;
66 |
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeLerpblurFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeLerpblurFilter.h
3 | *
4 | * Created on: 2015-8-3
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_LERPBLURFILTER_H_
9 | #define _CGE_LERPBLURFILTER_H_
10 |
11 | #include "cgeAdvancedEffectsCommon.h"
12 |
13 | namespace CGE
14 | {
15 | class CGELerpblurFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 | ~CGELerpblurFilter();
19 |
20 | enum { MAX_LERP_BLUR_INTENSITY = 12 };
21 |
22 | bool init();
23 |
24 | struct TextureCache
25 | {
26 | GLuint texID;
27 | CGESizei size;
28 | };
29 |
30 | void setBlurLevel(int value);
31 |
32 | void setIntensity(float value);
33 |
34 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
35 |
36 | //图像渐进缩小基数( > 1.1)
37 | void setMipmapBase(float value);
38 |
39 | protected:
40 | void _genMipmaps(int width, int height);
41 | void _clearMipmaps();
42 | int _calcLevel(int len, int level);
43 |
44 | private:
45 |
46 | TextureCache m_texCache[MAX_LERP_BLUR_INTENSITY];
47 | CGESizei m_cacheTargetSize;
48 | int m_intensity;
49 | float m_mipmapBase;
50 | bool m_isBaseChanged;
51 |
52 | FrameBuffer m_framebuffer;
53 |
54 | };
55 |
56 |
57 | }
58 |
59 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeLookupFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeLookupFilter.h
3 | *
4 | * Created on: 2016-7-4
5 | * Author: Wang Yang
6 | * Description: 全图LUT滤镜
7 | */
8 |
9 | #ifndef _CGE_LOOKUPFILTER_H_
10 | #define _CGE_LOOKUPFILTER_H_
11 |
12 | #include "cgeGLFunctions.h"
13 |
14 | namespace CGE
15 | {
16 | class CGELookupFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 | CGELookupFilter();
20 | ~CGELookupFilter();
21 |
22 | bool init();
23 |
24 | inline void setLookupTexture(GLuint tex) { m_lookupTexture = tex; };
25 |
26 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
27 |
28 | inline GLuint& lookupTexture() { return m_lookupTexture; }
29 |
30 | protected:
31 | GLuint m_lookupTexture;
32 | };
33 |
34 | }
35 |
36 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeMaxValueFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMaxValueFilter.h
3 | *
4 | * Created on: 2015-3-20
5 | * Author: Wang Yang
6 | * Description: 最大值滤波
7 | */
8 |
9 | #ifndef _CGE_MAXVALUE_FILTER_H_
10 | #define _CGE_MAXVALUE_FILTER_H_
11 |
12 | #include "cgeMinValueFilter.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMaxValueFilter3x3 : public CGEMinValueFilter3x3
17 | {
18 | public:
19 | const char* getShaderCompFunc();
20 |
21 | };
22 |
23 | class CGEMaxValueFilter3x3Plus : public CGEMinValueFilter3x3Plus
24 | {
25 | public:
26 | const char* getShaderCompFunc();
27 | };
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeMidValueFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMinValueFilter.h
3 | *
4 | * Created on: 2015-9-24
5 | * Author: Wang Yang
6 | * Description: 中值滤波
7 | */
8 |
9 | #ifndef _CGE_MIDVALUE_FILTER_H_
10 | #define _CGE_MIDVALUE_FILTER_H_
11 |
12 | #include "cgeMinValueFilter.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMidValueFilter3x3 : public CGEMinValueFilter3x3
17 | {
18 | public:
19 |
20 | bool init();
21 |
22 | protected:
23 |
24 |
25 | };
26 |
27 | }
28 |
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeMinValueFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMinValueFilter.h
3 | *
4 | * Created on: 2015-3-20
5 | * Author: Wang Yang
6 | * Description: 最小值滤波
7 | */
8 |
9 | #ifndef _CGE_MINVALUE_FILTER_H_
10 | #define _CGE_MINVALUE_FILTER_H_
11 |
12 | #include "cgeGLFunctions.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMinValueFilter3x3: public CGEImageFilterInterface
17 | {
18 | public:
19 |
20 | bool init();
21 |
22 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
23 |
24 | GLint getStepsLocation() { return m_samplerStepsLoc; }
25 |
26 | protected:
27 |
28 | static CGEConstString paramSamplerStepsName;
29 |
30 | virtual const char* getShaderCompFunc();
31 |
32 | void initLocations();
33 |
34 | private:
35 | GLint m_samplerStepsLoc;
36 | };
37 |
38 | class CGEMinValueFilter3x3Plus: public CGEMinValueFilter3x3
39 | {
40 | public:
41 |
42 | bool init();
43 | };
44 |
45 | }
46 |
47 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeMonochromeAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMonochromeAdjust.h
3 | *
4 | * Created on: 2013-12-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEMONOCHROME_ADJUST_H_
9 | #define _CGEMONOCHROME_ADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEMonochromeFilter : public CGEImageFilterInterface
18 | {
19 | public:
20 | CGEMonochromeFilter(){}
21 | ~CGEMonochromeFilter(){}
22 |
23 | bool init();
24 |
25 | void setRed(float value);
26 | void setGreen(float value);
27 | void setBlue(float value);
28 | void setCyan(float value);
29 | void setMagenta(float value);
30 | void setYellow(float value);
31 |
32 | protected:
33 | static CGEConstString paramRed;
34 | static CGEConstString paramGreen;
35 | static CGEConstString paramBlue;
36 | static CGEConstString paramCyan;
37 | static CGEConstString paramMagenta;
38 | static CGEConstString paramYellow;
39 | };
40 | }
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeMosaicBlurFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMosaicBlur.h
3 | *
4 | * Created on: 2014-4-10
5 | * Author: Wang Yang
6 | * Description: 马赛克
7 | */
8 |
9 | #ifndef _CGE_MOSAICBLUR_H_
10 | #define _CGE_MOSAICBLUR_H_
11 |
12 | #include "cgeAdvancedEffectsCommon.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMosaicBlurFilter : public CGEAdvancedEffectOneStepFilterHelper
17 | {
18 | public:
19 |
20 | bool init();
21 |
22 | //Range: value >= 1.0, and 1.0(Default) for the origin. Value is better with integer.
23 | void setBlurPixels(float value);
24 |
25 | protected:
26 | static CGEConstString paramBlurPixelsName;
27 | };
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeMotionBlurAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMotionBlurAdjust.h
3 | *
4 | * Created on: 2014-9-25
5 | */
6 |
7 | #ifndef _CGEMOTIONBLURADJUST_H
8 | #define _CGEMOTIONBLURADJUST_H
9 |
10 | #include "cgeGLFunctions.h"
11 | #include "cgeSharpenBlurAdjust.h"
12 | #include "cgeVec.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMotionBlurFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 | CGEMotionBlurFilter(){}
20 | ~CGEMotionBlurFilter(){}
21 |
22 | bool init();
23 |
24 | // range: radius >= 0.0
25 | void setSamplerRadius(float radius);
26 |
27 | void setAngle(float angle);
28 | void setRadians(float radians);
29 |
30 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
31 |
32 | protected:
33 | static CGEConstString paramSamplerRadiusName;
34 | static CGEConstString paramSamplerStepName;
35 | static CGEConstString paramBlurNormName;
36 |
37 | float m_samplerRadius;
38 | Vec2f m_blurNorm;
39 | };
40 |
41 | class CGEMotionBlurCurveFilter : public CGEMotionBlurFilter
42 | {
43 | public:
44 | bool init();
45 | };
46 | }
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeMotionFlowFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicWaveFilter.h
3 | *
4 | * Created on: 2016-8-12
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef cgeMotionFlowFilter_h
9 | #define cgeMotionFlowFilter_h
10 |
11 | #include "cgeGLFunctions.h"
12 | #include
13 |
14 | namespace CGE
15 | {
16 | class TextureDrawer;
17 |
18 | class CGEMotionFlowFilter : public CGEImageFilterInterface
19 | {
20 | public:
21 | CGEMotionFlowFilter();
22 | ~CGEMotionFlowFilter();
23 |
24 | bool init();
25 |
26 | void setTotalFrames(int frames);
27 | void setFrameDelay(int delayFrame);
28 |
29 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
30 |
31 | protected:
32 |
33 | virtual void pushFrame(GLuint texture);
34 | void clear();
35 |
36 | protected:
37 |
38 | static CGEConstString paramAlphaName;
39 |
40 | std::list m_frameTextures;
41 | std::vector m_totalFrameTextures;
42 | FrameBuffer m_framebuffer;
43 | TextureDrawer* m_drawer;
44 | int m_width, m_height;
45 | int m_totalFrames, m_delayFrames;
46 | int m_delayedFrames;
47 |
48 | float m_dAlpha;
49 | GLint m_alphaLoc;
50 | };
51 |
52 | class CGEMotionFlow2Filter : public CGEMotionFlowFilter
53 | {
54 | public:
55 | CGEMotionFlow2Filter();
56 |
57 | // void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
58 |
59 | protected:
60 | void pushFrame(GLuint texture);
61 |
62 | float m_sizeScaling, m_dSizeScaling;
63 | float m_dsMost;
64 |
65 | bool m_continuouslyTrigger;
66 | };
67 |
68 |
69 |
70 |
71 | }
72 |
73 |
74 | #endif /* cgeMotionFlowFilter_h */
75 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgePlatform_iOS.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgePlatforms.h
3 | *
4 | * Created on: 2013-12-31
5 | * Author: Wang Yang
6 | * Description: load some library and do some essential initialization before compiling.
7 | */
8 |
9 | #ifndef CGEPLATFORMS_H_
10 | #define CGEPLATFORMS_H_
11 |
12 | #import
13 | #import
14 |
15 | #ifndef CGE_SHADER_CONFIG_PLATFORM
16 | #define CGE_SHADER_CONFIG_PLATFORM "\n#ifndef CGE_PLATFORM_IOS\n#define CGE_PLATFORM_IOS\n#endif\n"
17 | #endif
18 |
19 | #if (defined(DEBUG) || defined(_DEBUG) || defined(_CGE_USE_LOG_ERR_))
20 | #include
21 | #endif
22 |
23 | #if (defined(DEBUG) || defined(_DEBUG))
24 |
25 | #ifndef CGE_LOG_INFO
26 | #define CGE_LOG_INFO(...) printf(__VA_ARGS__)
27 | #endif
28 |
29 | #ifndef CGE_LOG_CODE
30 | #define CGE_LOG_CODE(...) __VA_ARGS__
31 | #endif
32 |
33 | #include
34 | #define CGEAssert assert
35 | #else
36 |
37 | #ifndef CGE_LOG_INFO
38 | #define CGE_LOG_INFO(...)
39 | #endif
40 |
41 | #ifndef CGE_LOG_CODE
42 | #define CGE_LOG_CODE(...)
43 |
44 | #define CGEAssert(...)
45 | #endif
46 |
47 | #endif
48 |
49 | #if !defined(CGE_LOG_ERROR) && (defined(_CGE_USE_LOG_ERR_) || defined(DEBUG) || defined(_DEBUG))
50 | #define CGE_LOG_ERROR(str, ...) \
51 | do{\
52 | fprintf(stderr, "\n❌❌❌\n" str "\n❌❌❌\n", ##__VA_ARGS__);\
53 | fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);\
54 | }while(0)
55 | #else
56 | #define CGE_LOG_ERROR(str, ...)
57 | #endif
58 |
59 | #ifndef CGE_UNEXPECTED_ERR_MSG
60 |
61 | #define CGE_UNEXPECTED_ERR_MSG(...)
62 |
63 | #else
64 |
65 | //for important log msg
66 | #define CGE_LOG_KEEP(...) printf(__VA_ARGS__)
67 |
68 | #endif
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgePolarPixellateFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgePolarPixellateFilter.h
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_POLARPIXELLATEFILTER_H_
9 | #define _CGE_POLARPIXELLATEFILTER_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEPolarPixellateFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: [0, 1]
20 | void setCenter(float x, float y);
21 | //Range: [0, 0.2]
22 | void setPixelSize(float x, float y);
23 |
24 | bool init();
25 |
26 | protected:
27 | static CGEConstString paramCenter;
28 | static CGEConstString paramPixelSize;
29 | };
30 | }
31 |
32 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgePolkaDotFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgePolkaDotFilter.h
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_POLKADOTFILTER_H_
9 | #define _CGE_POLKADOTFILTER_H_
10 |
11 | #include "cgeHalftoneFilter.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEPolkaDotFilter : public CGEHalftoneFilter
16 | {
17 | public:
18 | bool init();
19 |
20 | //Range: (0, 1]
21 | void setDotScaling(float value);
22 |
23 | protected:
24 | static CGEConstString paramDotScaling;
25 | };
26 | }
27 |
28 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeProcessingContext.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeProcessingContext.h
3 | *
4 | * Created on: 2015-9-17
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGE_PROCESSINGCONTEXT_H_
10 | #define _CGE_PROCESSINGCONTEXT_H_
11 |
12 | #import
13 |
14 | @interface CGEProcessingContext : NSObject
15 | {
16 | @public void* _contextKey;
17 | }
18 |
19 | @property(nonatomic) dispatch_queue_t contextQueue;
20 |
21 | - (void)syncProcessingQueue:(void (^)(void))block;
22 | - (void)asyncProcessingQueue:(void (^)(void))block;
23 |
24 | /////////////////////////////////////////////
25 |
26 |
27 | + (void)mainSyncProcessingQueue:(void (^)(void))block;
28 | + (void)mainASyncProcessingQueue:(void (^)(void))block;
29 |
30 | #if defined(_CGE_GENERAL_ERROR_TEST_ ) && _CGE_GENERAL_ERROR_TEST_
31 |
32 | + (int)refCount;
33 |
34 | #endif
35 |
36 | @end
37 |
38 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeRandomBlurFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeRandomBlurFilter.h
3 | *
4 | * Created on: 2013-12-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGERANDOMBLUR_H_
9 | #define _CGERANDOMBLUR_H_
10 |
11 | #include "cgeAdvancedEffectsCommon.h"
12 |
13 | namespace CGE
14 | {
15 | class CGERandomBlurFilter : public CGEAdvancedEffectOneStepFilterHelper
16 | {
17 | public:
18 | CGERandomBlurFilter(){}
19 | ~CGERandomBlurFilter(){}
20 |
21 | void setIntensity(float value);
22 | void setSamplerScale(float value);
23 |
24 | bool init();
25 |
26 | protected:
27 | static CGEConstString paramIntensity;
28 | static CGEConstString paramSamplerScale;
29 | static CGEConstString paramSamplerRadius;
30 | };
31 | }
32 |
33 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeSaturationAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSaturationAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGESATURATION_ADJUST_H_
9 | #define _CGESATURATION_ADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 | #include "cgeCurveAdjust.h"
15 |
16 | namespace CGE
17 | {
18 | //This one is based on HSL.
19 | class CGESaturationHSLFilter : public CGEImageFilterInterface
20 | {
21 | public:
22 | CGESaturationHSLFilter(){}
23 | ~CGESaturationHSLFilter(){}
24 |
25 | void setSaturation(float value); // range [-1, 1]
26 |
27 | void setHue(float value); // range [-1, 1]
28 |
29 | void setLum(float lum); // range [-1, 1]
30 |
31 | bool init();
32 |
33 | protected:
34 | static CGEConstString paramSaturationName;
35 | static CGEConstString paramHueName;
36 | static CGEConstString paramLuminanceName;
37 | };
38 |
39 | // You can use the fast one instead(of the one above).
40 | class CGESaturationFilter : public CGEImageFilterInterface
41 | {
42 | public:
43 | CGESaturationFilter() {}
44 | ~CGESaturationFilter() {}
45 | bool init();
46 |
47 | //range: >0, 1 for origin, and saturation would increase if value > 1
48 | void setIntensity(float value);
49 |
50 | protected:
51 | static CGEConstString paramIntensityName;
52 | };
53 |
54 | //This one is based on HSV
55 | class CGESaturationHSVFilter : public CGEImageFilterInterface
56 | {
57 | public:
58 | CGESaturationHSVFilter(){}
59 | ~CGESaturationHSVFilter(){}
60 |
61 | bool init();
62 |
63 | //range: [-1, 1]
64 | void setAdjustColors(float red, float green, float blue,
65 | float magenta, float yellow, float cyan);
66 |
67 | protected:
68 | static CGEConstString paramColor1;
69 | static CGEConstString paramColor2;
70 | };
71 | }
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeShadowHighlightAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeShadowHighlightAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGESHADOWHIGHLIGHT_H_
9 | #define _CGESHADOWHIGHLIGHT_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageHandler.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEShadowHighlightFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 | CGEShadowHighlightFilter(){}
20 | ~CGEShadowHighlightFilter(){}
21 |
22 | void setShadow(float value); // range [-200, 100]
23 | void setHighlight(float value); // range [-100, 200]
24 |
25 | bool init();
26 |
27 | protected:
28 | static CGEConstString paramShadowName;
29 | static CGEConstString paramHighlightName;
30 |
31 | private:
32 | };
33 |
34 | class CGEShadowHighlightFastFilter : public CGEFastAdjustRGBFilter
35 | {
36 | public:
37 | CGEShadowHighlightFastFilter() : m_shadow(0.0f), m_highlight(0.0f) {}
38 | ~CGEShadowHighlightFastFilter() {}
39 |
40 | void setShadowAndHighlight(float shadow, float highlight); //the same to above.
41 |
42 | bool init();
43 |
44 | float getShadow() { return m_shadow; }
45 | float getHighlight() { return m_highlight; }
46 |
47 | private:
48 | float m_shadow, m_highlight;
49 | };
50 |
51 | }
52 |
53 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeSharedGLContext.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSharedGLContext.h
3 | *
4 | * Created on: 2015-7-11
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGE_SHAREDGLCONTEXT_H_
10 | #define _CGE_SHAREDGLCONTEXT_H_
11 |
12 | #import
13 | #import
14 | #import "cgeProcessingContext.h"
15 |
16 | @interface CGESharedGLContext : CGEProcessingContext
17 |
18 | @property(nonatomic,strong) EAGLContext *context;
19 |
20 | - (id)initWithShareGroup:(EAGLSharegroup*)shareGroup;
21 |
22 | - (void)makeCurrent;
23 |
24 | /////////////////////////////////////////////
25 |
26 | + (instancetype)globalGLContext;
27 |
28 | + (BOOL)isGlobalGLContextExist;
29 | //Attention: the pre-created context will be desctroyed after this function.
30 | //So you can use "isGlobalGLContextExist" to see if the context is created.
31 | + (instancetype)bindGlobalGLContext:(EAGLContext*)context;
32 |
33 | + (void)useGlobalGLContext;
34 | + (void)clearGlobalGLContext;
35 |
36 | + (void)globalSyncProcessingQueue:(void (^)(void))block;
37 | + (void)globalAsyncProcessingQueue:(void (^)(void))block;
38 |
39 | +(instancetype)createSharedContext:(CGESharedGLContext*)sharedContext;
40 | +(instancetype)createGlobalSharedContext;
41 |
42 |
43 | @end
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeSketchFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSketchFilter.h
3 | *
4 | * Created on: 2015-3-20
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_SKETCHFILTER_H_
9 | #define _CGE_SKETCHFILTER_H_
10 |
11 | #include "cgeMaxValueFilter.h"
12 | #include "cgeMultipleEffects.h"
13 |
14 | namespace CGE
15 | {
16 | class CGESketchFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 |
20 | CGESketchFilter();
21 | ~CGESketchFilter();
22 |
23 | bool init();
24 |
25 | void setIntensity(float intensity);
26 |
27 | void render2Texture(CGE::CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
28 |
29 | void flush();
30 |
31 | protected:
32 |
33 | static CGEConstString paramCacheTextureName;
34 | static CGEConstString paramIntensityName;
35 |
36 | CGEMaxValueFilter3x3 m_maxValueFilter;
37 | GLuint m_textureCache;
38 | CGESizei m_cacheSize;
39 | };
40 | }
41 |
42 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeSlideshow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSlideshow.h
3 | *
4 | * Created on: 2014-9-9
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #if !defined(_CGESLIDESHOW_H_) && !defined(_CGE_ONLY_FILTERS_)
10 | #define _CGESLIDESHOW_H_
11 |
12 | #include "cgeAction.h"
13 | #include "cgeAnimation.h"
14 | #include "cgeSprite2d.h"
15 | #include "cgeScene.h"
16 |
17 | namespace CGE
18 | {
19 | typedef AnimationInterfaceAbstract TimeLineElem;
20 | typedef TimeLineInterface TimeLine;
21 |
22 | //////////////////////////////////////////////////////////////////////////
23 |
24 | template
25 | class AnimationLogicSpriteInterface : public AnimationType, public virtual SpriteType
26 | {
27 | public:
28 | // AnimationLogicSpriteInterface() : AnimationType(), SpriteType() {}
29 | AnimationLogicSpriteInterface(float start, float end) : AnimationType(start, end), SpriteType() {}
30 | virtual ~AnimationLogicSpriteInterface() {}
31 |
32 | typedef SpriteType SpriteInterfaceType;
33 | typedef AnimationType AnimationInterfaceType;
34 |
35 | virtual void render()
36 | {
37 | for(typename std::vector::iterator iter = this->m_children2Run.begin(); iter != this->m_children2Run.end(); ++iter)
38 | {
39 | (*iter)->_renderWithFather(this);
40 | }
41 | }
42 |
43 | protected:
44 |
45 | virtual float _getZ() const
46 | {
47 | return this->getZ();
48 | }
49 | };
50 |
51 | typedef AnimationWithChildrenInterface AnimAncestor;
52 | typedef AnimationLogicSpriteInterface AnimLogicSprite2d;
53 | // typedef AnimationLogicSpriteInterface AnimLogicSprite2dWith3dSpace;
54 |
55 | }
56 |
57 | #include "cgeSlideshowSprite2d.h"
58 | //#include "cgeSlideshowSprite2dWith3dSpace.h"
59 |
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeSoulStuffFilter.h:
--------------------------------------------------------------------------------
1 | //
2 | // cgeSoulStuffFilter.h
3 | // cgeStatic
4 | //
5 | // Created by Yang Wang on 2017/3/27.
6 | // Mail: admin@wysaid.org
7 | // Copyright © 2017年 wysaid. All rights reserved.
8 | //
9 |
10 | #ifndef cgeSoulStuffFilter_h
11 | #define cgeSoulStuffFilter_h
12 |
13 | #include "cgeGLFunctions.h"
14 | #include "cgeVec.h"
15 |
16 | namespace CGE
17 | {
18 | class CGESoulStuffFilter : public CGEImageFilterInterface
19 | {
20 | public:
21 | CGESoulStuffFilter();
22 | ~CGESoulStuffFilter();
23 |
24 | bool init();
25 |
26 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
27 |
28 | void trigger(float ds, float most);
29 |
30 | void setSoulStuffPos(float x, float y);
31 |
32 | inline void enableContinuouslyTrigger(bool continuouslyTrigger) { m_continuouslyTrigger = continuouslyTrigger; }
33 |
34 | protected:
35 | static CGEConstString paramSoulStuffPos;
36 | static CGEConstString paramSoulStuffScaling;
37 |
38 | GLint m_soulStuffPosLoc, m_soulStuffScalingLoc;
39 | float m_sizeScaling;
40 | float m_dSizeScaling;
41 | float m_dsMost;
42 |
43 | Vec2f m_pos;
44 |
45 | bool m_continuouslyTrigger;
46 | };
47 | }
48 |
49 | #endif /* cgeSoulStuffFilter_h */
50 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeSpriteCommon.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSpriteCommon.h
3 | *
4 | * Created on: 2014-9-25
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #if !defined(_CGESPRITECOMMON_H_) && !defined(_CGE_ONLY_FILTERS_)
10 | #define _CGESPRITECOMMON_H_
11 |
12 | #include "cgeMat.h"
13 | #include "cgeGLFunctions.h"
14 | #include "cgeShaderFunctions.h"
15 |
16 | //简介: 本文件中包含一些sprite需要使用到的辅助类和函数
17 |
18 | namespace CGE
19 | {
20 | // void cgeSpritesInitBuiltin();
21 | // void cgeSpritesCleanupBuiltin();
22 |
23 | class SpriteCommonSettings
24 | {
25 | public:
26 | SpriteCommonSettings();
27 | virtual ~SpriteCommonSettings();
28 |
29 | static CGESizei sCanvasSize; //Sprite2d 被绘制的画布大小(全局, 必须提前设置)
30 |
31 | inline static void sSetCanvasSize(int w, int h)
32 | {
33 | sCanvasSize.set(w, h);
34 | sOrthoProjectionMatrix = Mat4::makeOrtho(0.0f, (float)w, 0.0f, (float)h, -1e3f, 1e3f);
35 | }
36 |
37 | //仅对后面将要创建的 sprite 进行全局默认设置。 对于已经创建好的sprite,可以通过 set*Flip 函数进行单独处理
38 | static void sFlipCanvas(bool x, bool y);
39 | static void sFlipSprite(bool x, bool y);
40 |
41 | CGE_LOG_CODE
42 | (
43 | static std::vector& getDebugManager();
44 | )
45 |
46 | protected:
47 |
48 | static Mat4 sOrthoProjectionMatrix;
49 | static bool sCanvasFlipX, sCanvasFlipY;
50 | static bool sSpriteFlipX, sSpriteFlipY;
51 |
52 | };
53 |
54 | }
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeStaticAssert.h:
--------------------------------------------------------------------------------
1 | /*
2 | @Author: wysaid
3 | @Blog: blog.wysaid.org
4 | @Date: 2013-10-31
5 | */
6 |
7 | #ifndef _CGE_STATICASSERT_H_
8 | #define _CGE_STATICASSERT_H_
9 |
10 | #ifndef _CGE_STATIC_ASSERT_
11 |
12 | #define cgeStaticAssert(value) static_assert(value, "Invalid Parameters!")
13 |
14 | #else
15 |
16 | #if defined(DEBUG) || defined(_DEBUG)
17 |
18 | template
19 | struct _CGEStaticAssert ;
20 |
21 | template<>
22 | struct _CGEStaticAssert { int dummy; };
23 |
24 | template
25 | struct __CGEStaticAssert {};
26 |
27 | #define cgeStaticAssert(value) do \
28 | {\
29 | typedef __CGEStaticAssert<\
30 | sizeof(_CGEStaticAssert<(bool)(value)>)\
31 | > ___CGEStaticAssert;\
32 | } while (0)
33 |
34 | #else
35 |
36 | #define cgeStaticAssert(...)
37 |
38 | #endif
39 |
40 | #endif
41 |
42 | #endif //_CGE_STATICASSERT_H_
43 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeVideoHandlerCV.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeVideoHandlerCV.h
3 | *
4 | * Created on: 2015-9-8
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGEVIDEOHANLERCV_H_
10 | #define _CGEVIDEOHANLERCV_H_
11 |
12 | #import
13 | #import
14 | #import
15 | #import "cgeImageHandler.h"
16 | #import "cgeTextureUtils.h"
17 |
18 | namespace CGE
19 | {
20 | class CGEVideoHandlerCV : public CGEImageHandler
21 | {
22 | public:
23 | CGEVideoHandlerCV();
24 | ~CGEVideoHandlerCV();
25 |
26 | bool initHandler();
27 |
28 | bool updateFrameWithCVImageBuffer(CVImageBufferRef);
29 |
30 | void cleanupYUVTextures();
31 |
32 | void processingFilters();
33 |
34 | inline TextureDrawerYUV* getYUVDrawer() { return m_yuvDrawer; }
35 |
36 | inline void replaceYUVDrawer(TextureDrawerYUV* drawer, bool shouldDelete = true)
37 | {
38 | if(shouldDelete)
39 | delete m_yuvDrawer;
40 | m_yuvDrawer = drawer;
41 | }
42 |
43 | bool reverseTargetSize() { return m_reverseTargetSize; }
44 |
45 | void setReverseTargetSize(bool rev) { m_reverseTargetSize = rev; }
46 |
47 | void swapBufferFBO();
48 |
49 | private:
50 |
51 | CVOpenGLESTextureCacheRef m_videoTextureCacheRef;
52 | CVOpenGLESTextureRef m_lumaTextureRef;
53 | CVOpenGLESTextureRef m_chromaTextureRef;
54 |
55 | TextureDrawerYUV* m_yuvDrawer;
56 | bool m_reverseTargetSize;
57 | };
58 | }
59 |
60 |
61 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeVideoPlayer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeVideoPlayer.h
3 | *
4 | * Created on: 2015-10-14
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #import
10 | #import "cgeFrameRenderer.h"
11 |
12 | typedef enum CGEVideoPlayerLoadingStatus
13 | {
14 | CGEVideoPlayerLoadingStatus_Loading,
15 | CGEVideoPlayerLoadingStatus_LoadOK,
16 | CGEVideoPlayerLoadingStatus_LoadFailed,
17 | }CGEVideoPlayerLoadingStatus;
18 |
19 | @class CGEVideoPlayer;
20 |
21 | @protocol CGEVideoPlayerDelegate
22 |
23 | // 视频播放完毕
24 | @required
25 | - (void)videoPlayingComplete:(CGEVideoPlayer*)player playItem:(AVPlayerItem*)item;
26 |
27 | // 视频分辨率改变 (在 startWithURL 调用后触发)
28 | @optional
29 | - (void)videoResolutionChanged: (CGSize)size;
30 |
31 | // 播放时间更新
32 | @optional
33 | - (void)playTimeUpdated:(CMTime)currentTime;
34 |
35 | // 设定播放时间更新频率 (当未实现 playTimeUpdateInterval 方法时, 默认为一秒 CMTimeMakeWithSeconds(1, 1) )
36 | @optional
37 | - (CMTime)playTimeUpdateInterval;
38 |
39 | // 播放器状态改变
40 | @optional
41 | - (void)playerStatusChanged:(AVPlayerItemStatus)status;
42 |
43 | @end
44 |
45 | @interface CGEVideoPlayer : CGEFrameRenderer
46 |
47 | @property AVPlayer* avPlayer;
48 | @property AVPlayerItemVideoOutput* videoOutput;
49 | @property CADisplayLink* displayLink;
50 | @property(nonatomic) dispatch_semaphore_t videoSema;
51 |
52 | // 视频分辨率
53 | @property(nonatomic) CGSize videoResolution;
54 |
55 | @property(nonatomic, weak) id updateDelegate;
56 | @property(nonatomic, weak) id playerDelegate;
57 |
58 | @property(nonatomic, assign) CGEVideoPlayerLoadingStatus loadingStatus;
59 |
60 | @property(nonatomic, assign) BOOL requestFirstFrameThenPause;
61 |
62 | #pragma mark - 初始化相关
63 |
64 | - (id)initWithContext:(CGESharedGLContext *)sharedContext;
65 |
66 | #pragma mark - 视频 播放/设置 相关
67 |
68 | - (void)startWithURL:(NSURL*) url;
69 | - (void)startWithURL:(NSURL*) url completionHandler:(void (^)(NSError*))block;
70 |
71 | - (void)startWithAsset:(AVAsset*)asset completionHandler:(void (^)(NSError*))block;
72 |
73 | - (BOOL)isPlaying;
74 |
75 | - (void)restart;
76 | - (void)pause;
77 | - (void)resume;
78 |
79 | #pragma mark - --其他--
80 |
81 | // 视频处理方法
82 | - (void)processVideoFrame:(CVPixelBufferRef)pixBuffer;
83 |
84 | @end
85 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeVideoPlayerViewHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeVideoPlayerViewHandler.h
3 | *
4 | * Created on: 2015-10-13
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 |
10 | // 对外接口, 添加较多中文注释
11 |
12 | #import
13 | #import "cgeVideoPlayer.h"
14 |
15 | typedef enum CGEVideoPlayerViewDisplayMode
16 | {
17 | CGEVideoPlayerViewDisplayModeScaleToFill,
18 | CGEVideoPlayerViewDisplayModeAspectFill,
19 | CGEVideoPlayerViewDisplayModeAspectFit,
20 | CGEVideoPlayerViewDisplayModeDefault = CGEVideoPlayerViewDisplayModeScaleToFill
21 | }CGEVideoPlayerViewDisplayMode;
22 |
23 | @interface CGEVideoPlayerViewHandler : NSObject
24 |
25 | @property(nonatomic) CGEVideoPlayer* videoPlayer;
26 |
27 | @property(weak, nonatomic) GLKView* glkView;
28 | @property(nonatomic) float maskAspectRatio; //使用的 mask 宽高比
29 | @property(nonatomic) CGRect viewArea;
30 |
31 | @property(nonatomic, setter=setViewDisplayMode:) CGEVideoPlayerViewDisplayMode displayMode;
32 | @property(nonatomic) BOOL shouldResetViewport;
33 | @property(nonatomic) BOOL shouldUpdateViewport;
34 |
35 | - (id)initWithGLKView:(GLKView*)glkView;
36 |
37 | #pragma mark - 播放相关接口
38 |
39 | //此接口将阻塞当前线程直到开始播放为止
40 | - (void)startWithURL:(NSURL*) url;
41 |
42 | //此接口当block为nil时将自动播放, 当block存在时需要手动开始播放(可写在block内)
43 | - (void)startWithURL:(NSURL*) url completionHandler:(void (^)(NSError*))block;
44 | - (void)startWithAsset:(AVAsset*)asset completionHandler:(void (^)(NSError*))block;
45 |
46 | - (BOOL)isPlaying;
47 |
48 | - (void)restart;
49 | - (void)pause;
50 | - (void)resume;
51 |
52 | - (CMTime)videoDuration; //正在播放的视频总时长
53 | - (CMTime)currentTime; //视频当前播放时间
54 | - (AVPlayerItemStatus)status; //播放器当前状态
55 |
56 | #pragma mark - 滤镜设定相关接口
57 | - (void)setFilterWithConfig :(const char*) config;
58 | - (void)setFilterIntensity :(float)value;
59 |
60 | #pragma mark - mask相关接口
61 |
62 | // mask设定中, 第一个参数填 nil 或者0 表示不使用mask
63 | - (void)setMaskUIImage :(UIImage*)image;
64 | - (void)setMaskTexture :(GLuint)maskTexture textureAspectRatio:(float)aspectRatio;
65 | - (BOOL)isUsingMask;
66 |
67 | #pragma mark - 显示相关的接口
68 |
69 | - (void)setViewDisplayMode :(CGEVideoPlayerViewDisplayMode)mode;
70 |
71 | #pragma mark - 其他接口
72 |
73 | - (void)clear;
74 |
75 | - (void)_updateViewArea; //For Private Usage. (Child Class)
76 | - (void)_updateViewArea:(float)ratio;
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeVignetteAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeVignetteAdjust.h
3 | *
4 | * Created on: 2014-1-22
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEVIGNETTEADJUST_H_
9 | #define _CGEVIGNETTEADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 |
16 | class CGEVignetteFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 |
20 | virtual bool init();
21 |
22 | void setVignetteCenter(float x, float y); //Range: [0, 1], and 0.5 for the center.
23 | void setVignette(float start, float range); //Range: [0, 1]
24 |
25 | protected:
26 | static CGEConstString paramVignetteCenterName;
27 | static CGEConstString paramVignetteName;
28 | };
29 |
30 | class CGEVignetteExtFilter : public CGEVignetteFilter
31 | {
32 | public:
33 | bool init();
34 |
35 | void setVignetteColor(float r, float g, float b);
36 |
37 | protected:
38 | static CGEConstString paramVignetteColor;
39 | };
40 |
41 | }
42 |
43 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeWhiteBalanceAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeWhiteBalanceAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEWHITEBALANCE_H_
9 | #define _CGEWHITEBALANCE_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEWhiteBalanceFilter : public CGEImageFilterInterface
18 | {
19 | public:
20 | CGEWhiteBalanceFilter(){}
21 | ~CGEWhiteBalanceFilter(){}
22 |
23 | void setTemperature(float value); //range: -1~1, 0 for origin
24 | void setTint(float value);// range 0~5, 1 for origin
25 |
26 | bool init();
27 |
28 | protected:
29 | static CGEConstString paramTemperatureName;
30 | static CGEConstString paramTintName;
31 | };
32 |
33 | class CGEWhiteBalanceFastFilter : public CGEImageFilterInterface
34 | {
35 | public:
36 | CGEWhiteBalanceFastFilter() : m_temp(0.0f), m_tint(1.0f) {}
37 | ~CGEWhiteBalanceFastFilter() {}
38 |
39 | void setTempAndTint(float temp, float tint);
40 |
41 | bool init();
42 |
43 | float getTemp() { return m_temp; }
44 | float getTint() { return m_tint; }
45 |
46 | protected:
47 | static CGEConstString paramBalanceName;
48 |
49 | private:
50 | float m_temp, m_tint;
51 | };
52 |
53 | }
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/library/cge.framework/Headers/cgeZoomBlurAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeZoomBlurAdjust.h
3 | *
4 | * Created on: 2014-9-17
5 | */
6 |
7 | #ifndef _CGEZOOMBLURADJUST_H
8 | #define _CGEZOOMBLURADJUST_H
9 |
10 | #include "cgeGLFunctions.h"
11 |
12 | namespace CGE
13 | {
14 | //适合向外扩散的情况
15 | class CGEZoomBlurFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 | CGEZoomBlurFilter(){}
19 | ~CGEZoomBlurFilter(){}
20 |
21 | void setCenter(float x, float y); // texture coordinate
22 | void setIntensity(float strength); // range: [0, 1]
23 |
24 | bool init();
25 |
26 | protected:
27 | static CGEConstString paramCenterName;
28 | static CGEConstString paramIntensityName;
29 | };
30 |
31 | //折中方案, 兼顾向外与向内
32 | class CGEZoomBlur2Filter : public CGEZoomBlurFilter
33 | {
34 | public:
35 | CGEZoomBlur2Filter() {}
36 | ~CGEZoomBlur2Filter() {}
37 |
38 | bool init();
39 |
40 | protected:
41 | static CGEConstString paramStepsName;
42 |
43 | };
44 |
45 | }
46 |
47 | #endif
--------------------------------------------------------------------------------
/library/cge.framework/Headers/libCGE-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // libCGE-Prefix.pch
3 | // cge
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #ifndef cge_libCGE_Prefix_pch
10 | #define cge_libCGE_Prefix_pch
11 |
12 | #ifdef __OBJC__
13 | #import
14 | #endif
15 |
16 | // Include any system framework and library headers here that should be included in all compilation units.
17 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
18 |
19 | //仅作为编译文件内区分sdk版本使用, (V2.0.0开始)不再用来区分头文件 (各个版本分开指定相应的头文件)
20 | #ifndef IOS_SDK
21 | #define IOS_SDK 1
22 | #endif
23 |
24 | #ifndef CGE_TEXTURE_PREMULTIPLIED
25 | #define CGE_TEXTURE_PREMULTIPLIED 1
26 | #endif
27 |
28 | #ifndef _CGE_ONLY_FILTERS_
29 | #define _CGE_ONLY_FILTERS_ 1
30 | #endif
31 |
32 | #define _CGE_USE_GLOBAL_GL_CACHE_ 0
33 |
34 | //_CGE_STATIC_ASSERT_ 为过时设定, 用于兼容不支持 C++ 11 static_assert 配置
35 | //#define _CGE_STATIC_ASSERT_ 1
36 |
37 | //定义 _CGE_USE_LOG_ERR_ 可以强制开启所有的cge内建 error log
38 | #define _CGE_USE_LOG_ERR_ 1
39 |
40 | #define _CGE_DISABLE_GLOBALCONTEXT_ 1
41 |
42 | #define CGE_NSLog(...) NSLog(__VA_ARGS__)
43 |
44 | #if defined(DEBUG) || defined(_DEBUG)
45 |
46 | //#define _CGE_SHOW_RENDER_FPS_ 1
47 | #define CGE_NSLog_Code(...) __VA_ARGS__
48 | #define CGE_NSAssert NSAssert
49 |
50 | #else
51 |
52 | #define CGE_NSLog_Code(...)
53 | #define CGE_NSAssert(...)
54 |
55 | #endif
56 |
57 | #define CGE_GLK_TEXTURE_OPTION @{GLKTextureLoaderApplyPremultiplication : @(YES)}
58 |
59 | //#define CGE_USE_OPENAL 1
60 |
61 | //#define _CGE_GENERAL_ERROR_TEST_ 1
62 | #if defined(_CGE_GENERAL_ERROR_TEST_) && _CGE_GENERAL_ERROR_TEST_
63 | #define CGE_UNEXPECTED_ERR_MSG(...) __VA_ARGS__
64 | #else
65 | #define CGE_UNEXPECTED_ERR_MSG(...)
66 | #endif
67 |
68 | //#define CGE_USE_WEBP 1
69 |
70 | //#define CGE_USE_RAPIDJSON 1
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/library/cge.framework/Info.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/library/cge.framework/Info.plist
--------------------------------------------------------------------------------
/library/cge.framework/Modules/module.modulemap:
--------------------------------------------------------------------------------
1 | framework module cge {
2 | umbrella header "cge.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/library/cge.framework/cge:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/library/cge.framework/cge
--------------------------------------------------------------------------------
/library/cge/include/cgeFilters.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeFilters.h
3 | *
4 | * Created on: 2014-11-11
5 | * Author: Wang Yang
6 | */
7 |
8 |
9 | #ifndef _CGEFILTERS_H_
10 | #define _CGEFILTERS_H_
11 |
12 | #include "cgeFilterBasic.h"
13 | #include "cgeAdvancedEffects.h"
14 | #include "cgeBlendFilter.h"
15 | #include "cgeDynamicFilters.h"
16 |
17 | #include "cgeMultipleEffectsCommon.h"
18 | #include "cgeMultipleEffects.h"
19 |
20 |
21 | #endif
--------------------------------------------------------------------------------
/library/cge/include/cgeGlobal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeGlobal.h
3 | *
4 | * Created on: 2014-9-9
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGEGLOBAL_H_
10 | #define _CGEGLOBAL_H_
11 |
12 | #if defined(__APPLE__)
13 | #include
14 | #endif
15 |
16 | #ifdef GLEW_USED
17 | #include "cgePlatform_GLEW.h"
18 | #elif defined(ANDROID_NDK)
19 | #include "cgePlatform_ANDROID.h"
20 | #elif defined(IOS_SDK) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
21 | #include "cgePlatform_iOS.h"
22 | #elif defined(LIBCGE4QT_LIB)
23 | #include "cgePlatform_QT.h"
24 | #endif
25 |
26 |
27 | #ifdef __cplusplus
28 |
29 | namespace CGE
30 | {
31 | //辅助类,全局可用。
32 | class CGEGlobalConfig
33 | {
34 | public:
35 | static int viewWidth, viewHeight;
36 |
37 | #if _CGE_USE_GLOBAL_GL_CACHE_
38 | static GLuint sVertexBufferCommon;
39 | #endif
40 | static float sVertexDataCommon[8];
41 |
42 | enum InitArguments
43 | {
44 | CGE_INIT_LEAST = 0,
45 | CGE_INIT_COMMONVERTEXBUFFER = 0x1,
46 | CGE_INIT_SPRITEBUILTIN = 0x3,
47 | CGE_INIT_DEFAULT = 0xffffffff,
48 | };
49 |
50 | static InitArguments sInitArugment;
51 | };
52 |
53 | //CGE 全局初始化函数。
54 | bool cgeInitialize(int w = CGEGlobalConfig::viewWidth, int h = CGEGlobalConfig::viewHeight, CGEGlobalConfig::InitArguments arg = CGEGlobalConfig::CGE_INIT_DEFAULT);
55 |
56 | inline bool cgeInitialize(int w, int h, GLenum arg)
57 | {
58 | return cgeInitialize(w, h, CGEGlobalConfig::InitArguments(arg));
59 | }
60 |
61 | void cgeInitFilterStatus();
62 |
63 | //CGE 全局清除函数
64 | void cgeCleanup();
65 |
66 | //设置画面显示尺寸
67 | void cgeSetGlobalViewSize(int width, int height);
68 |
69 | }
70 |
71 | #endif
72 |
73 | #ifdef __cplusplus
74 | extern "C" {
75 | #endif
76 |
77 | void cgePrintGLInfo(void);
78 | const char* cgeQueryGLExtensions(void);
79 | bool cgeCheckGLExtension(const char* ext);
80 |
81 | GLuint cgeGenCommonQuadArrayBuffer(void);
82 |
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif
88 |
--------------------------------------------------------------------------------
/library/cge/include/cgeParticleSystem.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeParticleSystem.h
3 | *
4 | * Created on: 2014-10-17
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGEPARTICLESYSTEM_H_
10 | #define _CGEPARTICLESYSTEM_H_
11 |
12 | #include "cgeMat.h"
13 | #include "cgeGLFunctions.h"
14 | #include "cgeShaderFunctions.h"
15 |
16 | //简介: 本文件中包含cge的粒子系统实现
17 |
18 | namespace CGE
19 | {
20 |
21 | }
22 |
23 |
24 | #endif
--------------------------------------------------------------------------------
/library/cge/include/cgePlatform_iOS.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgePlatforms.h
3 | *
4 | * Created on: 2013-12-31
5 | * Author: Wang Yang
6 | * Description: load some library and do some essential initialization before compiling.
7 | */
8 |
9 | #ifndef CGEPLATFORMS_H_
10 | #define CGEPLATFORMS_H_
11 |
12 | #import
13 | #import
14 |
15 | #ifndef CGE_SHADER_CONFIG_PLATFORM
16 | #define CGE_SHADER_CONFIG_PLATFORM "\n#ifndef CGE_PLATFORM_IOS\n#define CGE_PLATFORM_IOS\n#endif\n"
17 | #endif
18 |
19 | #if (defined(DEBUG) || defined(_DEBUG) || defined(_CGE_USE_LOG_ERR_))
20 | #include
21 | #endif
22 |
23 | #if (defined(DEBUG) || defined(_DEBUG))
24 |
25 | #ifndef CGE_LOG_INFO
26 | #define CGE_LOG_INFO(...) printf(__VA_ARGS__)
27 | #endif
28 |
29 | #ifndef CGE_LOG_CODE
30 | #define CGE_LOG_CODE(...) __VA_ARGS__
31 | #endif
32 |
33 | #include
34 | #define CGEAssert assert
35 | #else
36 |
37 | #ifndef CGE_LOG_INFO
38 | #define CGE_LOG_INFO(...)
39 | #endif
40 |
41 | #ifndef CGE_LOG_CODE
42 | #define CGE_LOG_CODE(...)
43 |
44 | #define CGEAssert(...)
45 | #endif
46 |
47 | #endif
48 |
49 | #if !defined(CGE_LOG_ERROR) && (defined(_CGE_USE_LOG_ERR_) || defined(DEBUG) || defined(_DEBUG))
50 | #define CGE_LOG_ERROR(str, ...) \
51 | do{\
52 | fprintf(stderr, "\n❌❌❌\n" str "\n❌❌❌\n", ##__VA_ARGS__);\
53 | fprintf(stderr, "%s:%d\n", __FILE__, __LINE__);\
54 | }while(0)
55 | #else
56 | #define CGE_LOG_ERROR(str, ...)
57 | #endif
58 |
59 | #ifndef CGE_UNEXPECTED_ERR_MSG
60 |
61 | #define CGE_UNEXPECTED_ERR_MSG(...)
62 |
63 | #else
64 |
65 | //for important log msg
66 | #define CGE_LOG_KEEP(...) printf(__VA_ARGS__)
67 |
68 | #endif
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/library/cge/include/cgeSlideshow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSlideshow.h
3 | *
4 | * Created on: 2014-9-9
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #if !defined(_CGESLIDESHOW_H_) && !defined(_CGE_ONLY_FILTERS_)
10 | #define _CGESLIDESHOW_H_
11 |
12 | #include "cgeAction.h"
13 | #include "cgeAnimation.h"
14 | #include "cgeSprite2d.h"
15 | #include "cgeScene.h"
16 |
17 | namespace CGE
18 | {
19 | typedef AnimationInterfaceAbstract TimeLineElem;
20 | typedef TimeLineInterface TimeLine;
21 |
22 | //////////////////////////////////////////////////////////////////////////
23 |
24 | template
25 | class AnimationLogicSpriteInterface : public AnimationType, public virtual SpriteType
26 | {
27 | public:
28 | // AnimationLogicSpriteInterface() : AnimationType(), SpriteType() {}
29 | AnimationLogicSpriteInterface(float start, float end) : AnimationType(start, end), SpriteType() {}
30 | virtual ~AnimationLogicSpriteInterface() {}
31 |
32 | typedef SpriteType SpriteInterfaceType;
33 | typedef AnimationType AnimationInterfaceType;
34 |
35 | virtual void render()
36 | {
37 | for(typename std::vector::iterator iter = this->m_children2Run.begin(); iter != this->m_children2Run.end(); ++iter)
38 | {
39 | (*iter)->_renderWithFather(this);
40 | }
41 | }
42 |
43 | protected:
44 |
45 | virtual float _getZ() const
46 | {
47 | return this->getZ();
48 | }
49 | };
50 |
51 | typedef AnimationWithChildrenInterface AnimAncestor;
52 | typedef AnimationLogicSpriteInterface AnimLogicSprite2d;
53 | // typedef AnimationLogicSpriteInterface AnimLogicSprite2dWith3dSpace;
54 |
55 | }
56 |
57 | #include "cgeSlideshowSprite2d.h"
58 | //#include "cgeSlideshowSprite2dWith3dSpace.h"
59 |
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/library/cge/include/cgeSpriteCommon.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSpriteCommon.h
3 | *
4 | * Created on: 2014-9-25
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #if !defined(_CGESPRITECOMMON_H_) && !defined(_CGE_ONLY_FILTERS_)
10 | #define _CGESPRITECOMMON_H_
11 |
12 | #include "cgeMat.h"
13 | #include "cgeGLFunctions.h"
14 | #include "cgeShaderFunctions.h"
15 |
16 | //简介: 本文件中包含一些sprite需要使用到的辅助类和函数
17 |
18 | namespace CGE
19 | {
20 | // void cgeSpritesInitBuiltin();
21 | // void cgeSpritesCleanupBuiltin();
22 |
23 | class SpriteCommonSettings
24 | {
25 | public:
26 | SpriteCommonSettings();
27 | virtual ~SpriteCommonSettings();
28 |
29 | static CGESizei sCanvasSize; //Sprite2d 被绘制的画布大小(全局, 必须提前设置)
30 |
31 | inline static void sSetCanvasSize(int w, int h)
32 | {
33 | sCanvasSize.set(w, h);
34 | sOrthoProjectionMatrix = Mat4::makeOrtho(0.0f, (float)w, 0.0f, (float)h, -1e3f, 1e3f);
35 | }
36 |
37 | //仅对后面将要创建的 sprite 进行全局默认设置。 对于已经创建好的sprite,可以通过 set*Flip 函数进行单独处理
38 | static void sFlipCanvas(bool x, bool y);
39 | static void sFlipSprite(bool x, bool y);
40 |
41 | CGE_LOG_CODE
42 | (
43 | static std::vector& getDebugManager();
44 | )
45 |
46 | protected:
47 |
48 | static Mat4 sOrthoProjectionMatrix;
49 | static bool sCanvasFlipX, sCanvasFlipY;
50 | static bool sSpriteFlipX, sSpriteFlipY;
51 |
52 | };
53 |
54 | }
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/library/cge/include/cgeStaticAssert.h:
--------------------------------------------------------------------------------
1 | /*
2 | @Author: wysaid
3 | @Blog: blog.wysaid.org
4 | @Date: 2013-10-31
5 | */
6 |
7 | #ifndef _CGE_STATICASSERT_H_
8 | #define _CGE_STATICASSERT_H_
9 |
10 | #ifndef _CGE_STATIC_ASSERT_
11 |
12 | #define cgeStaticAssert(value) static_assert(value, "Invalid Parameters!")
13 |
14 | #else
15 |
16 | #if defined(DEBUG) || defined(_DEBUG)
17 |
18 | template
19 | struct _CGEStaticAssert ;
20 |
21 | template<>
22 | struct _CGEStaticAssert { int dummy; };
23 |
24 | template
25 | struct __CGEStaticAssert {};
26 |
27 | #define cgeStaticAssert(value) do \
28 | {\
29 | typedef __CGEStaticAssert<\
30 | sizeof(_CGEStaticAssert<(bool)(value)>)\
31 | > ___CGEStaticAssert;\
32 | } while (0)
33 |
34 | #else
35 |
36 | #define cgeStaticAssert(...)
37 |
38 | #endif
39 |
40 | #endif
41 |
42 | #endif //_CGE_STATICASSERT_H_
43 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeAdvancedEffects.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeAdvancedEffects.h
3 | *
4 | * Created on: 2013-12-13
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEADVANCEDEFFECTS_H_
9 | #define _CGEADVANCEDEFFECTS_H_
10 |
11 | #include "cgeEmbossFilter.h"
12 | #include "cgeEdgeFilter.h"
13 | #include "cgeRandomBlurFilter.h"
14 | #include "cgeBilateralBlurFilter.h"
15 | #include "cgeMosaicBlurFilter.h"
16 | #include "cgeLiquidationFilter.h"
17 | #include "cgeHalftoneFilter.h"
18 | #include "cgePolarPixellateFilter.h"
19 | #include "cgePolkaDotFilter.h"
20 | #include "cgeCrosshatchFilter.h"
21 | #include "cgeHazeFilter.h"
22 | #include "cgeLerpblurFilter.h"
23 |
24 | #include "cgeSketchFilter.h"
25 | #include "cgeBeautifyFilter.h"
26 |
27 | namespace CGE
28 | {
29 | CGEEmbossFilter* createEmbossFilter();
30 | CGEEdgeFilter* createEdgeFilter();
31 | CGEEdgeSobelFilter* createEdgeSobelFilter();
32 | CGERandomBlurFilter* createRandomBlurFilter();
33 | CGEBilateralBlurFilter* createBilateralBlurFilter();
34 | CGEBilateralBlurBetterFilter* createBilateralBlurBetterFilter();
35 | CGEMosaicBlurFilter* createMosaicBlurFilter();
36 | CGELiquidationFilter* getLiquidationFilter(float ratio, float stride);
37 | CGELiquidationFilter* getLiquidationFilter(float width, float height , float stride);
38 |
39 | CGELiquidationNicerFilter* getLiquidationNicerFilter(float ratio, float stride);
40 | CGELiquidationNicerFilter* getLiquidationNicerFilter(float width, float height , float stride);
41 |
42 | CGEHalftoneFilter* createHalftoneFilter();
43 | CGEPolarPixellateFilter* createPolarPixellateFilter();
44 | CGEPolkaDotFilter* createPolkaDotFilter();
45 | CGECrosshatchFilter* createCrosshatchFilter();
46 | CGEHazeFilter* createHazeFilter();
47 | CGELerpblurFilter* createLerpblurFilter();
48 |
49 | CGESketchFilter* createSketchFilter();
50 |
51 | CGEBeautifyFilter* createBeautifyFilter();
52 | }
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeAdvancedEffectsCommon.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeAdvancedEffectsCommon.h
3 | *
4 | * Created on: 2013-12-13
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEADVANCEDEFFECTSCOMMON_H_
9 | #define _CGEADVANCEDEFFECTSCOMMON_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEAdvancedEffectOneStepFilterHelper : public CGEImageFilterInterface
18 | {
19 | public:
20 | CGEAdvancedEffectOneStepFilterHelper(){}
21 | ~CGEAdvancedEffectOneStepFilterHelper(){}
22 | virtual void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
23 |
24 | protected:
25 | static CGEConstString paramStepsName;
26 | };
27 |
28 | class CGEAdvancedEffectTwoStepFilterHelper : public CGEImageFilterInterface
29 | {
30 | public:
31 | CGEAdvancedEffectTwoStepFilterHelper() {}
32 | ~CGEAdvancedEffectTwoStepFilterHelper() {}
33 |
34 | virtual void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
35 |
36 | protected:
37 | static CGEConstString paramStepsName;
38 | };
39 |
40 | }
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeBeautifyFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeBeautifyFilter.h
3 | *
4 | * Created on: 2016-3-22
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_BEAUTIFYFILTER_H_
9 | #define _CGE_BEAUTIFYFILTER_H_
10 |
11 | #include "cgeImageFilter.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEBeautifyFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | bool init();
20 |
21 | void setIntensity(float intensity);
22 |
23 | void setImageSize(float width, float height, float mul = 1.5f);
24 |
25 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
26 |
27 | protected:
28 | float m_intensity;
29 | };
30 | }
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeBilateralBlurFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeBilateralBlurFilter.h
3 | *
4 | * Created on: 2014-4-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_BLIATERALBLUR_H_
9 | #define _CGE_BLIATERALBLUR_H_
10 |
11 | #include "cgeAdvancedEffectsCommon.h"
12 |
13 | namespace CGE
14 | {
15 | //blur with fixed radius.
16 | class CGEBilateralBlurFilter : public CGEAdvancedEffectTwoStepFilterHelper
17 | {
18 | public:
19 | CGEBilateralBlurFilter() {}
20 | ~CGEBilateralBlurFilter() {}
21 |
22 | bool init();
23 |
24 | //Range: value >= 0.0, and 0.0 for the origin. Default: 4.0
25 | virtual void setBlurScale(float value);
26 |
27 | //Range: [1.0, 20.0], none for the origin. Default: 8.0 (It'll show the origin when blurScale value is 1.0
28 | void setDistanceNormalizationFactor(float value);
29 |
30 | protected:
31 | static CGEConstString paramDistanceFactorName;
32 | static CGEConstString paramBlurSamplerScaleName;
33 | static CGEConstString paramBlurFactorsName;
34 | };
35 |
36 | //not blur with fixed radius.
37 | class CGEBilateralBlurBetterFilter : public CGEBilateralBlurFilter
38 | {
39 | public:
40 | bool init();
41 | void setSamplerRadiusLimit(int limit);
42 | virtual void setBlurScale(float value);
43 |
44 | protected:
45 | static CGEConstString paramBlurRadiusName;
46 | int m_limit;
47 | };
48 |
49 | //特殊用法
50 | class CGEBilateralWrapperFilter : public CGEImageFilterInterface
51 | {
52 | public:
53 |
54 | CGEBilateralWrapperFilter() : m_repeatTimes(1) {}
55 | ~CGEBilateralWrapperFilter() { delete m_proc; }
56 |
57 | bool init();
58 |
59 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
60 |
61 |
62 | //Range: [-100, 100]. the value would be transformed basing on the input image size.
63 | void setBlurScale(float value)
64 | {
65 | m_blurScale = value;
66 | }
67 |
68 | //Range: [1.0, 20.0], none for the origin. Default: 8.0 (It'll show the origin when blurScale value is 1.0
69 | void setDistanceNormalizationFactor(float value)
70 | {
71 | m_proc->setDistanceNormalizationFactor(value);
72 | }
73 |
74 | void setRepeatTimes(int n)
75 | {
76 | m_repeatTimes = n;
77 | }
78 |
79 | CGEBilateralBlurFilter *m_proc;
80 | float m_blurScale;
81 | int m_repeatTimes;
82 | };
83 | }
84 |
85 | #endif
86 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeBrightnessAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeBrightnessAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEBRIGHTNESSADJUST_H_
9 | #define _CGEBRIGHTNESSADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEBrightnessFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | void setIntensity(float value); // range: [-1, 1]
20 |
21 | bool init();
22 |
23 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
24 |
25 | protected:
26 | static CGEConstString paramName;
27 |
28 | private:
29 | float m_intensity;
30 | };
31 |
32 | class CGEBrightnessFastFilter : public CGEFastAdjustRGBFilter
33 | {
34 | public:
35 |
36 | void setIntensity(float value);
37 | bool init();
38 | };
39 |
40 | }
41 |
42 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeColorBalanceAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeColorBalanceAdjust.h
3 | *
4 | * Created on: 2015-3-30
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGECOLORBALANCEADJUST_H_
9 | #define _CGECOLORBALANCEADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEColorBalanceFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | bool init();
20 |
21 | //Range[-1, 1], cyan to red
22 | void setRedShift(float value);
23 |
24 | //Range[-1, 1], magenta to green
25 | void setGreenShift(float value);
26 |
27 | //Range[-1, 1], yellow to blue
28 | void setBlueShift(float value);
29 |
30 | protected:
31 | static CGEConstString paramRedShiftName;
32 | static CGEConstString paramGreenShiftName;
33 | static CGEConstString paramBlueShiftName;
34 |
35 | };
36 |
37 |
38 |
39 | }
40 |
41 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeColorLevelAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeColorLevelAdjust.h
3 | *
4 | * Created on: 2014-1-20
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGECOLORLEVELADJUST_H_
9 | #define _CGECOLORLEVELADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEColorLevelFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 | CGEColorLevelFilter() {}
19 | ~CGEColorLevelFilter() {}
20 |
21 | bool init();
22 |
23 | void setLevel(float dark, float light); // range [0, 1], dark < light
24 | void setGamma(float value); // range [0, 3], default: 1 (origin)
25 |
26 | protected:
27 | static CGEConstString paramLevelName;
28 | static CGEConstString paramGammaName;
29 | };
30 | }
31 |
32 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeColorMappingFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeColorMappingFilter.h
3 | *
4 | * Created on: 2016-8-5
5 | * Author: Wang Yang
6 | * Description: 色彩映射
7 | */
8 |
9 | #ifndef _CGE_COLOR_MAPPING_FILTER_H_
10 | #define _CGE_COLOR_MAPPING_FILTER_H_
11 |
12 | #include "cgeGLFunctions.h"
13 | #include
14 | #include "cgeVec.h"
15 |
16 | namespace CGE
17 | {
18 | class CGEColorMappingFilter : public CGEImageFilterInterface
19 | {
20 | public:
21 | CGEColorMappingFilter();
22 | ~CGEColorMappingFilter();
23 |
24 | enum MapingMode
25 | {
26 | MAPINGMODE_DEFAULT = 0,
27 | MAPINGMODE_BUFFERED_AREA = 0,
28 | MAPINGMODE_SINGLE = 1,
29 | };
30 |
31 | struct MappingArea
32 | {
33 | Vec4f area;
34 | float weight;
35 |
36 | bool operator<(const MappingArea& m) const
37 | {
38 | return weight < m.weight;
39 | }
40 |
41 | };
42 |
43 | static CGEColorMappingFilter* createWithMode(MapingMode mode = MAPINGMODE_DEFAULT);
44 |
45 | virtual void pushMapingArea(const MappingArea& area);
46 | virtual void endPushing(); //pushMapingArea 结束之后调用
47 |
48 | //texWith, texHeight 表示纹理大小
49 | //texUnitWidth, texUnitHeight 表示每个映射单元映射后的分辨率
50 | virtual void setupMapping(GLuint mappingTex, int texWidth, int texHeight, int texUnitWidth, int texUnitHeight);
51 |
52 |
53 | protected:
54 |
55 | GLuint m_mappingTexture;
56 | CGESizei m_texSize; //纹理像素尺寸
57 | CGESizei m_texUnitResolution;
58 | std::vector m_mappingAreas;
59 | };
60 |
61 | }
62 |
63 | #endif // !_CGE_COLOR_MAPPING_FILTER_H_
64 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeContrastAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeContrastAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGECONTRAST_ADJUST_H_
9 | #define _CGECONTRAST_ADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEContrastFilter : public CGEImageFilterInterface
18 | {
19 | public:
20 | CGEContrastFilter(){}
21 | ~CGEContrastFilter(){}
22 |
23 | void setIntensity(float value); //range > 0, and 1 for origin
24 |
25 | bool init();
26 |
27 | protected:
28 | static CGEConstString paramName;
29 | };
30 | }
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeCrosshatchFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeCrosshatchFilter.h
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_CROSSHATCH_H_
9 | #define _CGE_CROSSHATCH_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGECrosshatchFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: (0, 0.1], default: 0.03
20 | void setCrosshatchSpacing(float value);
21 | //Range: (0, 0.01], default: 0.003
22 | void setLineWidth(float value);
23 |
24 | bool init();
25 |
26 | protected:
27 | static CGEConstString paramCrosshatchSpacing;
28 | static CGEConstString paramLineWidth;
29 | };
30 |
31 | }
32 |
33 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeDataParsingEngine.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMultipleEffects.h
3 | *
4 | * Created on: 2013-12-13
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEDATAPARSINGENGINE_H_
9 | #define _CGEDATAPARSINGENGINE_H_
10 |
11 | #include "cgeMultipleEffects.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEDataParsingEngine
16 | {
17 | public:
18 | static CGEImageFilterInterface* adjustParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
19 | static CGEImageFilterInterface* curveParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
20 | static CGEImageFilterInterface* lomoWithCurveParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
21 | static CGEImageFilterInterface* lomoParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
22 | static CGEImageFilterInterface* blendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
23 | static CGEImageFilterInterface* vignetteBlendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
24 | static CGEImageFilterInterface* colorScaleParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
25 | static CGEImageFilterInterface* pixblendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
26 | static CGEImageFilterInterface* krblendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
27 | static CGEImageFilterInterface* vignetteParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
28 | static CGEImageFilterInterface* selfblendParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
29 | static CGEImageFilterInterface* colorMulParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
30 | static CGEImageFilterInterface* selectiveColorParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
31 | static CGEImageFilterInterface* blendTileParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
32 | static CGEImageFilterInterface* advancedStyleParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
33 | static CGEImageFilterInterface* beautifyParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
34 | static CGEImageFilterInterface* blurParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
35 | static CGEImageFilterInterface* dynamicParser(const char* pstr, CGEMutipleEffectFilter* fatherFilter = nullptr);
36 |
37 | };
38 |
39 | }
40 | #endif /* _CGEDATAPARSINGENGINE_H_ */
41 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeDynamicFilters.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicFilters.h
3 | *
4 | * Created on: 2015-11-18
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEDYNAMICFILTERS_H_
9 | #define _CGEDYNAMICFILTERS_H_
10 |
11 | #include "cgeDynamicWaveFilter.h"
12 | #include "cgeMotionFlowFilter.h"
13 | #include "cgeSoulStuffFilter.h"
14 |
15 | namespace CGE
16 | {
17 | CGEDynamicWaveFilter* createDynamicWaveFilter();
18 | CGEMotionFlowFilter* createMotionFlowFilter();
19 | CGEMotionFlow2Filter* createMotionFlow2Filter();
20 | CGESoulStuffFilter* createSoulStuffFilter();
21 | }
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeDynamicWaveFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicWaveFilter.h
3 | *
4 | * Created on: 2015-11-12
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEDYNAMICWAVE_H_
9 | #define _CGEDYNAMICWAVE_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEDynamicWaveFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | void setIntensity(float value); // The same to setAutoMotionSpeed
20 |
21 | bool init();
22 |
23 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
24 |
25 | void setWaveMotion(float motion);
26 | void setWaveAngle(float angle); //default: 20 (从左往右, 从上往下 包含 angle / PI 个周期)
27 | void setStrength(float strength); //default: 0.01 强度(百分比), 范围 (0, 1)
28 |
29 | void setAutoMotionSpeed(float speed); // Auto motion would be disabled if speed <= 0.
30 |
31 | protected:
32 | static CGEConstString paramMotion;
33 | static CGEConstString paramAngle;
34 | static CGEConstString paramStrength;
35 |
36 | private:
37 |
38 | GLint m_motionLoc;
39 | GLint m_angleLoc;
40 | GLint m_strengthLoc;
41 |
42 | GLfloat m_motion;
43 | GLfloat m_motionSpeed;
44 | GLfloat m_angle;
45 | GLfloat m_strength;
46 | bool m_autoMotion;
47 | };
48 |
49 | }
50 |
51 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeEdgeFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeEdgeFilter.h
3 | *
4 | * Created on: 2013-12-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEEDGE_H_
9 | #define _CGEEDGE_H_
10 |
11 | #include "cgeEmbossFilter.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEEdgeFilter : public CGEEmbossFilter
16 | {
17 | public:
18 | bool init();
19 |
20 | //Intensity Range:[0, 1], 0 for origin, and 1 for the best effect
21 | //Stride: [0, 5]. Default: 2
22 | };
23 |
24 | class CGEEdgeSobelFilter : public CGEEmbossFilter
25 | {
26 | public:
27 |
28 | bool init();
29 |
30 | protected:
31 | //hide
32 | void setAngle(float value) {}
33 | };
34 | }
35 |
36 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeEmbossFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeEmbossFilter.h
3 | *
4 | * Created on: 2013-12-27
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEEMBOSS_H_
9 | #define _CGEEMBOSS_H_
10 |
11 | #include "cgeAdvancedEffectsCommon.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEEmbossFilter : public CGEAdvancedEffectOneStepFilterHelper
16 | {
17 | public:
18 | CGEEmbossFilter(){}
19 | ~CGEEmbossFilter(){}
20 |
21 | //Range: [0, 1], and 0 for the origin, 1 for the best effect.
22 | void setIntensity(float value);
23 |
24 | //Range: [1, 5], default: 2.0. The 'stride' would never affect the speed.
25 | //You should set this when you want to keep the effects
26 | // between two image with the same content but different sizes.
27 | void setStride(float value);
28 |
29 | void setAngle(float value);
30 |
31 | bool init();
32 |
33 | protected:
34 | static CGEConstString paramIntensity;
35 | static CGEConstString paramStride;
36 | static CGEConstString paramNorm;
37 | };
38 |
39 | }
40 |
41 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeExposureAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeExposureAdjust.h
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEEXPOSUREADJUST_H_
9 | #define _CGEEXPOSUREADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEExposureFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: [-10, 10]
20 | void setIntensity(float value);
21 |
22 | bool init();
23 |
24 | protected:
25 | static CGEConstString paramName;
26 |
27 | };
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeHalftoneFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHalftoneFilter.h
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEHALFTONEFILTER_H_
9 | #define _CGEHALFTONEFILTER_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEHalftoneFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | bool init();
20 |
21 | //Range: >= 1.
22 | void setDotSize(float value);
23 |
24 | void render2Texture(CGE::CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
25 |
26 | protected:
27 | static CGEConstString paramAspectRatio;
28 | static CGEConstString paramDotPercent;
29 | float m_dotSize;
30 | };
31 |
32 |
33 | }
34 |
35 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeHazeFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHazeFilter.h
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_HAZEFILTER_H_
9 | #define _CGE_HAZEFILTER_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEHazeFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: [-0.5, 0.5], default: 0.2
20 | void setDistance(float value);
21 | //Range: [-0.5, 0.5] defualt: 0
22 | void setSlope(float value);
23 |
24 | //Range: [0, 1], Defualt: all 1
25 | void setHazeColor(float r, float g, float b);
26 |
27 | bool init();
28 |
29 | protected:
30 | static CGEConstString paramDistance;
31 | static CGEConstString paramSlope;
32 | static CGEConstString paramHazeColor;
33 | };
34 | }
35 |
36 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeHueAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHueAdjust.h
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEHUEADJUST_H_
9 | #define _CGEHUEADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEHueAdjustFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: [0, 2π]
20 | void setHue(float value);
21 |
22 | bool init();
23 |
24 | protected:
25 | static CGEConstString paramName;
26 | };
27 |
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeLerpblurFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeLerpblurFilter.h
3 | *
4 | * Created on: 2015-8-3
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_LERPBLURFILTER_H_
9 | #define _CGE_LERPBLURFILTER_H_
10 |
11 | #include "cgeAdvancedEffectsCommon.h"
12 |
13 | namespace CGE
14 | {
15 | class CGELerpblurFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 | ~CGELerpblurFilter();
19 |
20 | enum { MAX_LERP_BLUR_INTENSITY = 12 };
21 |
22 | bool init();
23 |
24 | struct TextureCache
25 | {
26 | GLuint texID;
27 | CGESizei size;
28 | };
29 |
30 | void setBlurLevel(int value);
31 |
32 | void setIntensity(float value);
33 |
34 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
35 |
36 | //图像渐进缩小基数( > 1.1)
37 | void setMipmapBase(float value);
38 |
39 | protected:
40 | void _genMipmaps(int width, int height);
41 | void _clearMipmaps();
42 | int _calcLevel(int len, int level);
43 |
44 | private:
45 |
46 | TextureCache m_texCache[MAX_LERP_BLUR_INTENSITY];
47 | CGESizei m_cacheTargetSize;
48 | int m_intensity;
49 | float m_mipmapBase;
50 | bool m_isBaseChanged;
51 |
52 | FrameBuffer m_framebuffer;
53 |
54 | };
55 |
56 |
57 | }
58 |
59 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeLookupFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeLookupFilter.h
3 | *
4 | * Created on: 2016-7-4
5 | * Author: Wang Yang
6 | * Description: 全图LUT滤镜
7 | */
8 |
9 | #ifndef _CGE_LOOKUPFILTER_H_
10 | #define _CGE_LOOKUPFILTER_H_
11 |
12 | #include "cgeGLFunctions.h"
13 |
14 | namespace CGE
15 | {
16 | class CGELookupFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 | CGELookupFilter();
20 | ~CGELookupFilter();
21 |
22 | bool init();
23 |
24 | inline void setLookupTexture(GLuint tex) { m_lookupTexture = tex; };
25 |
26 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
27 |
28 | inline GLuint& lookupTexture() { return m_lookupTexture; }
29 |
30 | protected:
31 | GLuint m_lookupTexture;
32 | };
33 |
34 | }
35 |
36 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeMaxValueFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMaxValueFilter.h
3 | *
4 | * Created on: 2015-3-20
5 | * Author: Wang Yang
6 | * Description: 最大值滤波
7 | */
8 |
9 | #ifndef _CGE_MAXVALUE_FILTER_H_
10 | #define _CGE_MAXVALUE_FILTER_H_
11 |
12 | #include "cgeMinValueFilter.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMaxValueFilter3x3 : public CGEMinValueFilter3x3
17 | {
18 | public:
19 | const char* getShaderCompFunc();
20 |
21 | };
22 |
23 | class CGEMaxValueFilter3x3Plus : public CGEMinValueFilter3x3Plus
24 | {
25 | public:
26 | const char* getShaderCompFunc();
27 | };
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeMidValueFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMinValueFilter.h
3 | *
4 | * Created on: 2015-9-24
5 | * Author: Wang Yang
6 | * Description: 中值滤波
7 | */
8 |
9 | #ifndef _CGE_MIDVALUE_FILTER_H_
10 | #define _CGE_MIDVALUE_FILTER_H_
11 |
12 | #include "cgeMinValueFilter.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMidValueFilter3x3 : public CGEMinValueFilter3x3
17 | {
18 | public:
19 |
20 | bool init();
21 |
22 | protected:
23 |
24 |
25 | };
26 |
27 | }
28 |
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeMinValueFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMinValueFilter.h
3 | *
4 | * Created on: 2015-3-20
5 | * Author: Wang Yang
6 | * Description: 最小值滤波
7 | */
8 |
9 | #ifndef _CGE_MINVALUE_FILTER_H_
10 | #define _CGE_MINVALUE_FILTER_H_
11 |
12 | #include "cgeGLFunctions.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMinValueFilter3x3: public CGEImageFilterInterface
17 | {
18 | public:
19 |
20 | bool init();
21 |
22 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
23 |
24 | GLint getStepsLocation() { return m_samplerStepsLoc; }
25 |
26 | protected:
27 |
28 | static CGEConstString paramSamplerStepsName;
29 |
30 | virtual const char* getShaderCompFunc();
31 |
32 | void initLocations();
33 |
34 | private:
35 | GLint m_samplerStepsLoc;
36 | };
37 |
38 | class CGEMinValueFilter3x3Plus: public CGEMinValueFilter3x3
39 | {
40 | public:
41 |
42 | bool init();
43 | };
44 |
45 | }
46 |
47 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeMonochromeAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMonochromeAdjust.h
3 | *
4 | * Created on: 2013-12-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEMONOCHROME_ADJUST_H_
9 | #define _CGEMONOCHROME_ADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEMonochromeFilter : public CGEImageFilterInterface
18 | {
19 | public:
20 | CGEMonochromeFilter(){}
21 | ~CGEMonochromeFilter(){}
22 |
23 | bool init();
24 |
25 | void setRed(float value);
26 | void setGreen(float value);
27 | void setBlue(float value);
28 | void setCyan(float value);
29 | void setMagenta(float value);
30 | void setYellow(float value);
31 |
32 | protected:
33 | static CGEConstString paramRed;
34 | static CGEConstString paramGreen;
35 | static CGEConstString paramBlue;
36 | static CGEConstString paramCyan;
37 | static CGEConstString paramMagenta;
38 | static CGEConstString paramYellow;
39 | };
40 | }
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeMosaicBlurFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMosaicBlur.h
3 | *
4 | * Created on: 2014-4-10
5 | * Author: Wang Yang
6 | * Description: 马赛克
7 | */
8 |
9 | #ifndef _CGE_MOSAICBLUR_H_
10 | #define _CGE_MOSAICBLUR_H_
11 |
12 | #include "cgeAdvancedEffectsCommon.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMosaicBlurFilter : public CGEAdvancedEffectOneStepFilterHelper
17 | {
18 | public:
19 |
20 | bool init();
21 |
22 | //Range: value >= 1.0, and 1.0(Default) for the origin. Value is better with integer.
23 | void setBlurPixels(float value);
24 |
25 | protected:
26 | static CGEConstString paramBlurPixelsName;
27 | };
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeMotionBlurAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMotionBlurAdjust.h
3 | *
4 | * Created on: 2014-9-25
5 | */
6 |
7 | #ifndef _CGEMOTIONBLURADJUST_H
8 | #define _CGEMOTIONBLURADJUST_H
9 |
10 | #include "cgeGLFunctions.h"
11 | #include "cgeSharpenBlurAdjust.h"
12 | #include "cgeVec.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEMotionBlurFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 | CGEMotionBlurFilter(){}
20 | ~CGEMotionBlurFilter(){}
21 |
22 | bool init();
23 |
24 | // range: radius >= 0.0
25 | void setSamplerRadius(float radius);
26 |
27 | void setAngle(float angle);
28 | void setRadians(float radians);
29 |
30 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
31 |
32 | protected:
33 | static CGEConstString paramSamplerRadiusName;
34 | static CGEConstString paramSamplerStepName;
35 | static CGEConstString paramBlurNormName;
36 |
37 | float m_samplerRadius;
38 | Vec2f m_blurNorm;
39 | };
40 |
41 | class CGEMotionBlurCurveFilter : public CGEMotionBlurFilter
42 | {
43 | public:
44 | bool init();
45 | };
46 | }
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeMotionFlowFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicWaveFilter.h
3 | *
4 | * Created on: 2016-8-12
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef cgeMotionFlowFilter_h
9 | #define cgeMotionFlowFilter_h
10 |
11 | #include "cgeGLFunctions.h"
12 | #include
13 |
14 | namespace CGE
15 | {
16 | class TextureDrawer;
17 |
18 | class CGEMotionFlowFilter : public CGEImageFilterInterface
19 | {
20 | public:
21 | CGEMotionFlowFilter();
22 | ~CGEMotionFlowFilter();
23 |
24 | bool init();
25 |
26 | void setTotalFrames(int frames);
27 | void setFrameDelay(int delayFrame);
28 |
29 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
30 |
31 | protected:
32 |
33 | virtual void pushFrame(GLuint texture);
34 | void clear();
35 |
36 | protected:
37 |
38 | static CGEConstString paramAlphaName;
39 |
40 | std::list m_frameTextures;
41 | std::vector m_totalFrameTextures;
42 | FrameBuffer m_framebuffer;
43 | TextureDrawer* m_drawer;
44 | int m_width, m_height;
45 | int m_totalFrames, m_delayFrames;
46 | int m_delayedFrames;
47 |
48 | float m_dAlpha;
49 | GLint m_alphaLoc;
50 | };
51 |
52 | class CGEMotionFlow2Filter : public CGEMotionFlowFilter
53 | {
54 | public:
55 | CGEMotionFlow2Filter();
56 |
57 | // void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
58 |
59 | protected:
60 | void pushFrame(GLuint texture);
61 |
62 | float m_sizeScaling, m_dSizeScaling;
63 | float m_dsMost;
64 |
65 | bool m_continuouslyTrigger;
66 | };
67 |
68 |
69 |
70 |
71 | }
72 |
73 |
74 | #endif /* cgeMotionFlowFilter_h */
75 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgePolarPixellateFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgePolarPixellateFilter.h
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_POLARPIXELLATEFILTER_H_
9 | #define _CGE_POLARPIXELLATEFILTER_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEPolarPixellateFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | //Range: [0, 1]
20 | void setCenter(float x, float y);
21 | //Range: [0, 0.2]
22 | void setPixelSize(float x, float y);
23 |
24 | bool init();
25 |
26 | protected:
27 | static CGEConstString paramCenter;
28 | static CGEConstString paramPixelSize;
29 | };
30 | }
31 |
32 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgePolkaDotFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgePolkaDotFilter.h
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_POLKADOTFILTER_H_
9 | #define _CGE_POLKADOTFILTER_H_
10 |
11 | #include "cgeHalftoneFilter.h"
12 |
13 | namespace CGE
14 | {
15 | class CGEPolkaDotFilter : public CGEHalftoneFilter
16 | {
17 | public:
18 | bool init();
19 |
20 | //Range: (0, 1]
21 | void setDotScaling(float value);
22 |
23 | protected:
24 | static CGEConstString paramDotScaling;
25 | };
26 | }
27 |
28 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeRandomBlurFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeRandomBlurFilter.h
3 | *
4 | * Created on: 2013-12-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGERANDOMBLUR_H_
9 | #define _CGERANDOMBLUR_H_
10 |
11 | #include "cgeAdvancedEffectsCommon.h"
12 |
13 | namespace CGE
14 | {
15 | class CGERandomBlurFilter : public CGEAdvancedEffectOneStepFilterHelper
16 | {
17 | public:
18 | CGERandomBlurFilter(){}
19 | ~CGERandomBlurFilter(){}
20 |
21 | void setIntensity(float value);
22 | void setSamplerScale(float value);
23 |
24 | bool init();
25 |
26 | protected:
27 | static CGEConstString paramIntensity;
28 | static CGEConstString paramSamplerScale;
29 | static CGEConstString paramSamplerRadius;
30 | };
31 | }
32 |
33 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeSaturationAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSaturationAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGESATURATION_ADJUST_H_
9 | #define _CGESATURATION_ADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 | #include "cgeCurveAdjust.h"
15 |
16 | namespace CGE
17 | {
18 | //This one is based on HSL.
19 | class CGESaturationHSLFilter : public CGEImageFilterInterface
20 | {
21 | public:
22 | CGESaturationHSLFilter(){}
23 | ~CGESaturationHSLFilter(){}
24 |
25 | void setSaturation(float value); // range [-1, 1]
26 |
27 | void setHue(float value); // range [-1, 1]
28 |
29 | void setLum(float lum); // range [-1, 1]
30 |
31 | bool init();
32 |
33 | protected:
34 | static CGEConstString paramSaturationName;
35 | static CGEConstString paramHueName;
36 | static CGEConstString paramLuminanceName;
37 | };
38 |
39 | // You can use the fast one instead(of the one above).
40 | class CGESaturationFilter : public CGEImageFilterInterface
41 | {
42 | public:
43 | CGESaturationFilter() {}
44 | ~CGESaturationFilter() {}
45 | bool init();
46 |
47 | //range: >0, 1 for origin, and saturation would increase if value > 1
48 | void setIntensity(float value);
49 |
50 | protected:
51 | static CGEConstString paramIntensityName;
52 | };
53 |
54 | //This one is based on HSV
55 | class CGESaturationHSVFilter : public CGEImageFilterInterface
56 | {
57 | public:
58 | CGESaturationHSVFilter(){}
59 | ~CGESaturationHSVFilter(){}
60 |
61 | bool init();
62 |
63 | //range: [-1, 1]
64 | void setAdjustColors(float red, float green, float blue,
65 | float magenta, float yellow, float cyan);
66 |
67 | protected:
68 | static CGEConstString paramColor1;
69 | static CGEConstString paramColor2;
70 | };
71 | }
72 |
73 | #endif
74 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeSelectiveColorAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSelectiveColorAdjust.h
3 | *
4 | * Created on: 2014-11-18
5 | */
6 |
7 | #ifndef _CGESELECTIVECOLORADJUST_H_
8 | #define _CGESELECTIVECOLORADJUST_H_
9 |
10 | #include "cgeGLFunctions.h"
11 | #include "cgeImageFilter.h"
12 |
13 | namespace CGE
14 | {
15 | class CGESelectiveColorFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 |
19 | CGESelectiveColorFilter():m_curveTexture(0){}
20 | ~CGESelectiveColorFilter(){}
21 |
22 | void setRed (float cyan,float magenta,float yellow,float key); // range: [-1, 1]
23 | void setGreen (float cyan,float magenta,float yellow,float key); // range: [-1, 1]
24 | void setBlue (float cyan,float magenta,float yellow,float key); // range: [-1, 1]
25 | void setCyan (float cyan,float magenta,float yellow,float key); // range: [-1, 1]
26 | void setMagenta(float cyan,float magenta,float yellow,float key); // range: [-1, 1]
27 | void setYellow (float cyan,float magenta,float yellow,float key); // range: [-1, 1]
28 | void setWhite (float cyan,float magenta,float yellow,float key); // range: [-1, 1]
29 | void setGray (float cyan,float magenta,float yellow,float key); // range: [-1, 1]
30 | void setBlack (float cyan,float magenta,float yellow,float key); // range: [-1, 1]
31 |
32 | bool init();
33 |
34 | protected:
35 | unsigned int m_curveTexture;
36 | static CGEConstString paramName;
37 | };
38 |
39 | }
40 |
41 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeShadowHighlightAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeShadowHighlightAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGESHADOWHIGHLIGHT_H_
9 | #define _CGESHADOWHIGHLIGHT_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageHandler.h"
13 |
14 | namespace CGE
15 | {
16 | class CGEShadowHighlightFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 | CGEShadowHighlightFilter(){}
20 | ~CGEShadowHighlightFilter(){}
21 |
22 | void setShadow(float value); // range [-200, 100]
23 | void setHighlight(float value); // range [-100, 200]
24 |
25 | bool init();
26 |
27 | protected:
28 | static CGEConstString paramShadowName;
29 | static CGEConstString paramHighlightName;
30 |
31 | private:
32 | };
33 |
34 | class CGEShadowHighlightFastFilter : public CGEFastAdjustRGBFilter
35 | {
36 | public:
37 | CGEShadowHighlightFastFilter() : m_shadow(0.0f), m_highlight(0.0f) {}
38 | ~CGEShadowHighlightFastFilter() {}
39 |
40 | void setShadowAndHighlight(float shadow, float highlight); //the same to above.
41 |
42 | bool init();
43 |
44 | float getShadow() { return m_shadow; }
45 | float getHighlight() { return m_highlight; }
46 |
47 | private:
48 | float m_shadow, m_highlight;
49 | };
50 |
51 | }
52 |
53 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeSketchFilter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSketchFilter.h
3 | *
4 | * Created on: 2015-3-20
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGE_SKETCHFILTER_H_
9 | #define _CGE_SKETCHFILTER_H_
10 |
11 | #include "cgeMaxValueFilter.h"
12 | #include "cgeMultipleEffects.h"
13 |
14 | namespace CGE
15 | {
16 | class CGESketchFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 |
20 | CGESketchFilter();
21 | ~CGESketchFilter();
22 |
23 | bool init();
24 |
25 | void setIntensity(float intensity);
26 |
27 | void render2Texture(CGE::CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
28 |
29 | void flush();
30 |
31 | protected:
32 |
33 | static CGEConstString paramCacheTextureName;
34 | static CGEConstString paramIntensityName;
35 |
36 | CGEMaxValueFilter3x3 m_maxValueFilter;
37 | GLuint m_textureCache;
38 | CGESizei m_cacheSize;
39 | };
40 | }
41 |
42 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeSoulStuffFilter.h:
--------------------------------------------------------------------------------
1 | //
2 | // cgeSoulStuffFilter.h
3 | // cgeStatic
4 | //
5 | // Created by Yang Wang on 2017/3/27.
6 | // Mail: admin@wysaid.org
7 | // Copyright © 2017年 wysaid. All rights reserved.
8 | //
9 |
10 | #ifndef cgeSoulStuffFilter_h
11 | #define cgeSoulStuffFilter_h
12 |
13 | #include "cgeGLFunctions.h"
14 | #include "cgeVec.h"
15 |
16 | namespace CGE
17 | {
18 | class CGESoulStuffFilter : public CGEImageFilterInterface
19 | {
20 | public:
21 | CGESoulStuffFilter();
22 | ~CGESoulStuffFilter();
23 |
24 | bool init();
25 |
26 | void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
27 |
28 | void trigger(float ds, float most);
29 |
30 | void setSoulStuffPos(float x, float y);
31 |
32 | inline void enableContinuouslyTrigger(bool continuouslyTrigger) { m_continuouslyTrigger = continuouslyTrigger; }
33 |
34 | protected:
35 | static CGEConstString paramSoulStuffPos;
36 | static CGEConstString paramSoulStuffScaling;
37 |
38 | GLint m_soulStuffPosLoc, m_soulStuffScalingLoc;
39 | float m_sizeScaling;
40 | float m_dSizeScaling;
41 | float m_dsMost;
42 |
43 | Vec2f m_pos;
44 |
45 | bool m_continuouslyTrigger;
46 | };
47 | }
48 |
49 | #endif /* cgeSoulStuffFilter_h */
50 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeVignetteAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeVignetteAdjust.h
3 | *
4 | * Created on: 2014-1-22
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEVIGNETTEADJUST_H_
9 | #define _CGEVIGNETTEADJUST_H_
10 |
11 | #include "cgeGLFunctions.h"
12 |
13 | namespace CGE
14 | {
15 |
16 | class CGEVignetteFilter : public CGEImageFilterInterface
17 | {
18 | public:
19 |
20 | virtual bool init();
21 |
22 | void setVignetteCenter(float x, float y); //Range: [0, 1], and 0.5 for the center.
23 | void setVignette(float start, float range); //Range: [0, 1]
24 |
25 | protected:
26 | static CGEConstString paramVignetteCenterName;
27 | static CGEConstString paramVignetteName;
28 | };
29 |
30 | class CGEVignetteExtFilter : public CGEVignetteFilter
31 | {
32 | public:
33 | bool init();
34 |
35 | void setVignetteColor(float r, float g, float b);
36 |
37 | protected:
38 | static CGEConstString paramVignetteColor;
39 | };
40 |
41 | }
42 |
43 | #endif
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeWhiteBalanceAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeWhiteBalanceAdjust.h
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #ifndef _CGEWHITEBALANCE_H_
9 | #define _CGEWHITEBALANCE_H_
10 |
11 | #include "cgeGLFunctions.h"
12 | #include "cgeImageFilter.h"
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEWhiteBalanceFilter : public CGEImageFilterInterface
18 | {
19 | public:
20 | CGEWhiteBalanceFilter(){}
21 | ~CGEWhiteBalanceFilter(){}
22 |
23 | void setTemperature(float value); //range: -1~1, 0 for origin
24 | void setTint(float value);// range 0~5, 1 for origin
25 |
26 | bool init();
27 |
28 | protected:
29 | static CGEConstString paramTemperatureName;
30 | static CGEConstString paramTintName;
31 | };
32 |
33 | class CGEWhiteBalanceFastFilter : public CGEImageFilterInterface
34 | {
35 | public:
36 | CGEWhiteBalanceFastFilter() : m_temp(0.0f), m_tint(1.0f) {}
37 | ~CGEWhiteBalanceFastFilter() {}
38 |
39 | void setTempAndTint(float temp, float tint);
40 |
41 | bool init();
42 |
43 | float getTemp() { return m_temp; }
44 | float getTint() { return m_tint; }
45 |
46 | protected:
47 | static CGEConstString paramBalanceName;
48 |
49 | private:
50 | float m_temp, m_tint;
51 | };
52 |
53 | }
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/library/cge/include/filters/cgeZoomBlurAdjust.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeZoomBlurAdjust.h
3 | *
4 | * Created on: 2014-9-17
5 | */
6 |
7 | #ifndef _CGEZOOMBLURADJUST_H
8 | #define _CGEZOOMBLURADJUST_H
9 |
10 | #include "cgeGLFunctions.h"
11 |
12 | namespace CGE
13 | {
14 | //适合向外扩散的情况
15 | class CGEZoomBlurFilter : public CGEImageFilterInterface
16 | {
17 | public:
18 | CGEZoomBlurFilter(){}
19 | ~CGEZoomBlurFilter(){}
20 |
21 | void setCenter(float x, float y); // texture coordinate
22 | void setIntensity(float strength); // range: [0, 1]
23 |
24 | bool init();
25 |
26 | protected:
27 | static CGEConstString paramCenterName;
28 | static CGEConstString paramIntensityName;
29 | };
30 |
31 | //折中方案, 兼顾向外与向内
32 | class CGEZoomBlur2Filter : public CGEZoomBlurFilter
33 | {
34 | public:
35 | CGEZoomBlur2Filter() {}
36 | ~CGEZoomBlur2Filter() {}
37 |
38 | bool init();
39 |
40 | protected:
41 | static CGEConstString paramStepsName;
42 |
43 | };
44 |
45 | }
46 |
47 | #endif
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeAnimationParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeAnimationParser.h
3 | *
4 | * Created on: 2016-5-16
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #if !defined(cgeAnimationParser_h) && !defined(_CGE_ONLY_FILTERS_)
10 | #define cgeAnimationParser_h
11 |
12 | #import
13 |
14 | namespace CGE
15 | {
16 | //返回值类型为 TimeLine. 避免头文件混乱, 这里使用 void* 作为返回值
17 | void* createSlideshowByConfig(id config, float totalTime);
18 | }
19 |
20 |
21 | #endif /* cgeAnimationParser_h */
22 |
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeCVUtilTexture.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeCVUtilTexture.h
3 | *
4 | * Created on: 2015-11-6
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 |
10 | #import
11 | #import
12 | #import
13 |
14 | @interface CGECVUtilTexture : NSObject
15 |
16 | @property(nonatomic, readonly)int textureWidth;
17 | @property(nonatomic, readonly)int textureHeight;
18 |
19 | - (id)initWithSize:(int)width height:(int)height;
20 | - (id)initWithSize:(int)width height:(int)height bufferPool:(CVPixelBufferPoolRef)bufferPool;
21 | - (void)clear;
22 |
23 | - (CVPixelBufferRef)pixelBufferRef;
24 | - (CVOpenGLESTextureRef)textureRef;
25 | - (CVOpenGLESTextureCacheRef)textureCacheRef;
26 | - (GLenum)textureTarget;
27 | - (GLuint)textureID;
28 |
29 | ////////////////////////
30 |
31 | //+ (BOOL)supportsFastTextureUpload;
32 | //
33 | //+ (NSInteger)maximumTextureSizeForThisDevice;
34 | //+ (NSInteger)maximumTextureUnitsForThisDevice;
35 | //
36 | //+ (BOOL)deviceSupportsOpenGLESExtension:(NSString *)extension;
37 | //+ (BOOL)deviceSupportsRedTextures;
38 | //+ (BOOL)deviceSupportsFramebufferReads;
39 |
40 | ////////////////////////
41 |
42 | //便捷方法, 生成较常用的 pixelBufferPoolRef
43 | //此处生成的 CVPixelBufferPoolRef 需要手动调用下方的 release 方法来释放
44 | + (CVPixelBufferPoolRef)makePixelBufferPoolRef:(int)width height:(int)height;
45 | + (void)releasePixelBufferPoolRef:(CVPixelBufferPoolRef)bufferPoolRef;
46 |
47 | //当 bufferPoolRef 为 nil 时, 将额外创建新的bufferPool.
48 | + (instancetype)makeCVTexture:(int)width height:(int)height bufferPool:(CVPixelBufferPoolRef)bufferPoolRef;
49 |
50 | @end
51 |
52 | ////////////////////////////////////////////////
53 |
54 | typedef struct CGECVBufferData
55 | {
56 | void* data;
57 | int width, height;
58 | int bytesPerRow; //May not be the same with (width * channels)
59 | int channels; //'channels' is always 4 for now.
60 |
61 | }CGECVBufferData;
62 |
63 | @interface CGECVUtilTextureWithFramebuffer : CGECVUtilTexture
64 |
65 | - (GLuint)framebuffer;
66 |
67 | - (void)bindTextureFramebuffer;
68 |
69 | //'lockFlag' = 1 (kCVPixelBufferLock_ReadOnly) for readOnly, 0 for read&write.
70 | //glFinish should be called if any gl functions are not finished.
71 | - (CGECVBufferData)mapBuffer:(CVPixelBufferLockFlags)lockFlag;
72 | - (void)unmapBuffer:(CVPixelBufferLockFlags)lockFlag;
73 |
74 | + (instancetype)makeCVTexture:(int)width height:(int)height bufferPool:(CVPixelBufferPoolRef)bufferPoolRef;
75 |
76 | @end
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeDynamicImageViewHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicImageViewHandler.h
3 | *
4 | * Created on: 2015-12-28
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 |
10 | #import "cgeImageViewHandler.h"
11 |
12 | //不适于图片帧特别多且图片分辨率较大的情况(当图片帧过多时将导致内存占用过多)
13 |
14 | @interface CGEDynamicImageViewHandler : CGEImageViewHandler
15 |
16 | @property (nonatomic)int currentImageIndex;
17 | - (size_t)totalImages;
18 |
19 | #pragma mark - 图片相关接口
20 |
21 | /*
22 |
23 | imageConfig (NSDictionary*)
24 |
25 | @{
26 |
27 | @"images" : (NSArray*)images, //要用到的图片 (UIImage*), 分辨率以第一张为准
28 | @"delayTimes" : (NSArray*)delayTimes, //每一张图片的单独持续显示时间 (float), 单位 秒 (与 stableDelayTime 二选一)
29 | @"stableDelayTime" : (float)delayTime, //所有图片的持续显示时间 (与 delayTimes 二选一)
30 |
31 | }
32 |
33 | */
34 |
35 | - (BOOL)setUIImagesWithConfig: (NSDictionary*)imageConfig startAnimation:(BOOL)doAnimation;
36 |
37 | - (BOOL)setGifImage:(CFURLRef)gifUrl;
38 |
39 | - (BOOL)saveAsGif:(NSURL*)gifUrl loopCount:(int)loopCount; //loopCount <= 0 表示不断循环
40 |
41 | /*
42 |
43 | getResultImages返回值: (NSDictionary*)
44 |
45 | @{
46 | @"images" : (NSArray*)images, //结果图片 (UIImage*)
47 | @"delayTimes" : (NSArray*)delayTimes, //每一张图片的单独持续显示时间 (float), 单位 秒
48 |
49 | }
50 |
51 | */
52 |
53 | - (NSDictionary*)getResultImages;
54 |
55 | #pragma mark - 显示相关的接口
56 |
57 | - (BOOL)startAnimation; //当图像少于2张时无法启动动画。
58 | - (void)stopAnimation;
59 |
60 | - (BOOL)jumpToFrame:(int)frameIndex; //直接跳转到指定帧 frameIndex 介于 [0, totalImages-1]
61 |
62 |
63 |
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeFrameRecorder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeFrameRecorder.h
3 | *
4 | * Created on: 2015-12-1
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | // 主要作为辅助类使用
10 |
11 | #ifndef _CGE_FRAME_RECORDER_H_
12 | #define _CGE_FRAME_RECORDER_H_
13 |
14 | #import
15 | #import "cgeVideoWriter.h"
16 | #import "cgeFrameRenderer.h"
17 |
18 | @interface CGEFrameRecorder : CGEFrameRenderer
19 |
20 | @property(nonatomic, readonly) NSURL* outputVideoURL;
21 | @property(nonatomic, readonly) NSURL* cacheVideoURL;
22 |
23 | @property(nonatomic, weak) id updateDelegate;
24 | @property(nonatomic, readonly) CGEVideoWriter* videoWriter;
25 | @property(nonatomic, readonly) BOOL isRecording;
26 | @property(nonatomic) BOOL shouldPassthroughAudio;
27 |
28 | #pragma mark - 初始化相关
29 |
30 | - (id)initWithContext :(CGESharedGLContext*)sharedContext;
31 |
32 | // 手动调用释放
33 | - (void)clear;
34 |
35 |
36 | #pragma mark - 录像相关接口
37 |
38 | /*
39 | For example:
40 |
41 | outputSettings = @{
42 |
43 | AVVideoCodecKey : AVVideoCodecH264,
44 | AVVideoWidthKey : @(_videoSize.width),
45 | AVVideoHeightKey : @(_videoSize.height),
46 | AVVideoCompressionPropertiesKey : @{ AVVideoAverageBitRateKey : @(1650000),
47 | AVVideoExpectedSourceFrameRateKey : @(30),
48 | AVVideoMaxKeyFrameIntervalKey : @(30),
49 | "EncodingLiveVideo" : @(YES), //此处必填, 相机实时录制必然为 YES, 已录制视频转录应该为 NO
50 |
51 | "mute" : @(NO) //可选参数, 可不填
52 |
53 | }
54 |
55 | */
56 |
57 | - (void)startRecording :(NSURL*)videoURL size:(CGSize)videoSize;
58 | - (void)startRecording :(NSURL*)videoURL size:(CGSize)videoSize outputSetting:(NSDictionary*)ouputSetting;
59 | - (void)endRecording :(void (^)(void))completionHandler; //默认 压缩程度 中等
60 | - (void)endRecording :(void (^)(void))completionHandler withCompressionLevel:(int)level; //level 取值范围为 [0, 3], 0为不压缩, 1 清晰度较高, 文件较大, 2 中等, 3 清晰度较低, 文件较小
61 |
62 | - (void)endRecording:(void (^)(void))completionHandler withQuality:(NSString*)quality shouldOptimizeForNetworkUse:(BOOL)shouldOptimize; //quality为 AVAssetExportPreset*
63 |
64 | - (void)cancelRecording;
65 |
66 | @end
67 |
68 |
69 | #endif
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeImageHandlerIOS.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeImageHandlerIOS.h
3 | *
4 | * Created on: 2015-8-23
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef __cge__cgeImageHandlerIOS__
10 | #define __cge__cgeImageHandlerIOS__
11 |
12 | #import
13 | #include "cgeImageHandler.h"
14 |
15 | namespace CGE
16 | {
17 | class CGEImageHandlerIOS : public CGE::CGEImageHandler
18 | {
19 | public:
20 |
21 | CGEImageHandlerIOS();
22 | ~CGEImageHandlerIOS();
23 |
24 | bool initWithUIImage(UIImage* uiimage, bool useImageBuffer = true, bool enableRevision = false);
25 |
26 | UIImage* getResultUIImage();
27 |
28 | void processingFilters();
29 |
30 | void swapBufferFBO();
31 |
32 | void enableImageBuffer(bool useBuffer);
33 | bool isImageBufferEnabled() { return m_imageBuffer != nullptr;}
34 |
35 | protected:
36 |
37 | unsigned char* m_imageBuffer;
38 | int m_imageBufferLen;
39 | CGFloat m_imageScale;
40 | };
41 |
42 | }
43 |
44 |
45 | #endif /* defined(__cge__cgeImageHandlerIOS__) */
46 |
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeImageViewHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeImageViewHandler.h
3 | *
4 | * Created on: 2015-11-18
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #import
10 | #import "cgeSharedGLContext.h"
11 |
12 | #define CGE_IMAGEVIEW_IMAGEHANDLER_IOS CGEImageHandlerIOS
13 |
14 | typedef enum CGEImageViewDisplayMode
15 | {
16 | CGEImageViewDisplayModeScaleToFill,
17 | CGEImageViewDisplayModeAspectFill,
18 | CGEImageViewDisplayModeAspectFit,
19 | CGEImageViewDisplayModeDefault = CGEImageViewDisplayModeScaleToFill
20 | }CGEImageViewDisplayMode;
21 |
22 | @interface CGEImageViewHandler : NSObject
23 |
24 | @property (weak, nonatomic) GLKView* glkView;
25 | @property (nonatomic, readonly)CGESharedGLContext* sharedContext;
26 | @property (nonatomic)CGSize imageSize;
27 | @property (nonatomic)float currentIntensity;
28 |
29 | // 初始化接口
30 |
31 | - (id)initWithGLKView:(GLKView*)glkView;
32 | - (id)initWithGLKView:(GLKView*)glkView withImage:(UIImage*)image;//image 将作为默认使用图像(附加滤镜等)
33 |
34 | #pragma mark - 滤镜设定相关接口
35 |
36 | //通用滤镜配置接口
37 | - (BOOL)setFilterWithConfig :(const char*) config;
38 |
39 | //扩展用法, 设置的filter必须与当前view在同一OpenGL环境下, 否则将出错
40 | - (BOOL)setFilter :(void*)filter;
41 | - (BOOL)setFilterWithWrapper :(void*)filter;
42 |
43 | - (void)flush; //flush filters.
44 |
45 | //通用滤镜强度设定接口, 取值范围 [0, 1]
46 | //注意, 当强度低于1时取得相反效果, 强度高于1时得到增强效果(某些滤镜无效, 如Lerp blur
47 | - (void)setFilterIntensity :(float)value;
48 |
49 | #pragma mark - 图片相关接口
50 |
51 | - (BOOL)setUIImage:(UIImage*) image; //切换图像
52 | - (UIImage*)resultImage; //获取计算结果
53 |
54 | #pragma mark - 显示相关的接口
55 |
56 | - (void)setViewDisplayMode :(CGEImageViewDisplayMode)mode;
57 |
58 | #pragma mark - 其他接口
59 |
60 | //清除view
61 | - (void)clear;
62 |
63 | //辅助接口 (子类使用, 非对外)
64 | - (void*)_getHandler;
65 | - (void)_setupView;
66 |
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeProcessingContext.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeProcessingContext.h
3 | *
4 | * Created on: 2015-9-17
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGE_PROCESSINGCONTEXT_H_
10 | #define _CGE_PROCESSINGCONTEXT_H_
11 |
12 | #import
13 |
14 | @interface CGEProcessingContext : NSObject
15 | {
16 | @public void* _contextKey;
17 | }
18 |
19 | @property(nonatomic) dispatch_queue_t contextQueue;
20 |
21 | - (void)syncProcessingQueue:(void (^)(void))block;
22 | - (void)asyncProcessingQueue:(void (^)(void))block;
23 |
24 | /////////////////////////////////////////////
25 |
26 |
27 | + (void)mainSyncProcessingQueue:(void (^)(void))block;
28 | + (void)mainASyncProcessingQueue:(void (^)(void))block;
29 |
30 | #if defined(_CGE_GENERAL_ERROR_TEST_ ) && _CGE_GENERAL_ERROR_TEST_
31 |
32 | + (int)refCount;
33 |
34 | #endif
35 |
36 | @end
37 |
38 | #endif
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeSharedGLContext.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeSharedGLContext.h
3 | *
4 | * Created on: 2015-7-11
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGE_SHAREDGLCONTEXT_H_
10 | #define _CGE_SHAREDGLCONTEXT_H_
11 |
12 | #import
13 | #import
14 | #import "cgeProcessingContext.h"
15 |
16 | @interface CGESharedGLContext : CGEProcessingContext
17 |
18 | @property(nonatomic,strong) EAGLContext *context;
19 |
20 | - (id)initWithShareGroup:(EAGLSharegroup*)shareGroup;
21 |
22 | - (void)makeCurrent;
23 |
24 | /////////////////////////////////////////////
25 |
26 | + (instancetype)globalGLContext;
27 |
28 | + (BOOL)isGlobalGLContextExist;
29 | //Attention: the pre-created context will be desctroyed after this function.
30 | //So you can use "isGlobalGLContextExist" to see if the context is created.
31 | + (instancetype)bindGlobalGLContext:(EAGLContext*)context;
32 |
33 | + (void)useGlobalGLContext;
34 | + (void)clearGlobalGLContext;
35 |
36 | + (void)globalSyncProcessingQueue:(void (^)(void))block;
37 | + (void)globalAsyncProcessingQueue:(void (^)(void))block;
38 |
39 | +(instancetype)createSharedContext:(CGESharedGLContext*)sharedContext;
40 | +(instancetype)createGlobalSharedContext;
41 |
42 |
43 | @end
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeVideoHandlerCV.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeVideoHandlerCV.h
3 | *
4 | * Created on: 2015-9-8
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGEVIDEOHANLERCV_H_
10 | #define _CGEVIDEOHANLERCV_H_
11 |
12 | #import
13 | #import
14 | #import
15 | #import "cgeImageHandler.h"
16 | #import "cgeTextureUtils.h"
17 |
18 | namespace CGE
19 | {
20 | class CGEVideoHandlerCV : public CGEImageHandler
21 | {
22 | public:
23 | CGEVideoHandlerCV();
24 | ~CGEVideoHandlerCV();
25 |
26 | bool initHandler();
27 |
28 | bool updateFrameWithCVImageBuffer(CVImageBufferRef);
29 |
30 | void cleanupYUVTextures();
31 |
32 | void processingFilters();
33 |
34 | inline TextureDrawerYUV* getYUVDrawer() { return m_yuvDrawer; }
35 |
36 | inline void replaceYUVDrawer(TextureDrawerYUV* drawer, bool shouldDelete = true)
37 | {
38 | if(shouldDelete)
39 | delete m_yuvDrawer;
40 | m_yuvDrawer = drawer;
41 | }
42 |
43 | bool reverseTargetSize() { return m_reverseTargetSize; }
44 |
45 | void setReverseTargetSize(bool rev) { m_reverseTargetSize = rev; }
46 |
47 | void swapBufferFBO();
48 |
49 | private:
50 |
51 | CVOpenGLESTextureCacheRef m_videoTextureCacheRef;
52 | CVOpenGLESTextureRef m_lumaTextureRef;
53 | CVOpenGLESTextureRef m_chromaTextureRef;
54 |
55 | TextureDrawerYUV* m_yuvDrawer;
56 | bool m_reverseTargetSize;
57 | };
58 | }
59 |
60 |
61 | #endif
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeVideoPlayer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeVideoPlayer.h
3 | *
4 | * Created on: 2015-10-14
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #import
10 | #import "cgeFrameRenderer.h"
11 |
12 | typedef enum CGEVideoPlayerLoadingStatus
13 | {
14 | CGEVideoPlayerLoadingStatus_Loading,
15 | CGEVideoPlayerLoadingStatus_LoadOK,
16 | CGEVideoPlayerLoadingStatus_LoadFailed,
17 | }CGEVideoPlayerLoadingStatus;
18 |
19 | @class CGEVideoPlayer;
20 |
21 | @protocol CGEVideoPlayerDelegate
22 |
23 | // 视频播放完毕
24 | @required
25 | - (void)videoPlayingComplete:(CGEVideoPlayer*)player playItem:(AVPlayerItem*)item;
26 |
27 | // 视频分辨率改变 (在 startWithURL 调用后触发)
28 | @optional
29 | - (void)videoResolutionChanged: (CGSize)size;
30 |
31 | // 播放时间更新
32 | @optional
33 | - (void)playTimeUpdated:(CMTime)currentTime;
34 |
35 | // 设定播放时间更新频率 (当未实现 playTimeUpdateInterval 方法时, 默认为一秒 CMTimeMakeWithSeconds(1, 1) )
36 | @optional
37 | - (CMTime)playTimeUpdateInterval;
38 |
39 | // 播放器状态改变
40 | @optional
41 | - (void)playerStatusChanged:(AVPlayerItemStatus)status;
42 |
43 | @end
44 |
45 | @interface CGEVideoPlayer : CGEFrameRenderer
46 |
47 | @property AVPlayer* avPlayer;
48 | @property AVPlayerItemVideoOutput* videoOutput;
49 | @property CADisplayLink* displayLink;
50 | @property(nonatomic) dispatch_semaphore_t videoSema;
51 |
52 | // 视频分辨率
53 | @property(nonatomic) CGSize videoResolution;
54 |
55 | @property(nonatomic, weak) id updateDelegate;
56 | @property(nonatomic, weak) id playerDelegate;
57 |
58 | @property(nonatomic, assign) CGEVideoPlayerLoadingStatus loadingStatus;
59 |
60 | @property(nonatomic, assign) BOOL requestFirstFrameThenPause;
61 |
62 | #pragma mark - 初始化相关
63 |
64 | - (id)initWithContext:(CGESharedGLContext *)sharedContext;
65 |
66 | #pragma mark - 视频 播放/设置 相关
67 |
68 | - (void)startWithURL:(NSURL*) url;
69 | - (void)startWithURL:(NSURL*) url completionHandler:(void (^)(NSError*))block;
70 |
71 | - (void)startWithAsset:(AVAsset*)asset completionHandler:(void (^)(NSError*))block;
72 |
73 | - (BOOL)isPlaying;
74 |
75 | - (void)restart;
76 | - (void)pause;
77 | - (void)resume;
78 |
79 | #pragma mark - --其他--
80 |
81 | // 视频处理方法
82 | - (void)processVideoFrame:(CVPixelBufferRef)pixBuffer;
83 |
84 | @end
85 |
--------------------------------------------------------------------------------
/library/cge/interfaces/cgeVideoPlayerViewHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeVideoPlayerViewHandler.h
3 | *
4 | * Created on: 2015-10-13
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 |
10 | // 对外接口, 添加较多中文注释
11 |
12 | #import
13 | #import "cgeVideoPlayer.h"
14 |
15 | typedef enum CGEVideoPlayerViewDisplayMode
16 | {
17 | CGEVideoPlayerViewDisplayModeScaleToFill,
18 | CGEVideoPlayerViewDisplayModeAspectFill,
19 | CGEVideoPlayerViewDisplayModeAspectFit,
20 | CGEVideoPlayerViewDisplayModeDefault = CGEVideoPlayerViewDisplayModeScaleToFill
21 | }CGEVideoPlayerViewDisplayMode;
22 |
23 | @interface CGEVideoPlayerViewHandler : NSObject
24 |
25 | @property(nonatomic) CGEVideoPlayer* videoPlayer;
26 |
27 | @property(weak, nonatomic) GLKView* glkView;
28 | @property(nonatomic) float maskAspectRatio; //使用的 mask 宽高比
29 | @property(nonatomic) CGRect viewArea;
30 |
31 | @property(nonatomic, setter=setViewDisplayMode:) CGEVideoPlayerViewDisplayMode displayMode;
32 | @property(nonatomic) BOOL shouldResetViewport;
33 | @property(nonatomic) BOOL shouldUpdateViewport;
34 |
35 | - (id)initWithGLKView:(GLKView*)glkView;
36 |
37 | #pragma mark - 播放相关接口
38 |
39 | //此接口将阻塞当前线程直到开始播放为止
40 | - (void)startWithURL:(NSURL*) url;
41 |
42 | //此接口当block为nil时将自动播放, 当block存在时需要手动开始播放(可写在block内)
43 | - (void)startWithURL:(NSURL*) url completionHandler:(void (^)(NSError*))block;
44 | - (void)startWithAsset:(AVAsset*)asset completionHandler:(void (^)(NSError*))block;
45 |
46 | - (BOOL)isPlaying;
47 |
48 | - (void)restart;
49 | - (void)pause;
50 | - (void)resume;
51 |
52 | - (CMTime)videoDuration; //正在播放的视频总时长
53 | - (CMTime)currentTime; //视频当前播放时间
54 | - (AVPlayerItemStatus)status; //播放器当前状态
55 |
56 | #pragma mark - 滤镜设定相关接口
57 | - (void)setFilterWithConfig :(const char*) config;
58 | - (void)setFilterIntensity :(float)value;
59 |
60 | #pragma mark - mask相关接口
61 |
62 | // mask设定中, 第一个参数填 nil 或者0 表示不使用mask
63 | - (void)setMaskUIImage :(UIImage*)image;
64 | - (void)setMaskTexture :(GLuint)maskTexture textureAspectRatio:(float)aspectRatio;
65 | - (BOOL)isUsingMask;
66 |
67 | #pragma mark - 显示相关的接口
68 |
69 | - (void)setViewDisplayMode :(CGEVideoPlayerViewDisplayMode)mode;
70 |
71 | #pragma mark - 其他接口
72 |
73 | - (void)clear;
74 |
75 | - (void)_updateViewArea; //For Private Usage. (Child Class)
76 | - (void)_updateViewArea:(float)ratio;
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/library/cge/libCGE-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // libCGE-Prefix.pch
3 | // cge
4 | //
5 | // Created by wysaid on 15/7/10.
6 | // Copyright (c) 2015年 wysaid. All rights reserved.
7 | //
8 |
9 | #ifndef cge_libCGE_Prefix_pch
10 | #define cge_libCGE_Prefix_pch
11 |
12 | #ifdef __OBJC__
13 | #import
14 | #endif
15 |
16 | // Include any system framework and library headers here that should be included in all compilation units.
17 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
18 |
19 | //仅作为编译文件内区分sdk版本使用, (V2.0.0开始)不再用来区分头文件 (各个版本分开指定相应的头文件)
20 | #ifndef IOS_SDK
21 | #define IOS_SDK 1
22 | #endif
23 |
24 | #ifndef CGE_TEXTURE_PREMULTIPLIED
25 | #define CGE_TEXTURE_PREMULTIPLIED 1
26 | #endif
27 |
28 | #ifndef _CGE_ONLY_FILTERS_
29 | #define _CGE_ONLY_FILTERS_ 1
30 | #endif
31 |
32 | #define _CGE_USE_GLOBAL_GL_CACHE_ 0
33 |
34 | //_CGE_STATIC_ASSERT_ 为过时设定, 用于兼容不支持 C++ 11 static_assert 配置
35 | //#define _CGE_STATIC_ASSERT_ 1
36 |
37 | //定义 _CGE_USE_LOG_ERR_ 可以强制开启所有的cge内建 error log
38 | #define _CGE_USE_LOG_ERR_ 1
39 |
40 | #define _CGE_DISABLE_GLOBALCONTEXT_ 1
41 |
42 | #define CGE_NSLog(...) NSLog(__VA_ARGS__)
43 |
44 | #if defined(DEBUG) || defined(_DEBUG)
45 |
46 | //#define _CGE_SHOW_RENDER_FPS_ 1
47 | #define CGE_NSLog_Code(...) __VA_ARGS__
48 | #define CGE_NSAssert NSAssert
49 |
50 | #else
51 |
52 | #define CGE_NSLog_Code(...)
53 | #define CGE_NSAssert(...)
54 |
55 | #endif
56 |
57 | #define CGE_GLK_TEXTURE_OPTION @{GLKTextureLoaderApplyPremultiplication : @(YES)}
58 |
59 | //#define CGE_USE_OPENAL 1
60 |
61 | //#define _CGE_GENERAL_ERROR_TEST_ 1
62 | #if defined(_CGE_GENERAL_ERROR_TEST_) && _CGE_GENERAL_ERROR_TEST_
63 | #define CGE_UNEXPECTED_ERR_MSG(...) __VA_ARGS__
64 | #else
65 | #define CGE_UNEXPECTED_ERR_MSG(...)
66 | #endif
67 |
68 | //#define CGE_USE_WEBP 1
69 |
70 | //#define CGE_USE_RAPIDJSON 1
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/library/cge/models/cgeBuiltinModels.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeBuiltinModels.h
3 | *
4 | * Created on: 2014-10-30
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | // 请勿在头文件里面包含 models 目录下的任何文件
10 | // 请在cpp 文件里面包含
11 |
12 | #ifndef _CGEBUILTINMODEL_H_
13 | #define _CGEBUILTINMODEL_H_
14 |
15 | #include "cgeModelCube.h"
16 | #include "cgeModelTeapot.h"
17 |
18 |
19 |
20 | #endif
--------------------------------------------------------------------------------
/library/cge/models/cgeModelCube.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeModelCube.h
3 | *
4 | * Created on: 2014-10-30
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGEMODELCUBE_H_
10 | #define _CGEMODELCUBE_H_
11 |
12 | namespace CGE
13 | {
14 | //使用 GL_TRIANGLES 方式绘制
15 | struct ModelCube
16 | {
17 | static const float vertices[];
18 | static const int vertDataSize = 3; // 每个顶点包含三个分量
19 | static const int vertSize;
20 |
21 | static const float vertTexture[]; // 纹理顶点
22 | static const int vertTextureSize; //每个纹理顶点包含两个分量
23 |
24 | static const float vertNormals[]; //顶点法向量
25 |
26 | static const unsigned short vertIndexes[];
27 | static const int vertIndexSize;
28 |
29 | };
30 |
31 | const float ModelCube::vertices[] = {
32 | 1, 1, 1, -1, 1, 1, -1,-1, 1, 1,-1, 1,
33 | 1, 1, 1, 1,-1, 1, 1,-1,-1, 1, 1,-1,
34 | 1, 1, 1, 1, 1,-1, -1, 1,-1, -1, 1, 1,
35 | -1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1,
36 | -1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1,
37 | 1,-1,-1, -1,-1,-1, -1, 1,-1, 1, 1,-1
38 | };
39 |
40 | const unsigned short ModelCube::vertIndexes[] = {
41 | 0, 1, 2, 0, 2, 3,
42 | 4, 5, 6, 4, 6, 7,
43 | 8, 9,10, 8,10,11,
44 | 12,13,14, 12,14,15,
45 | 16,17,18, 16,18,19,
46 | 20,21,22, 20,22,23
47 | };
48 |
49 | const float ModelCube::vertTexture[] = {
50 | 1, 1, 0, 1, 0, 0, 1, 0,
51 | 0, 1, 0, 0, 1, 0, 1, 1,
52 | 1, 0, 1, 1, 0, 1, 0, 0,
53 | 1, 1, 0, 1, 0, 0, 1, 0,
54 | 0, 0, 1, 0, 1, 1, 0, 1,
55 | 0, 0, 1, 0, 1, 1, 0, 1
56 | };
57 |
58 | const float ModelCube::vertNormals[] = {
59 | 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
60 | 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
61 | 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
62 | -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0,
63 | 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0,
64 | 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1
65 | };
66 |
67 | const int ModelCube::vertSize = sizeof(ModelCube::vertices);
68 | const int ModelCube::vertTextureSize = sizeof(ModelCube::vertTexture);
69 | const int ModelCube::vertIndexSize = sizeof(ModelCube::vertIndexes);
70 | }
71 |
72 | #endif
--------------------------------------------------------------------------------
/library/cge/src/animation/cgeAction.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeAction.h
3 | *
4 | * Created on: 2014-9-9
5 | * Author: Wang Yang
6 | * Mail: admin@wysaid.org
7 | */
8 |
9 | #ifndef _CGE_ONLY_FILTERS_
10 |
11 | #include "cgeAction.h"
12 |
13 | CGE_LOG_CODE
14 | (
15 | static bool sRemoveMe(std::vector& vec, CGE::TimeActionInterfaceAbstract* action)
16 | {
17 | for(std::vector::iterator iter = vec.begin(); iter != vec.end(); ++iter)
18 | {
19 | if(*iter == action)
20 | {
21 | vec.erase(iter);
22 | CGE_LOG_INFO("TimeAction deleted! total: %d\n", (int)vec.size());
23 | return true;
24 | }
25 | }
26 | return false;
27 | }
28 |
29 | static void sAddMe(std::vector& vec, CGE::TimeActionInterfaceAbstract* action)
30 | {
31 | vec.push_back(action);
32 | CGE_LOG_INFO("TimeAction created! total: %d\n", (int)vec.size());
33 | }
34 |
35 | //保存所有存在的action, 探测内存泄漏或者进行一些全局设置。
36 | static std::vector s_actionManager;
37 | )
38 |
39 | namespace CGE
40 | {
41 | CGE_LOG_CODE
42 | (
43 | std::vector& TimeActionInterfaceAbstract::getDebugManager()
44 | {
45 | return s_actionManager;
46 | }
47 | )
48 |
49 |
50 | TimeActionInterfaceAbstract::TimeActionInterfaceAbstract() : m_repeatTimes(1), m_startTime(0), m_endTime(0), m_duringTime(0)
51 | {
52 | CGE_LOG_CODE
53 | (
54 | sAddMe(s_actionManager, this);
55 | )
56 | }
57 |
58 | TimeActionInterfaceAbstract::TimeActionInterfaceAbstract(float startTime, float endTime, float repeatTimes) : m_repeatTimes(repeatTimes), m_startTime(startTime), m_endTime(endTime), m_duringTime(endTime - startTime)
59 | {
60 | CGE_LOG_CODE
61 | (
62 | sAddMe(s_actionManager, this);
63 | )
64 | }
65 |
66 | TimeActionInterfaceAbstract::~TimeActionInterfaceAbstract()
67 | {
68 | CGE_LOG_CODE
69 | (
70 | if(!sRemoveMe(s_actionManager, this))
71 | CGE_LOG_ERROR("Global remove action failed! Maybe memory leaks!");
72 | )
73 | }
74 |
75 | }
76 |
77 | #endif
78 |
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeAdvancedEffectsCommon.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeAdvancedEffectsCommon.cpp
3 | *
4 | * Created on: 2013-12-13
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeAdvancedEffectsCommon.h"
9 |
10 | namespace CGE
11 | {
12 | CGEConstString CGEAdvancedEffectOneStepFilterHelper::paramStepsName = "samplerSteps";
13 |
14 | void CGEAdvancedEffectOneStepFilterHelper::render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID)
15 | {
16 | handler->setAsTarget();
17 | m_program.bind();
18 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
19 | glEnableVertexAttribArray(0);
20 | glActiveTexture(GL_TEXTURE0);
21 | glBindTexture(GL_TEXTURE_2D, srcTexture);
22 |
23 | if(m_uniformParam != nullptr)
24 | m_uniformParam->assignUniforms(handler, m_program.programID());
25 |
26 | // Additional functions for new effects.
27 | {
28 | CGESizei sz = handler->getOutputFBOSize();
29 | m_program.sendUniformf(paramStepsName, 1.0f / sz.width, 1.0f / sz.height);
30 | }
31 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
32 | CGE_LOG_CODE
33 | (
34 | cgeCheckGLError("glDrawArrays");
35 | )
36 | }
37 |
38 | //////////////////////////////////////////////////////////////////////////
39 |
40 | CGEConstString CGEAdvancedEffectTwoStepFilterHelper::paramStepsName = "samplerSteps";
41 |
42 | void CGEAdvancedEffectTwoStepFilterHelper::render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID)
43 | {
44 | CGESizei sz = handler->getOutputFBOSize();
45 | m_program.bind();
46 |
47 | glActiveTexture(GL_TEXTURE0);
48 |
49 | //Pass one
50 | handler->setAsTarget();
51 | {
52 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
53 | glEnableVertexAttribArray(0);
54 | glBindTexture(GL_TEXTURE_2D, srcTexture);
55 |
56 | m_program.sendUniformf(paramStepsName, 0.0f, 1.0f / sz.height);
57 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
58 | }
59 | //Pass Two
60 | handler->swapBufferFBO();
61 | handler->setAsTarget();
62 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
63 | glEnableVertexAttribArray(0);
64 | glBindTexture(GL_TEXTURE_2D, handler->getBufferTextureID());
65 |
66 | m_program.sendUniformf(paramStepsName, 1.0f / sz.width, 0.0f);
67 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeColorLevelAdjust.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeColorLevelAdjust.cpp
3 | *
4 | * Created on: 2014-1-20
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeColorLevelAdjust.h"
9 |
10 | const static char* const s_fshColorLevel = CGE_SHADER_STRING_PRECISION_M
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 |
15 | uniform vec2 colorLevel;
16 | uniform float gamma;
17 |
18 | vec3 levelFunc(vec3 src, vec2 colorLevel)
19 | {
20 | return clamp((src - colorLevel.x) / (colorLevel.y - colorLevel.x), 0.0, 1.0);
21 | }
22 |
23 | vec3 gammaFunc(vec3 src, float value) //value: 0~1
24 | {
25 | return clamp(pow(src, vec3(value)), 0.0, 1.0);
26 | }
27 |
28 | void main()
29 | {
30 | vec4 src = texture2D(inputImageTexture, textureCoordinate);
31 | src.rgb = levelFunc(src.rgb, colorLevel);
32 | src.rgb = gammaFunc(src.rgb, gamma);
33 | gl_FragColor = src;
34 | }
35 | );
36 |
37 | namespace CGE
38 | {
39 | CGEConstString CGEColorLevelFilter::paramLevelName = "colorLevel";
40 | CGEConstString CGEColorLevelFilter::paramGammaName = "gamma";
41 |
42 | bool CGEColorLevelFilter::init()
43 | {
44 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshColorLevel))
45 | {
46 | setGamma(1.0f);
47 | setLevel(0.0f, 1.0f);
48 | return true;
49 | }
50 | return false;
51 | }
52 |
53 | void CGEColorLevelFilter::setLevel(float dark, float light)
54 | {
55 | m_program.bind();
56 | m_program.sendUniformf(paramLevelName, dark, light);
57 | }
58 |
59 | void CGEColorLevelFilter::setGamma(float value)
60 | {
61 | m_program.bind();
62 | m_program.sendUniformf(paramGammaName, value);
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeContrastAdjust.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeContrastAdjust.cpp
3 | *
4 | * Created on: 2013-12-26
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeContrastAdjust.h"
9 |
10 | const static char* const s_fshContrast = CGE_SHADER_STRING_PRECISION_H
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 | uniform float intensity;
15 |
16 | void main()
17 | {
18 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
19 | gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * intensity + vec3(0.5)), textureColor.a);
20 | }
21 |
22 | );
23 |
24 | namespace CGE
25 | {
26 | CGEConstString CGEContrastFilter::paramName = "intensity";
27 |
28 | bool CGEContrastFilter::init()
29 | {
30 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshContrast))
31 | {
32 | return true;
33 | }
34 | return false;
35 | }
36 |
37 | void CGEContrastFilter::setIntensity(float value)
38 | {
39 | m_program.bind();
40 | m_program.sendUniformf(paramName, value);
41 | }
42 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeCrosshatchFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeCrosshatchFilter.cpp
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeCrosshatchFilter.h"
9 |
10 | CGEConstString s_fshCrosshatch = CGE_SHADER_STRING_PRECISION_H
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 |
15 | uniform float crossHatchSpacing;
16 | uniform float lineWidth;
17 |
18 | const vec3 W = vec3(0.2125, 0.7154, 0.0721);
19 |
20 | void main()
21 | {
22 | vec4 color = texture2D(inputImageTexture, textureCoordinate);
23 | float luminance = dot(color.rgb, W);
24 |
25 | vec4 colorToDisplay = vec4(1.0, 1.0, 1.0, color.a);
26 | if (luminance < 1.00)
27 | {
28 | if (mod(textureCoordinate.x + textureCoordinate.y, crossHatchSpacing) <= lineWidth)
29 | {
30 | colorToDisplay.rgb = vec3(0.0, 0.0, 0.0);
31 | }
32 | }
33 | if (luminance < 0.75)
34 | {
35 | if (mod(textureCoordinate.x - textureCoordinate.y, crossHatchSpacing) <= lineWidth)
36 | {
37 | colorToDisplay.rgb = vec3(0.0, 0.0, 0.0);
38 | }
39 | }
40 | if (luminance < 0.50)
41 | {
42 | if (mod(textureCoordinate.x + textureCoordinate.y - (crossHatchSpacing / 2.0), crossHatchSpacing) <= lineWidth)
43 | {
44 | colorToDisplay.rgb = vec3(0.0, 0.0, 0.0);
45 | }
46 | }
47 | if (luminance < 0.3)
48 | {
49 | if (mod(textureCoordinate.x - textureCoordinate.y - (crossHatchSpacing / 2.0), crossHatchSpacing) <= lineWidth)
50 | {
51 | colorToDisplay.rgb = vec3(0.0, 0.0, 0.0);
52 | }
53 | }
54 |
55 | gl_FragColor = colorToDisplay;
56 | }
57 | );
58 |
59 |
60 | namespace CGE
61 | {
62 | CGEConstString CGECrosshatchFilter::paramCrosshatchSpacing = "crossHatchSpacing";
63 | CGEConstString CGECrosshatchFilter::paramLineWidth = "lineWidth";
64 |
65 | bool CGECrosshatchFilter::init()
66 | {
67 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshCrosshatch))
68 | {
69 | setCrosshatchSpacing(0.03f);
70 | setLineWidth(0.003f);
71 | return true;
72 | }
73 | return false;
74 | }
75 |
76 | void CGECrosshatchFilter::setCrosshatchSpacing(float value)
77 | {
78 | m_program.bind();
79 | m_program.sendUniformf(paramCrosshatchSpacing, value);
80 | }
81 |
82 | void CGECrosshatchFilter::setLineWidth(float value)
83 | {
84 | m_program.bind();
85 | m_program.sendUniformf(paramLineWidth, value);
86 | }
87 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeDynamicFilters.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeDynamicFilters.cpp
3 | *
4 | * Created on: 2015-11-18
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeDynamicFilters.h"
9 |
10 | #define COMMON_FUNC(type) \
11 | type* proc = new type();\
12 | if(!proc->init())\
13 | {\
14 | delete proc;\
15 | proc = NULL;\
16 | }\
17 | return proc;\
18 |
19 | namespace CGE
20 | {
21 |
22 | CGEDynamicWaveFilter* createDynamicWaveFilter()
23 | {
24 | COMMON_FUNC(CGEDynamicWaveFilter);
25 | }
26 |
27 | CGEMotionFlowFilter* createMotionFlowFilter()
28 | {
29 | COMMON_FUNC(CGEMotionFlowFilter);
30 | }
31 |
32 | CGEMotionFlow2Filter* createMotionFlow2Filter()
33 | {
34 | COMMON_FUNC(CGEMotionFlow2Filter);
35 | }
36 |
37 | CGESoulStuffFilter* createSoulStuffFilter()
38 | {
39 | COMMON_FUNC(CGESoulStuffFilter);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeEmbossFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeEmbossFilter.cpp
3 | *
4 | * Created on: 2013-12-27
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeEmbossFilter.h"
9 | #include "cgeMat.h"
10 |
11 | const static char* const s_fshEmboss = CGE_SHADER_STRING_PRECISION_M
12 | (
13 | uniform sampler2D inputImageTexture;
14 | varying vec2 textureCoordinate;
15 | uniform vec2 samplerSteps;
16 | uniform float stride;
17 | uniform float intensity;
18 | uniform vec2 norm;
19 |
20 | void main() {
21 | vec4 src = texture2D(inputImageTexture, textureCoordinate);
22 | vec3 tmp = texture2D(inputImageTexture, textureCoordinate + samplerSteps * stride * norm).rgb - src.rgb + 0.5;
23 | float f = (tmp.r + tmp.g + tmp.b) / 3.0;
24 | gl_FragColor = vec4(mix(src.rgb, vec3(f, f, f), intensity), src.a);
25 | }
26 | );
27 |
28 | namespace CGE
29 | {
30 | CGEConstString CGEEmbossFilter::paramIntensity = "intensity";
31 | CGEConstString CGEEmbossFilter::paramStride = "stride";
32 | CGEConstString CGEEmbossFilter::paramNorm = "norm";
33 |
34 | bool CGEEmbossFilter::init()
35 | {
36 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshEmboss))
37 | {
38 | setIntensity(1.0f);
39 | setStride(2.0f);
40 | setAngle(M_PI * 0.75f);
41 | return true;
42 | }
43 | return false;
44 | }
45 |
46 | void CGEEmbossFilter::setIntensity(float value)
47 | {
48 | m_program.bind();
49 | m_program.sendUniformf(paramIntensity, value);
50 | }
51 |
52 | void CGEEmbossFilter::setStride(float value)
53 | {
54 | m_program.bind();
55 | m_program.sendUniformf(paramStride, value);
56 | }
57 |
58 | void CGEEmbossFilter::setAngle(float value)
59 | {
60 | Vec2f v = Mat2::makeRotation(value) * Vec2f(1.0f, 0.0f);
61 | m_program.bind();
62 | m_program.sendUniformf(paramNorm, v[0], v[1]);
63 | }
64 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeExposureAdjust.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeExposureAdjust.cpp
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeExposureAdjust.h"
9 |
10 | static CGEConstString s_fshExposure = CGE_SHADER_STRING_PRECISION_H
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 |
15 | uniform float exposure;
16 |
17 | void main()
18 | {
19 | vec4 color = texture2D(inputImageTexture, textureCoordinate);
20 | gl_FragColor = vec4(color.rgb * exp2(exposure), color.a);
21 | });
22 |
23 | namespace CGE
24 | {
25 | CGEConstString CGEExposureFilter::paramName = "exposure";
26 |
27 | bool CGEExposureFilter::init()
28 | {
29 | return initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshExposure);
30 | }
31 |
32 | void CGEExposureFilter::setIntensity(float value)
33 | {
34 | m_program.bind();
35 | m_program.sendUniformf(paramName, value);
36 | }
37 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeHalftoneFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHalftoneFilter.cpp
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeHalftoneFilter.h"
9 |
10 | static CGEConstString s_fshHalftone = CGE_SHADER_STRING_PRECISION_H
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 |
15 | uniform vec2 dotPercent;
16 | uniform float aspectRatio;
17 |
18 | //const vec3 weight = vec3(0.2125, 0.7154, 0.0721);
19 |
20 | void main()
21 | {
22 | vec2 samplePos = textureCoordinate - mod(textureCoordinate, dotPercent) + 0.5 * dotPercent;
23 | vec2 coordToUse = vec2(textureCoordinate.x, (textureCoordinate.y - 0.5) * aspectRatio + 0.5);
24 | vec2 adjustedPos = vec2(samplePos.x, (samplePos.y - 0.5) * aspectRatio + 0.5);
25 |
26 | float dis = distance(coordToUse, adjustedPos);
27 |
28 | vec4 color = texture2D(inputImageTexture, samplePos);
29 | vec3 dotScaling = 1.0 - color.rgb;//dot(color.rgb, weight);
30 | vec3 presenceDot = 1.0 - step(dis, dotPercent.x * dotScaling * 0.5);
31 |
32 | gl_FragColor = vec4(presenceDot, color.a);
33 | });
34 |
35 | namespace CGE
36 | {
37 | CGEConstString CGEHalftoneFilter::paramAspectRatio = "aspectRatio";
38 | CGEConstString CGEHalftoneFilter::paramDotPercent = "dotPercent";
39 |
40 | bool CGEHalftoneFilter::init()
41 | {
42 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshHalftone))
43 | {
44 | setDotSize(1.0f);
45 | return true;
46 | }
47 | return false;
48 | }
49 |
50 | void CGEHalftoneFilter::setDotSize(float value)
51 | {
52 | m_dotSize = value;
53 | }
54 |
55 | void CGEHalftoneFilter::render2Texture(CGE::CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID)
56 | {
57 | handler->setAsTarget();
58 | m_program.bind();
59 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
60 | glEnableVertexAttribArray(0);
61 | glActiveTexture(GL_TEXTURE0);
62 | glBindTexture(GL_TEXTURE_2D, srcTexture);
63 |
64 | CGESizei sz = handler->getOutputFBOSize();
65 | float aspectRatio = sz.width / (float)sz.height;
66 | float dotPercent = m_dotSize / sz.width;
67 | m_program.sendUniformf(paramAspectRatio, aspectRatio);
68 | m_program.sendUniformf(paramDotPercent, dotPercent, dotPercent / aspectRatio);
69 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
70 | CGE_LOG_CODE
71 | (
72 | cgeCheckGLError("glDrawArrays");
73 | )
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeHazeFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHazeFilter.cpp
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeHazeFilter.h"
9 |
10 | static CGEConstString s_fshHaze = CGE_SHADER_STRING_PRECISION_M
11 | (
12 | varying vec2 textureCoordinate;
13 |
14 | uniform sampler2D inputImageTexture;
15 |
16 | uniform float dis;
17 | uniform float slope;
18 | uniform vec3 hazeColor;
19 |
20 | void main()
21 | {
22 | float d = textureCoordinate.y * slope + dis;
23 |
24 | vec4 c = texture2D(inputImageTexture, textureCoordinate);
25 |
26 | c.rgb = (c.rgb - d * hazeColor.rgb) / (1.0 -d);
27 |
28 | gl_FragColor = c;
29 | });
30 |
31 | namespace CGE
32 | {
33 | CGEConstString CGEHazeFilter::paramDistance = "dis";
34 | CGEConstString CGEHazeFilter::paramSlope = "slope";
35 | CGEConstString CGEHazeFilter::paramHazeColor = "hazeColor";
36 |
37 | bool CGEHazeFilter::init()
38 | {
39 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshHaze))
40 | {
41 | setDistance(0.2f);
42 | setHazeColor(1.0f, 1.0f, 1.0f);
43 | return true;
44 | }
45 | return false;
46 | }
47 |
48 | void CGEHazeFilter::setDistance(float value)
49 | {
50 | m_program.bind();
51 | m_program.sendUniformf(paramDistance, value);
52 | }
53 |
54 | void CGEHazeFilter::setSlope(float value)
55 | {
56 | m_program.bind();
57 | m_program.sendUniformf(paramSlope, value);
58 | }
59 |
60 | void CGEHazeFilter::setHazeColor(float r, float g, float b)
61 | {
62 | m_program.bind();
63 | m_program.sendUniformf(paramHazeColor, r, g, b);
64 | }
65 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeHueAdjust.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeHueAdjust.cpp
3 | *
4 | * Created on: 2015-1-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeHueAdjust.h"
9 |
10 | static CGEConstString s_fshHue = CGE_SHADER_STRING_PRECISION_H
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 |
15 | uniform float hueAdjust;
16 |
17 | vec3 rgb2yiq(vec3 src)
18 | {
19 | return src * mat3(0.299, 0.587, 0.114,
20 | 0.595716, -0.274453, -0.321263,
21 | 0.211456, -0.522591, 0.31135);
22 | }
23 |
24 | vec3 yiq2rgb(vec3 src)
25 | {
26 | return src * mat3(1.0, 0.9563, 0.6210,
27 | 1.0, -0.2721, -0.6474,
28 | 1.0, -1.1070, 1.7046);
29 | }
30 |
31 | void main()
32 | {
33 | vec4 color = texture2D(inputImageTexture, textureCoordinate);
34 | vec3 yiq = rgb2yiq(color.rgb);
35 | float hue = atan(yiq.z, yiq.y);
36 | float chroma = length(yiq.yz);
37 |
38 | hue -= hueAdjust;
39 | yiq.yz = vec2(cos(hue), sin(hue)) * chroma;
40 |
41 | gl_FragColor = vec4(yiq2rgb(yiq), color.a);
42 | });
43 |
44 | namespace CGE
45 | {
46 | CGEConstString CGEHueAdjustFilter::paramName = "hueAdjust";
47 |
48 | bool CGEHueAdjustFilter::init()
49 | {
50 | return initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshHue);
51 | }
52 |
53 | void CGEHueAdjustFilter::setHue(float value)
54 | {
55 | m_program.bind();
56 | m_program.sendUniformf(paramName, value);
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeLookupFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeLookupFilter.cpp
3 | *
4 | * Created on: 2016-7-4
5 | * Author: Wang Yang
6 | * Description: 全图LUT滤镜
7 | */
8 |
9 | #include "cgeLookupFilter.h"
10 |
11 | static CGEConstString s_fsh = CGE_SHADER_STRING_PRECISION_H
12 | (
13 | varying vec2 textureCoordinate;
14 | uniform sampler2D inputImageTexture;
15 | uniform sampler2D lookupTexture;
16 |
17 | const float stepDis = 1.0 / 8.0;
18 | const float perPixel = 1.0 / 512.0;
19 | const float halfPixel = 0.5 / 512.0;
20 |
21 | void main()
22 | {
23 | vec4 color = texture2D(inputImageTexture, textureCoordinate);
24 |
25 | float blue = color.b * 63.0;
26 | vec2 coord1;
27 | coord1.y = floor(floor(blue) / 8.0);
28 | coord1.x = floor(blue) - (coord1.y * 8.0);
29 |
30 | vec2 coord2;
31 | coord2.y = floor(ceil(blue) / 8.0);
32 | coord2.x = ceil(blue) - (coord2.y * 8.0);
33 |
34 | vec2 stepsCalc = halfPixel + (stepDis - perPixel) * color.xy;
35 |
36 | coord1 = coord1 * stepDis + stepsCalc;
37 | coord2 = coord2 * stepDis + stepsCalc;
38 |
39 | vec3 lutColor1 = texture2D(lookupTexture, coord1).rgb;
40 | vec3 lutColor2 = texture2D(lookupTexture, coord2).rgb;
41 |
42 | gl_FragColor.rgb = mix(lutColor1, lutColor2, fract(blue));
43 | gl_FragColor.a = color.a;
44 | }
45 | );
46 |
47 | namespace CGE
48 | {
49 | CGELookupFilter::CGELookupFilter() : m_lookupTexture(0)
50 | {
51 |
52 | }
53 |
54 | CGELookupFilter::~CGELookupFilter()
55 | {
56 | glDeleteTextures(1, &m_lookupTexture);
57 | }
58 |
59 | bool CGELookupFilter::init()
60 | {
61 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fsh))
62 | {
63 | m_program.bind();
64 | m_program.sendUniformi("lookupTexture", 1);
65 | return true;
66 | }
67 | return false;
68 | }
69 |
70 | void CGELookupFilter::render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID)
71 | {
72 | glActiveTexture(GL_TEXTURE1);
73 | glBindTexture(GL_TEXTURE_2D, m_lookupTexture);
74 | CGEImageFilterInterface::render2Texture(handler, srcTexture, vertexBufferID);
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeMaxValueFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMaxValueFilter.cpp
3 | *
4 | * Created on: 2015-3-20
5 | * Author: Wang Yang
6 | * Description: 最大值滤波
7 | */
8 |
9 | #include "cgeMaxValueFilter.h"
10 |
11 | static CGEConstString s_maxValueFunc = CGE_SHADER_STRING
12 | (
13 | float lum(vec4 value)
14 | {
15 | return dot(value.rgb, vec3(0.299, 0.587, 0.114));
16 | }
17 | vec4 getValue(vec4 newValue, vec4 originValue)
18 | {
19 | return mix(newValue, originValue, step(lum(newValue), lum(originValue)));
20 | });
21 |
22 | namespace CGE
23 | {
24 | const char* CGEMaxValueFilter3x3::getShaderCompFunc()
25 | {
26 | return s_maxValueFunc;
27 | }
28 |
29 | const char* CGEMaxValueFilter3x3Plus::getShaderCompFunc()
30 | {
31 | return s_maxValueFunc;
32 | }
33 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeMosaicBlurFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeMosaicBlur.cpp
3 | *
4 | * Created on: 2014-4-10
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeMosaicBlurFilter.h"
9 |
10 | static CGEConstString s_fshMosaic = CGE_SHADER_STRING_PRECISION_M
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 | uniform vec2 samplerSteps;
15 | uniform float blurPixels;
16 |
17 | void main()
18 | {
19 | vec2 coord = floor(textureCoordinate / samplerSteps / blurPixels) * samplerSteps * blurPixels;
20 | gl_FragColor = texture2D(inputImageTexture, coord + samplerSteps * 0.5);
21 | }
22 | );
23 |
24 | namespace CGE
25 | {
26 | CGEConstString CGEMosaicBlurFilter::paramBlurPixelsName = "blurPixels";
27 |
28 | bool CGEMosaicBlurFilter::init()
29 | {
30 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshMosaic))
31 | {
32 | setBlurPixels(1.0f);
33 | return true;
34 | }
35 | return false;
36 | }
37 |
38 | void CGEMosaicBlurFilter::setBlurPixels(float value)
39 | {
40 | m_program.bind();
41 | m_program.sendUniformf(paramBlurPixelsName, value);
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgePolarPixellateFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgePolarPixellateFilter.cpp
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgePolarPixellateFilter.h"
9 |
10 | static CGEConstString s_fshPolarPixellate = CGE_SHADER_STRING_PRECISION_M
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 |
15 | uniform vec2 center;
16 | uniform vec2 pixelSize;
17 |
18 | void main()
19 | {
20 | vec2 normCoord = 2.0 * textureCoordinate - 1.0;
21 | vec2 normCenter = 2.0 * center - 1.0;
22 |
23 | normCoord -= normCenter;
24 |
25 | float r = length(normCoord); // to polar coords
26 | float phi = atan(normCoord.y, normCoord.x); // to polar coords
27 |
28 | r = r - mod(r, pixelSize.x) + 0.03;
29 | phi = phi - mod(phi, pixelSize.y);
30 |
31 | normCoord.x = r * cos(phi);
32 | normCoord.y = r * sin(phi);
33 |
34 | normCoord += normCenter;
35 |
36 | vec2 textureCoordinateToUse = normCoord / 2.0 + 0.5;
37 |
38 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse);
39 | });
40 |
41 | namespace CGE
42 | {
43 | CGEConstString CGEPolarPixellateFilter::paramCenter = "center";
44 | CGEConstString CGEPolarPixellateFilter::paramPixelSize = "pixelSize";
45 |
46 | bool CGEPolarPixellateFilter::init()
47 | {
48 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshPolarPixellate))
49 | {
50 | setCenter(0.5f, 0.5f);
51 | setPixelSize(0.05f, 0.05f);
52 | return true;
53 | }
54 | return false;
55 | }
56 |
57 | void CGEPolarPixellateFilter::setCenter(float x, float y)
58 | {
59 | m_program.bind();
60 | m_program.sendUniformf(paramCenter, x, y);
61 | }
62 |
63 | void CGEPolarPixellateFilter::setPixelSize(float x, float y)
64 | {
65 | m_program.bind();
66 | m_program.sendUniformf(paramPixelSize, x, y);
67 | }
68 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgePolkaDotFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgePolkaDotFilter.cpp
3 | *
4 | * Created on: 2015-2-1
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgePolkaDotFilter.h"
9 |
10 | static CGEConstString s_fshPolkaDot = CGE_SHADER_STRING_PRECISION_M
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 |
15 | uniform vec2 dotPercent;
16 | uniform float aspectRatio;
17 | uniform float dotScaling;
18 |
19 | void main()
20 | {
21 | vec2 samplePos = textureCoordinate - mod(textureCoordinate, dotPercent) + 0.5 * dotPercent;
22 | vec2 coordToUse = vec2(textureCoordinate.x, (textureCoordinate.y - 0.5) * aspectRatio + 0.5);
23 | vec2 adjustedPos = vec2(samplePos.x, (samplePos.y - 0.5) * aspectRatio + 0.5);
24 | float dis = distance(coordToUse, adjustedPos);
25 | float checkForPresenceWithinDot = step(dis, (dotPercent.x * 0.5) * dotScaling);
26 | vec4 color = texture2D(inputImageTexture, samplePos);
27 | gl_FragColor = vec4(color.rgb * checkForPresenceWithinDot, color.a);
28 |
29 | });
30 |
31 | namespace CGE
32 | {
33 | CGEConstString CGEPolkaDotFilter::paramDotScaling = "dotScaling";
34 |
35 | bool CGEPolkaDotFilter::init()
36 | {
37 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshPolkaDot))
38 | {
39 | setDotScaling(0.9f);
40 | setDotSize(1.0f);
41 | return true;
42 | }
43 | return false;
44 | }
45 |
46 | void CGEPolkaDotFilter::setDotScaling(float value)
47 | {
48 | m_program.bind();
49 | m_program.sendUniformf(paramDotScaling, value);
50 | }
51 | }
--------------------------------------------------------------------------------
/library/cge/src/filters/cgeRandomBlurFilter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * cgeRandomBlurFilter.cpp
3 | *
4 | * Created on: 2013-12-29
5 | * Author: Wang Yang
6 | */
7 |
8 | #include "cgeRandomBlurFilter.h"
9 |
10 | const static char* const s_fshRandomBlur = CGE_SHADER_STRING_PRECISION_M
11 | (
12 | varying vec2 textureCoordinate;
13 | uniform sampler2D inputImageTexture;
14 | uniform vec2 samplerSteps;
15 | uniform float blurSamplerScale;
16 | uniform float intensity;
17 | uniform float samplerRadius;
18 |
19 | float random(vec2 seed)
20 | {
21 | return fract(sin(dot(seed ,vec2(12.9898,78.233))) * 43758.5453);
22 | }
23 |
24 | void main()
25 | {
26 | vec3 sumColor = vec3(0.0, 0.0, 0.0);
27 | float dir = random(textureCoordinate);
28 | float samplingCount = 0.0;
29 | for(float fy = -samplerRadius; fy <= samplerRadius; ++fy)
30 | {
31 | for(float fx = -samplerRadius; fx <= samplerRadius; ++fx)
32 | {
33 | float dis = length(vec2(fx, fy) * samplerSteps) * blurSamplerScale;
34 | vec2 coord = dis * vec2(cos(dir), sin(dir));
35 | sumColor += texture2D(inputImageTexture, textureCoordinate + coord).rgb;
36 | ++samplingCount;
37 | }
38 | }
39 |
40 | vec4 src = texture2D(inputImageTexture, textureCoordinate);
41 |
42 | vec3 dst = mix(src.rgb, sumColor / samplingCount, intensity);
43 | gl_FragColor = vec4(dst, src.a);
44 | }
45 | );
46 |
47 | namespace CGE
48 | {
49 | CGEConstString CGERandomBlurFilter::paramIntensity = "intensity";
50 | CGEConstString CGERandomBlurFilter::paramSamplerScale = "blurSamplerScale";
51 | CGEConstString CGERandomBlurFilter::paramSamplerRadius = "samplerRadius";
52 |
53 | bool CGERandomBlurFilter::init()
54 | {
55 | if(initShadersFromString(g_vshDefaultWithoutTexCoord, s_fshRandomBlur))
56 | {
57 | setIntensity(1.0f);
58 | setSamplerScale(2.0f);
59 | return true;
60 | }
61 | return false;
62 | }
63 |
64 | void CGERandomBlurFilter::setIntensity(float value)
65 | {
66 | m_program.bind();
67 | m_program.sendUniformf(paramIntensity, value);
68 | }
69 |
70 | void CGERandomBlurFilter::setSamplerScale(float value)
71 | {
72 | m_program.bind();
73 | m_program.sendUniformf(paramSamplerScale, value);
74 | if(value > 10.0f) value = 5.0f;
75 | m_program.sendUniformf(paramSamplerRadius, value);
76 | }
77 | }
--------------------------------------------------------------------------------
/library/cgeFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/library/cgeFramework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | zh_CN
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 2.5.1
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/library/cgeStatic.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/library/filterLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/library/filterLib/CustomFilter_0.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomFilter_0.h
3 | // filterLib
4 | //
5 | // Created by wangyang on 16/8/2.
6 | // Copyright © 2016年 wysaid. All rights reserved.
7 | //
8 |
9 | #ifndef CustomFilter_0_h
10 | #define CustomFilter_0_h
11 |
12 | #include "cgeGLFunctions.h"
13 |
14 | //standard demo
15 |
16 | class CustomFilter_0 : public CGE::CGEImageFilterInterface
17 | {
18 | public:
19 |
20 | bool init();
21 |
22 | void render2Texture(CGE::CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID);
23 |
24 | protected:
25 | GLint mStepLoc;
26 | };
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/library/filterLib/CustomFilter_N.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomFilter_N.h
3 | // filterLib
4 | //
5 | // Created by wangyang on 16/8/2.
6 | // Copyright © 2016年 wysaid. All rights reserved.
7 | //
8 |
9 | #ifndef CustomFilter_N_h
10 | #define CustomFilter_N_h
11 |
12 | #include "CustomFilter_0.h"
13 |
14 | class CustomFilter_1 : public CGE::CGEImageFilterInterface
15 | {
16 | public:
17 |
18 | bool init();
19 |
20 | };
21 |
22 | class CustomFilter_2 : public CustomFilter_0
23 | {
24 | public:
25 |
26 | bool init();
27 |
28 | };
29 |
30 | class CustomFilter_3 : public CGE::CGEImageFilterInterface
31 | {
32 | public:
33 |
34 | bool init();
35 |
36 | };
37 |
38 | class CustomFilter_4 : public CGE::CGEImageFilterInterface
39 | {
40 | public:
41 |
42 | bool init();
43 |
44 | };
45 |
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/library/filterLib/CustomHelper.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // CustomHelper.cpp
3 | // filterLib
4 | //
5 | // Created by wysaid on 16/1/11.
6 | // Copyright © 2016年 wysaid. All rights reserved.
7 | //
8 |
9 | #include "CustomHelper.h"
10 | #include "CustomFilter_0.h"
11 | #include "CustomFilter_N.h"
12 |
13 | #define CREATE_FILTER(var, Type) \
14 | do{\
15 | var = new Type(); \
16 | if(!var->init()) \
17 | {\
18 | delete var; \
19 | var = nullptr; \
20 | }}while(0);
21 |
22 | namespace CGE
23 | {
24 | CGEImageFilterInterface* cgeCreateCustomFilterByType(CustomFilterType type)
25 | {
26 | CGEImageFilterInterface* resultFilter = nullptr;
27 |
28 | switch (type)
29 | {
30 | case CGE_CUSTOM_FILTER_0:
31 | CREATE_FILTER(resultFilter, CustomFilter_0);
32 | break;
33 | case CGE_CUSTOM_FILTER_1:
34 | CREATE_FILTER(resultFilter, CustomFilter_1);
35 | break;
36 | case CGE_CUSTOM_FILTER_2:
37 | CREATE_FILTER(resultFilter, CustomFilter_2);
38 | break;
39 | case CGE_CUSTOM_FILTER_3:
40 | CREATE_FILTER(resultFilter, CustomFilter_3);
41 | break;
42 | case CGE_CUSTOM_FILTER_4:
43 | CREATE_FILTER(resultFilter, CustomFilter_4);
44 | break;
45 | default:
46 | return nullptr;
47 | }
48 |
49 | return resultFilter;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/library/filterLib/CustomHelper.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomHelper.h
3 | // filterLib
4 | //
5 | // Created by wysaid on 16/1/11.
6 | // Copyright © 2016年 wysaid. All rights reserved.
7 | //
8 |
9 | #ifndef CommonHelper_h
10 | #define CommonHelper_h
11 |
12 | #include "cgeGLFunctions.h"
13 | #include "cgeCustomFilters.h"
14 |
15 | namespace CGE
16 | {
17 | CGEImageFilterInterface* cgeCreateCustomFilterByType(CustomFilterType type);
18 | }
19 |
20 | #endif /* IFCommonHelper_h */
21 |
--------------------------------------------------------------------------------
/library/filterLib/cgeCustomFilters.h:
--------------------------------------------------------------------------------
1 | //
2 | // cgeCustomFilters.h
3 | // filterLib
4 | //
5 | // Created by wysaid on 16/1/11.
6 | // Copyright © 2016年 wysaid. All rights reserved.
7 | //
8 |
9 | #ifndef cgeCustomFilters_h
10 | #define cgeCustomFilters_h
11 |
12 | typedef enum CustomFilterType
13 | {
14 | CGE_CUSTOM_FILTER_0,
15 | CGE_CUSTOM_FILTER_1,
16 | CGE_CUSTOM_FILTER_2,
17 | CGE_CUSTOM_FILTER_3,
18 | CGE_CUSTOM_FILTER_4,
19 | CGE_FILTER_TOTAL_NUMBER
20 | } CustomFilterType;
21 |
22 | #ifdef __OBJC__
23 |
24 | #import
25 | #import "cgeSharedGLContext.h"
26 |
27 | #ifdef __cplusplus
28 | extern "C"
29 | {
30 | #endif
31 |
32 | //intensity: 0 for origin, 1 for normal, below 0 for neg effect, above 1 for enhanced effect.
33 | //processingContext: nil for global context, otherwise use the context you provided.
34 | UIImage* cgeFilterUIImage_CustomFilters(UIImage* uiimage, CustomFilterType type, float intensity, CGESharedGLContext* processingContext);
35 |
36 | //args meanings is the same to the above.
37 | //type "CGEMutipleEffectFilter" will be returned.
38 | void* cgeCreateCustomFilter(CustomFilterType type, float intensity, CGESharedGLContext* processingContext);
39 |
40 |
41 | #ifdef __cplusplus
42 | }
43 | #endif
44 |
45 | #endif
46 | #endif
47 |
--------------------------------------------------------------------------------
/screenshots/0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/screenshots/0.jpg
--------------------------------------------------------------------------------
/screenshots/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/screenshots/1.jpg
--------------------------------------------------------------------------------
/screenshots/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/screenshots/2.jpg
--------------------------------------------------------------------------------
/screenshots/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/screenshots/3.jpg
--------------------------------------------------------------------------------
/screenshots/alipay.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wysaid/ios-gpuimage-plus/HEAD/screenshots/alipay.jpg
--------------------------------------------------------------------------------