├── .gitignore
├── LICENSE
├── README.md
├── build
└── cocos2d-x-filters
│ └── cocos2d-x-filters.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ └── xcschemes
│ ├── cocos2d-x-filters-ios.xcscheme
│ └── cocos2d-x-filters-mac.xcscheme
├── demos
├── Resources
│ └── res
│ │ ├── CloseNormal.png
│ │ ├── CloseSelected.png
│ │ ├── HelloWorld2.png
│ │ ├── HelloWorld3.png
│ │ ├── b1.png
│ │ ├── b2.png
│ │ ├── bg.jpg
│ │ ├── close.png
│ │ ├── colorRamp.png
│ │ ├── colors.png
│ │ ├── colors2.png
│ │ ├── dirt.png
│ │ ├── f1.png
│ │ ├── f2.png
│ │ ├── grass.png
│ │ ├── grass10.png
│ │ ├── grass2.png
│ │ ├── grass3.png
│ │ ├── grass4.png
│ │ ├── grass5.png
│ │ ├── helloworld.png
│ │ ├── helloworld1.png
│ │ ├── mask.png
│ │ ├── mask10.png
│ │ ├── r1.png
│ │ ├── r2.png
│ │ ├── red.png
│ │ ├── test.plist
│ │ ├── test.png
│ │ ├── test2.plist
│ │ ├── test2.png
│ │ ├── test3.plist
│ │ ├── test3.png
│ │ └── test3.tps
└── filters-cpp-demo
│ ├── .cocos-project.json
│ ├── CMakeLists.txt
│ ├── Classes
│ ├── AppDelegate.cpp
│ ├── AppDelegate.h
│ ├── FilterSample.cpp
│ ├── FilterSample.h
│ ├── VisibleRect.cpp
│ └── VisibleRect.h
│ ├── cocos2d
│ ├── proj.android
│ ├── .classpath
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── org.eclipse.cdt.codan.core.prefs
│ │ ├── org.eclipse.cdt.core.prefs
│ │ └── org.eclipse.ltk.core.refactoring.prefs
│ ├── AndroidManifest.xml
│ ├── ant.properties
│ ├── build-cfg.json
│ ├── build.xml
│ ├── build_native.py
│ ├── jni
│ │ ├── Android.mk
│ │ ├── Application.mk
│ │ └── hellocpp
│ │ │ └── main.cpp
│ ├── proguard-project.txt
│ ├── res
│ │ ├── drawable-hdpi
│ │ │ └── icon.png
│ │ ├── drawable-ldpi
│ │ │ └── icon.png
│ │ ├── drawable-mdpi
│ │ │ └── icon.png
│ │ └── values
│ │ │ └── strings.xml
│ └── src
│ │ └── org
│ │ └── cocos2dx
│ │ └── cpp
│ │ └── AppActivity.java
│ ├── proj.ios_mac
│ ├── filters-cpp-demo.xcodeproj
│ │ └── project.pbxproj
│ ├── ios
│ │ ├── AppController.h
│ │ ├── AppController.mm
│ │ ├── Default-568h@2x.png
│ │ ├── Default-667h@2x.png
│ │ ├── Default-736h@3x.png
│ │ ├── Default.png
│ │ ├── Default@2x.png
│ │ ├── Icon-100.png
│ │ ├── Icon-114.png
│ │ ├── Icon-120.png
│ │ ├── Icon-144.png
│ │ ├── Icon-152.png
│ │ ├── Icon-29.png
│ │ ├── Icon-40.png
│ │ ├── Icon-50.png
│ │ ├── Icon-57.png
│ │ ├── Icon-58.png
│ │ ├── Icon-72.png
│ │ ├── Icon-76.png
│ │ ├── Icon-80.png
│ │ ├── Info.plist
│ │ ├── Prefix.pch
│ │ ├── RootViewController.h
│ │ ├── RootViewController.mm
│ │ └── main.m
│ └── mac
│ │ ├── Icon.icns
│ │ ├── Info.plist
│ │ ├── Prefix.pch
│ │ └── main.cpp
│ ├── proj.linux
│ └── main.cpp
│ ├── proj.win32
│ ├── build-cfg.json
│ ├── filters-cpp-demo.sln
│ ├── filters-cpp-demo.vcxproj
│ ├── filters-cpp-demo.vcxproj.filters
│ ├── game.rc
│ ├── main.cpp
│ ├── main.h
│ ├── res
│ │ └── game.ico
│ └── resource.h
│ ├── proj.win8.1-universal
│ ├── App.Shared
│ │ ├── App.xaml
│ │ ├── App.xaml.cpp
│ │ ├── App.xaml.h
│ │ ├── Cocos2dRenderer.cpp
│ │ ├── Cocos2dRenderer.h
│ │ ├── OpenGLES.cpp
│ │ ├── OpenGLES.h
│ │ ├── OpenGLESPage.xaml
│ │ ├── OpenGLESPage.xaml.cpp
│ │ ├── OpenGLESPage.xaml.h
│ │ ├── filters-cpp-demo.Shared.vcxitems
│ │ ├── filters-cpp-demo.Shared.vcxitems.filters
│ │ ├── pch.cpp
│ │ └── pch.h
│ ├── App.Windows
│ │ ├── Package.appxmanifest
│ │ ├── filters-cpp-demo.Windows.vcxproj
│ │ ├── filters-cpp-demo.Windows.vcxproj.filters
│ │ └── filters-cpp-demo.Windows_TemporaryKey.pfx
│ ├── App.WindowsPhone
│ │ ├── Package.appxmanifest
│ │ ├── filters-cpp-demo.WindowsPhone.vcxproj
│ │ └── filters-cpp-demo.WindowsPhone.vcxproj.filters
│ └── filters-cpp-demo.sln
│ └── proj.wp8-xaml
│ ├── App
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── EditBox.xaml
│ ├── EditBox.xaml.cs
│ ├── LocalizedStrings.cs
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── Properties
│ │ ├── AppManifest.xml
│ │ ├── AssemblyInfo.cs
│ │ └── WMAppManifest.xml
│ ├── Resources
│ │ ├── AppResources.Designer.cs
│ │ └── AppResources.resx
│ ├── SplashScreenImage.jpg
│ └── filters-cpp-demo.csproj
│ ├── AppComponent
│ ├── filters-cpp-demoComponent.vcxproj
│ ├── filters-cpp-demoComponent.vcxproj.filters
│ └── src
│ │ ├── Cocos2dRenderer.cpp
│ │ ├── Cocos2dRenderer.h
│ │ ├── Direct3DContentProvider.cpp
│ │ ├── Direct3DContentProvider.h
│ │ ├── Direct3DInterop.cpp
│ │ ├── Direct3DInterop.h
│ │ ├── DirectXBase.cpp
│ │ ├── DirectXBase.h
│ │ ├── DirectXHelper.h
│ │ ├── EditBoxEvent.cpp
│ │ ├── EditBoxEvent.h
│ │ ├── pch.cpp
│ │ └── pch.h
│ └── filters-cpp-demo.sln
└── filters
├── Android.mk
├── cocos2dFilters.h
├── filters
├── CCBlurFilter.cpp
├── CCBlurFilter.h
├── CCBrightnessFilter.cpp
├── CCBrightnessFilter.h
├── CCContrastFilter.cpp
├── CCContrastFilter.h
├── CCCustomFilter.cpp
├── CCCustomFilter.h
├── CCDropShadowFilter.cpp
├── CCDropShadowFilter.h
├── CCExposureFilter.cpp
├── CCExposureFilter.h
├── CCFilter.cpp
├── CCFilter.h
├── CCGammaFilter.cpp
├── CCGammaFilter.h
├── CCGrayFilter.cpp
├── CCGrayFilter.h
├── CCHazeFilter.cpp
├── CCHazeFilter.h
├── CCHueFilter.cpp
├── CCHueFilter.h
├── CCMaskFilter.cpp
├── CCMaskFilter.h
├── CCRGBFilter.cpp
├── CCRGBFilter.h
├── CCSaturationFilter.cpp
├── CCSaturationFilter.h
├── CCSepiaFilter.cpp
├── CCSepiaFilter.h
├── CCSharpenFilter.cpp
├── CCSharpenFilter.h
├── CCTestFilter.cpp
└── CCTestFilter.h
├── nodes
├── CCFilteredSprite.cpp
└── CCFilteredSprite.h
└── shaders
├── ccFilterShader_blur_frag.h
├── ccFilterShader_brightness_frag.h
├── ccFilterShader_colorramp_frag.h
├── ccFilterShader_contrast_frag.h
├── ccFilterShader_drop_shadow_frag.h
├── ccFilterShader_drop_shadow_vert.h
├── ccFilterShader_emboss_frag.h
├── ccFilterShader_embossmov_frag.h
├── ccFilterShader_exposure_frag.h
├── ccFilterShader_gamma_frag.h
├── ccFilterShader_gaussian_blur_frag.h
├── ccFilterShader_gaussian_hblur_frag.h
├── ccFilterShader_gaussian_vblur_frag.h
├── ccFilterShader_grass_frag.h
├── ccFilterShader_gray_frag.h
├── ccFilterShader_haze_frag.h
├── ccFilterShader_hblur_vert.h
├── ccFilterShader_hue_frag.h
├── ccFilterShader_motion_blur_frag.h
├── ccFilterShader_motion_blur_vert.h
├── ccFilterShader_rgb_frag.h
├── ccFilterShader_saturation_frag.h
├── ccFilterShader_sepia_frag.h
├── ccFilterShader_sharpen_frag.h
├── ccFilterShader_sharpen_vert.h
├── ccFilterShader_test_frag.h
├── ccFilterShader_test_vert.h
├── ccFilterShader_vblur_vert.h
├── ccFilterShader_zoom_blur_frag.h
├── ccFilterShaders.cpp
├── ccFilterShaders.h
├── example_Blur.fsh
├── example_ColorBars.fsh
├── example_ColorBars.vsh
├── example_Flower.fsh
├── example_Heart.fsh
├── example_HorizontalColor.fsh
├── example_Julia.fsh
├── example_Mandelbrot.fsh
├── example_Monjori.fsh
├── example_MultiTexture.fsh
├── example_MultiTexture.vsh
├── example_Noisy.fsh
├── example_Plasma.fsh
├── example_Twist.fsh
├── example_bloom.fsh
├── example_celShading.fsh
├── example_edgeDetection.fsh
├── example_greyScale.fsh
├── example_lensFlare.fsh
├── example_normal.fsh
├── example_outline.fsh
├── example_sepia.fsh
├── shadertoy_FireBall.fsh
├── shadertoy_Glow.fsh
└── shadertoy_LensFlare.fsh
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014, Jacky Tsang
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | list of conditions and the following disclaimer in the documentation and/or
12 | other materials provided with the distribution.
13 |
14 | * Neither the name of the {organization} nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | cocos2d-x-filters
2 | =================
3 |
4 | [Official site(Chinese)][6]
5 |
6 | A filter implement for cocos2d-x 2.x/3.x and quick-cocos2d-x 2.x.
7 |
8 | - [for quick-cocos2d-x 2.x][1]
9 | - [lua package for quick][4]
10 | - [A sample for quick][5]
11 | - [for cocos2d-x 2.x][2]
12 | - [for cocos2d-x 3.x][3]
13 |
14 | [1]: http://github.com/chukong/quick-cocos2d-x/tree/master/lib/cocos2d-x/extensions/filters
15 | [2]: https://github.com/zrong/cocos2d-x-filters/tree/v2.x
16 | [3]: https://github.com/zrong/cocos2d-x-filters/tree/v3.x
17 | [4]: https://github.com/chukong/quick-cocos2d-x/blob/master/framework/filter.lua
18 | [5]: https://github.com/chukong/quick-cocos2d-x/tree/master/samples/filters
19 | [6]: https://blog.zengrong.net/cocos2d-x-filters/
20 |
--------------------------------------------------------------------------------
/demos/Resources/res/CloseNormal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/CloseNormal.png
--------------------------------------------------------------------------------
/demos/Resources/res/CloseSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/CloseSelected.png
--------------------------------------------------------------------------------
/demos/Resources/res/HelloWorld2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/HelloWorld2.png
--------------------------------------------------------------------------------
/demos/Resources/res/HelloWorld3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/HelloWorld3.png
--------------------------------------------------------------------------------
/demos/Resources/res/b1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/b1.png
--------------------------------------------------------------------------------
/demos/Resources/res/b2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/b2.png
--------------------------------------------------------------------------------
/demos/Resources/res/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/bg.jpg
--------------------------------------------------------------------------------
/demos/Resources/res/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/close.png
--------------------------------------------------------------------------------
/demos/Resources/res/colorRamp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/colorRamp.png
--------------------------------------------------------------------------------
/demos/Resources/res/colors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/colors.png
--------------------------------------------------------------------------------
/demos/Resources/res/colors2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/colors2.png
--------------------------------------------------------------------------------
/demos/Resources/res/dirt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/dirt.png
--------------------------------------------------------------------------------
/demos/Resources/res/f1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/f1.png
--------------------------------------------------------------------------------
/demos/Resources/res/f2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/f2.png
--------------------------------------------------------------------------------
/demos/Resources/res/grass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/grass.png
--------------------------------------------------------------------------------
/demos/Resources/res/grass10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/grass10.png
--------------------------------------------------------------------------------
/demos/Resources/res/grass2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/grass2.png
--------------------------------------------------------------------------------
/demos/Resources/res/grass3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/grass3.png
--------------------------------------------------------------------------------
/demos/Resources/res/grass4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/grass4.png
--------------------------------------------------------------------------------
/demos/Resources/res/grass5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/grass5.png
--------------------------------------------------------------------------------
/demos/Resources/res/helloworld.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/helloworld.png
--------------------------------------------------------------------------------
/demos/Resources/res/helloworld1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/helloworld1.png
--------------------------------------------------------------------------------
/demos/Resources/res/mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/mask.png
--------------------------------------------------------------------------------
/demos/Resources/res/mask10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/mask10.png
--------------------------------------------------------------------------------
/demos/Resources/res/r1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/r1.png
--------------------------------------------------------------------------------
/demos/Resources/res/r2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/r2.png
--------------------------------------------------------------------------------
/demos/Resources/res/red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/red.png
--------------------------------------------------------------------------------
/demos/Resources/res/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/test.png
--------------------------------------------------------------------------------
/demos/Resources/res/test2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/test2.png
--------------------------------------------------------------------------------
/demos/Resources/res/test3.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | frames
6 |
7 | grass.png
8 |
9 | frame
10 | {{2,324},{600,234}}
11 | offset
12 | {0,-33}
13 | rotated
14 |
15 | sourceColorRect
16 | {{0,66},{600,234}}
17 | sourceSize
18 | {600,300}
19 |
20 | helloworld1.png
21 |
22 | frame
23 | {{2,2},{480,320}}
24 | offset
25 | {0,0}
26 | rotated
27 |
28 | sourceColorRect
29 | {{0,0},{480,320}}
30 | sourceSize
31 | {480,320}
32 |
33 |
34 | metadata
35 |
36 | format
37 | 2
38 | realTextureFileName
39 | test3.png
40 | size
41 | {512,1024}
42 | smartupdate
43 | $TexturePacker:SmartUpdate:f5865aa137b8da4fa68b9c3f013eee7e:69634f2cff914104ef8183865fc328d7:efbd392f8172d765a3057b8daf5d6c2f$
44 | textureFileName
45 | test3.png
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/demos/Resources/res/test3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/Resources/res/test3.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/.cocos-project.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_type": "cpp"
3 | }
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/Classes/AppDelegate.cpp:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "FilterSample.h"
3 |
4 | USING_NS_CC;
5 |
6 | AppDelegate::AppDelegate() {
7 |
8 | }
9 |
10 | AppDelegate::~AppDelegate()
11 | {
12 | }
13 |
14 | //if you want a different context,just modify the value of glContextAttrs
15 | //it will takes effect on all platforms
16 | void AppDelegate::initGLContextAttrs()
17 | {
18 | //set OpenGL context attributions,now can only set six attributions:
19 | //red,green,blue,alpha,depth,stencil
20 | GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
21 |
22 | GLView::setGLContextAttrs(glContextAttrs);
23 | }
24 |
25 | bool AppDelegate::applicationDidFinishLaunching() {
26 | // initialize director
27 | auto director = Director::getInstance();
28 | auto glview = director->getOpenGLView();
29 | if(!glview) {
30 | glview = GLViewImpl::create("Filters Sample");
31 | director->setOpenGLView(glview);
32 | }
33 |
34 | // turn on display FPS
35 | director->setDisplayStats(true);
36 |
37 | // set FPS. the default value is 1.0/60 if you don't call this
38 | director->setAnimationInterval(1.0 / 60);
39 |
40 | // create a scene. it's an autorelease object
41 | auto scene = FilterSample::scene();
42 |
43 | // run
44 | director->runWithScene(scene);
45 |
46 | return true;
47 | }
48 |
49 | // This function will be called when the app is inactive. When comes a phone call,it's be invoked too
50 | void AppDelegate::applicationDidEnterBackground() {
51 | Director::getInstance()->stopAnimation();
52 |
53 | // if you use SimpleAudioEngine, it must be pause
54 | // SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
55 | }
56 |
57 | // this function will be called when the app is active again
58 | void AppDelegate::applicationWillEnterForeground() {
59 | Director::getInstance()->startAnimation();
60 |
61 | // if you use SimpleAudioEngine, it must resume here
62 | // SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
63 | }
64 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/Classes/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #ifndef _APP_DELEGATE_H_
2 | #define _APP_DELEGATE_H_
3 |
4 | #include "cocos2d.h"
5 |
6 | /**
7 | @brief The cocos2d Application.
8 |
9 | The reason for implement as private inheritance is to hide some interface call by Director.
10 | */
11 | class AppDelegate : private cocos2d::Application
12 | {
13 | public:
14 | AppDelegate();
15 | virtual ~AppDelegate();
16 |
17 | virtual void initGLContextAttrs();
18 |
19 | /**
20 | @brief Implement Director and Scene init code here.
21 | @return true Initialize success, app continue.
22 | @return false Initialize failed, app terminate.
23 | */
24 | virtual bool applicationDidFinishLaunching();
25 |
26 | /**
27 | @brief The function be called when the application enter background
28 | @param the pointer of the application
29 | */
30 | virtual void applicationDidEnterBackground();
31 |
32 | /**
33 | @brief The function be called when the application enter foreground
34 | @param the pointer of the application
35 | */
36 | virtual void applicationWillEnterForeground();
37 | };
38 |
39 | #endif // _APP_DELEGATE_H_
40 |
41 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/Classes/FilterSample.h:
--------------------------------------------------------------------------------
1 | /**********************************************
2 | * Author: zrong(zengrong.net)
3 | * Creation: 2014-03-24
4 | * Last Modification: 2015-05-06
5 | **********************************************/
6 |
7 | #ifndef FILTER_SAMPLE_H
8 | #define FILTER_SAMPLE_H
9 |
10 | #include "cocos2d.h"
11 | #include "extensions/ExtensionMacros.h"
12 | #include "VisibleRect.h"
13 | #include "filters/cocos2dFilters.h"
14 |
15 | USING_NS_CC_EXT;
16 |
17 | typedef enum {
18 | LEFT_TOP,
19 | RIGHT_TOP,
20 | LEFT_BOTTOM,
21 | RIGHT_BOTTOM,
22 | CENTER,
23 | } ccLocation;
24 |
25 | class FilterSample : public cocos2d::Layer
26 | {
27 | public:
28 | static cocos2d::Scene* scene();
29 |
30 | FilterSample();
31 | ~FilterSample();
32 |
33 | // Here's a difference. Method 'init' in cocos2d-x returns bool,
34 | // instead of returning 'id' in cocos2d-iphone
35 | virtual bool init();
36 |
37 | // a selector callback
38 | void onClose(Ref* pSender);
39 |
40 | void onRestart(Ref* pSender);
41 | void onNext(Ref* pSender);
42 | void onBack(Ref* pSender);
43 | void onClearFilter(Ref* pSender);
44 |
45 | Sprite* getFilteredSprite(int index);
46 |
47 | CREATE_FUNC(FilterSample);
48 |
49 | virtual void update(float delta);
50 |
51 | private:
52 | Label* _nameLabel;
53 | Filters _filters;
54 | std::vector _filterNames;
55 | std::vector _multiFilters;
56 | std::vector _multiFilterNames;
57 | int _filtersNum = 0;
58 | Node* _pNode;
59 |
60 | void initFilters();
61 | void showFilteredDisplay(int index);
62 |
63 | Sprite* testFilter(Filter* filter, ccLocation location = CENTER,
64 | int order = 0, const char* path = "res/helloworld.png");
65 | Sprite* testFilter(Filters filters, ccLocation location = CENTER,
66 | int order = 0, const char* path = "res/helloworld.png");
67 | Sprite* testFilterFromFrame(Filter* filter, ccLocation location = CENTER,
68 | int order = 0, const char* path = "grass.png");
69 | Sprite* testFilterFromFrame(Filters filters, ccLocation location = CENTER,
70 | int order = 0, const char* path = "grass.png");
71 | Point getLocation(ccLocation location);
72 |
73 | private:
74 | GLProgram* getEmboss();
75 | cocos2d::GLProgram* getEmbossMov();
76 | cocos2d::GLProgram* getColorRamp();
77 | cocos2d::GLProgram* getGrass();
78 |
79 | int _timeUniformLocation;
80 | float _totalTime = 0.0f;
81 | };
82 |
83 | #endif // FILTER_SAMPLE_H
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/Classes/VisibleRect.h:
--------------------------------------------------------------------------------
1 | /**********************************************
2 | * author: zrong(zengrong.net)
3 | * Creation: 2014-03-24
4 | * Last Modification: 2015-05-06
5 | **********************************************/
6 |
7 | #ifndef VISIBLERECT_H
8 | #define VISIBLERECT_H
9 |
10 | #include "cocos2d.h"
11 |
12 | USING_NS_CC;
13 |
14 | class VisibleRect
15 | {
16 | public:
17 | static Rect getVisibleRect();
18 | static Size getWinSize();
19 |
20 | static Point left();
21 | static Point left(const float &ox, const float &oy);
22 | static Point right();
23 | static Point right(const float &ox, const float &oy);
24 | static Point top();
25 | static Point top(const float &ox, const float &oy);
26 | static Point bottom();
27 | static Point bottom(const float &ox, const float &oy);
28 | static Point center();
29 | static Point center(const float &ox, const float &oy);
30 | static Point leftTop();
31 | static Point leftTop(const float &ox, const float &oy);
32 | static Point rightTop();
33 | static Point rightTop(const float &ox, const float &oy);
34 | static Point leftBottom();
35 | static Point leftBottom(const float &ox, const float &oy);
36 | static Point rightBottom();
37 | static Point rightBottom(const float &ox, const float &oy);
38 | private:
39 | static void lazyInit();
40 | static Rect s_visibleRect;
41 | static Size _sSize;
42 | };
43 |
44 | #endif /* VISIBLERECT_H */
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/cocos2d:
--------------------------------------------------------------------------------
1 | /Volumes/HD1/cocos/cocos2d-x
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/.settings/org.eclipse.cdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | environment/project/0.1230402123/append=true
3 | environment/project/0.1230402123/appendContributed=true
4 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/.settings/org.eclipse.ltk.core.refactoring.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
3 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
13 |
14 |
15 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/ant.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked into Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # This file is only used by the Ant script.
7 |
8 | # You can use this to override default values such as
9 | # 'source.dir' for the location of your java source folder and
10 | # 'out.dir' for the location of your output folder.
11 |
12 | # You can also use it define how the release builds are signed by declaring
13 | # the following properties:
14 | # 'key.store' for the location of your keystore and
15 | # 'key.alias' for the name of the key to use.
16 | # The password will be asked during the build when you use the 'release' target.
17 |
18 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/build-cfg.json:
--------------------------------------------------------------------------------
1 | {
2 | "ndk_module_path" :[
3 | "../cocos2d",
4 | "../cocos2d/cocos",
5 | "../cocos2d/external"
6 | ],
7 | "copy_resources": [
8 | {
9 | "from": "../Resources",
10 | "to": ""
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 |
5 | $(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
6 | $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
7 | $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
8 |
9 | LOCAL_MODULE := cocos2dcpp_shared
10 |
11 | LOCAL_MODULE_FILENAME := libcocos2dcpp
12 |
13 | LOCAL_SRC_FILES := hellocpp/main.cpp \
14 | ../../Classes/AppDelegate.cpp \
15 | ../../Classes/HelloWorldScene.cpp
16 |
17 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
18 |
19 | # _COCOS_HEADER_ANDROID_BEGIN
20 | # _COCOS_HEADER_ANDROID_END
21 |
22 |
23 | LOCAL_STATIC_LIBRARIES := cocos2dx_static
24 |
25 | # _COCOS_LIB_ANDROID_BEGIN
26 | # _COCOS_LIB_ANDROID_END
27 |
28 | include $(BUILD_SHARED_LIBRARY)
29 |
30 | $(call import-module,.)
31 |
32 | # _COCOS_LIB_IMPORT_ANDROID_BEGIN
33 | # _COCOS_LIB_IMPORT_ANDROID_END
34 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_STL := gnustl_static
2 |
3 | APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
4 | APP_LDFLAGS := -latomic
5 |
6 |
7 | ifeq ($(NDK_DEBUG),1)
8 | APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
9 | APP_OPTIM := debug
10 | else
11 | APP_CPPFLAGS += -DNDEBUG
12 | APP_OPTIM := release
13 | endif
14 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/jni/hellocpp/main.cpp:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "cocos2d.h"
3 | #include "platform/android/jni/JniHelper.h"
4 | #include
5 | #include
6 |
7 | #define LOG_TAG "main"
8 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
9 |
10 | using namespace cocos2d;
11 |
12 | void cocos_android_app_init (JNIEnv* env, jobject thiz) {
13 | LOGD("cocos_android_app_init");
14 | AppDelegate *pAppDelegate = new AppDelegate();
15 | }
16 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.android/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.android/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.android/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | filters-cpp-demo
4 |
5 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.android/src/org/cocos2dx/cpp/AppActivity.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2008-2010 Ricardo Quesada
3 | Copyright (c) 2010-2012 cocos2d-x.org
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2013-2014 Chukong Technologies Inc.
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 | package org.cocos2dx.cpp;
28 |
29 | import org.cocos2dx.lib.Cocos2dxActivity;
30 |
31 | public class AppActivity extends Cocos2dxActivity {
32 | }
33 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/AppController.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @class RootViewController;
4 |
5 | @interface AppController : NSObject {
6 | UIWindow *window;
7 | }
8 |
9 | @property(nonatomic, readonly) RootViewController* viewController;
10 |
11 | @end
12 |
13 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Default-568h@2x.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Default-667h@2x.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Default-736h@3x.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Default.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Default@2x.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-100.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-114.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-120.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-144.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-152.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-29.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-40.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-50.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-57.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-58.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-72.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-76.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/ios/Icon-80.png
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'iphone' target in the 'iphone' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #import
8 | #endif
9 |
10 | #ifdef __cplusplus
11 | #include "cocos2d.h"
12 | #endif
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/RootViewController.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) 2013-2014 Chukong Technologies Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #import
27 |
28 |
29 | @interface RootViewController : UIViewController {
30 |
31 | }
32 | - (BOOL) prefersStatusBarHidden;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/ios/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | int main(int argc, char *argv[]) {
4 |
5 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
6 | int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
7 | [pool release];
8 | return retVal;
9 | }
10 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/mac/Icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.ios_mac/mac/Icon.icns
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/mac/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 | Icon
11 | CFBundleIdentifier
12 | org.zengrong.filters.cppdemo
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSApplicationCategoryType
26 | public.app-category.games
27 | LSMinimumSystemVersion
28 | ${MACOSX_DEPLOYMENT_TARGET}
29 | NSHumanReadableCopyright
30 | Copyright © 2013. All rights reserved.
31 | NSMainNibFile
32 | MainMenu
33 | NSPrincipalClass
34 | NSApplication
35 |
36 |
37 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/mac/Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
9 | #ifdef __cplusplus
10 | #include "cocos2d.h"
11 | #endif
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.ios_mac/mac/main.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010 cocos2d-x.org
3 |
4 | http://www.cocos2d-x.org
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 | ****************************************************************************/
24 |
25 | #include "AppDelegate.h"
26 | #include "cocos2d.h"
27 |
28 | USING_NS_CC;
29 |
30 | int main(int argc, char *argv[])
31 | {
32 | AppDelegate app;
33 | return Application::getInstance()->run();
34 | }
35 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.linux/main.cpp:
--------------------------------------------------------------------------------
1 | #include "../Classes/AppDelegate.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | USING_NS_CC;
9 |
10 | int main(int argc, char **argv)
11 | {
12 | // create the application instance
13 | AppDelegate app;
14 | return Application::getInstance()->run();
15 | }
16 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win32/build-cfg.json:
--------------------------------------------------------------------------------
1 | {
2 | "copy_resources": [
3 | {
4 | "from": "../Resources",
5 | "to": ""
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win32/filters-cpp-demo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filters-cpp-demo", "filters-cpp-demo.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}"
5 | ProjectSection(ProjectDependencies) = postProject
6 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
7 | EndProjectSection
8 | EndProject
9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos2d\cocos\2d\libcocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d", "..\cocos2d\external\Box2D\proj.win32\libbox2d.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}"
12 | EndProject
13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos2d\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}"
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Win32 = Debug|Win32
18 | Release|Win32 = Release|Win32
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32
22 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32
23 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32
24 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32
25 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32
26 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32
27 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32
28 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32
29 | {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32
30 | {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32
31 | {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32
32 | {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32
33 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.ActiveCfg = Debug|Win32
34 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.Build.0 = Debug|Win32
35 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.ActiveCfg = Release|Win32
36 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.Build.0 = Release|Win32
37 | EndGlobalSection
38 | GlobalSection(SolutionProperties) = preSolution
39 | HideSolutionNode = FALSE
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win32/filters-cpp-demo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {84a8ebd7-7cf0-47f6-b75e-d441df67da40}
6 |
7 |
8 | {715254bc-d70b-4ec5-bf29-467dd3ace079}
9 |
10 |
11 | {bb6c862e-70e9-49d9-81b7-3829a6f50471}
12 |
13 |
14 |
15 |
16 | win32
17 |
18 |
19 | src
20 |
21 |
22 | src
23 |
24 |
25 |
26 |
27 | win32
28 |
29 |
30 | src
31 |
32 |
33 | src
34 |
35 |
36 |
37 |
38 | resource
39 |
40 |
41 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win32/game.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #define APSTUDIO_HIDDEN_SYMBOLS
11 | #include "windows.h"
12 | #undef APSTUDIO_HIDDEN_SYMBOLS
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (U.S.) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | #ifdef _WIN32
21 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22 | #pragma code_page(1252)
23 | #endif //_WIN32
24 |
25 | #ifdef APSTUDIO_INVOKED
26 | /////////////////////////////////////////////////////////////////////////////
27 | //
28 | // TEXTINCLUDE
29 | //
30 |
31 | 1 TEXTINCLUDE
32 | BEGIN
33 | "resource.h\0"
34 | END
35 |
36 | #endif // APSTUDIO_INVOKED
37 |
38 | /////////////////////////////////////////////////////////////////////////////
39 | //
40 | // Icon
41 | //
42 |
43 | // Icon with lowest ID value placed first to ensure application icon
44 | // remains consistent on all systems.
45 | GLFW_ICON ICON "res\\game.ico"
46 |
47 | /////////////////////////////////////////////////////////////////////////////
48 | //
49 | // Version
50 | //
51 |
52 | VS_VERSION_INFO VERSIONINFO
53 | FILEVERSION 1,0,0,1
54 | PRODUCTVERSION 1,0,0,1
55 | FILEFLAGSMASK 0x3fL
56 | #ifdef _DEBUG
57 | FILEFLAGS 0x1L
58 | #else
59 | FILEFLAGS 0x0L
60 | #endif
61 | FILEOS 0x4L
62 | FILETYPE 0x2L
63 | FILESUBTYPE 0x0L
64 | BEGIN
65 | BLOCK "StringFileInfo"
66 | BEGIN
67 | BLOCK "040904B0"
68 | BEGIN
69 | VALUE "CompanyName", "\0"
70 | VALUE "FileDescription", "game Module\0"
71 | VALUE "FileVersion", "1, 0, 0, 1\0"
72 | VALUE "InternalName", "game\0"
73 | VALUE "LegalCopyright", "Copyright \0"
74 | VALUE "OriginalFilename", "game.exe\0"
75 | VALUE "ProductName", "game Module\0"
76 | VALUE "ProductVersion", "1, 0, 0, 1\0"
77 | END
78 | END
79 | BLOCK "VarFileInfo"
80 | BEGIN
81 | VALUE "Translation", 0x0409, 0x04B0
82 | END
83 | END
84 |
85 | /////////////////////////////////////////////////////////////////////////////
86 | #endif // !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
87 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win32/main.cpp:
--------------------------------------------------------------------------------
1 | #include "main.h"
2 | #include "AppDelegate.h"
3 | #include "cocos2d.h"
4 |
5 | USING_NS_CC;
6 |
7 | int APIENTRY _tWinMain(HINSTANCE hInstance,
8 | HINSTANCE hPrevInstance,
9 | LPTSTR lpCmdLine,
10 | int nCmdShow)
11 | {
12 | UNREFERENCED_PARAMETER(hPrevInstance);
13 | UNREFERENCED_PARAMETER(lpCmdLine);
14 |
15 | // create the application instance
16 | AppDelegate app;
17 | return Application::getInstance()->run();
18 | }
19 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win32/main.h:
--------------------------------------------------------------------------------
1 | #ifndef __MAIN_H__
2 | #define __MAIN_H__
3 |
4 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
5 |
6 | // Windows Header Files:
7 | #include
8 | #include
9 |
10 | // C RunTime Header Files
11 | #include "CCStdC.h"
12 |
13 | #endif // __MAIN_H__
14 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win32/res/game.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.win32/res/game.ico
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win32/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by game.RC
4 | //
5 |
6 | #define IDS_PROJNAME 100
7 | #define IDR_TESTJS 100
8 |
9 | #define ID_FILE_NEW_WINDOW 32771
10 |
11 | // Next default values for new objects
12 | //
13 | #ifdef APSTUDIO_INVOKED
14 | #ifndef APSTUDIO_READONLY_SYMBOLS
15 | #define _APS_NEXT_RESOURCE_VALUE 201
16 | #define _APS_NEXT_CONTROL_VALUE 1000
17 | #define _APS_NEXT_SYMED_VALUE 101
18 | #define _APS_NEXT_COMMAND_VALUE 32775
19 | #endif
20 | #endif
21 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 | cpp_tests
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/App.xaml.cpp:
--------------------------------------------------------------------------------
1 | #include "App.xaml.h"
2 | #include "OpenGLESPage.xaml.h"
3 |
4 | using namespace cocos2d;
5 |
6 | App::App()
7 | {
8 | InitializeComponent();
9 | }
10 |
11 | void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
12 | {
13 | if (mPage == nullptr)
14 | {
15 | mPage = ref new OpenGLESPage(&mOpenGLES);
16 | }
17 |
18 | // Place the page in the current window and ensure that it is active.
19 | Windows::UI::Xaml::Window::Current->Content = mPage;
20 | Windows::UI::Xaml::Window::Current->Activate();
21 | }
22 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/App.xaml.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "app.g.h"
4 | #include "OpenGLES.h"
5 | #include "openglespage.xaml.h"
6 |
7 | namespace cocos2d
8 | {
9 | ref class App sealed
10 | {
11 | public:
12 | App();
13 | virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override;
14 |
15 | private:
16 | OpenGLESPage^ mPage;
17 | OpenGLES mOpenGLES;
18 | };
19 | }
20 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/Cocos2dRenderer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cocos2d-x http://www.cocos2d-x.org
3 | *
4 | * Copyright (c) 2010-2014 - cocos2d-x community
5 | *
6 | * Portions Copyright (c) Microsoft Open Technologies, Inc.
7 | * All Rights Reserved
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and limitations under the License.
17 | */
18 | #pragma once
19 |
20 | #include
21 |
22 | #include "cocos2d.h"
23 |
24 |
25 | class AppDelegate;
26 |
27 | namespace cocos2d
28 | {
29 | class Cocos2dRenderer
30 | {
31 | public:
32 | Cocos2dRenderer(int width, int height, float dpi,
33 | Windows::Graphics::Display::DisplayOrientations orientation,
34 | Windows::UI::Core::CoreDispatcher^ dispathcer, Windows::UI::Xaml::Controls::Panel^ panel);
35 | ~Cocos2dRenderer();
36 | void Draw(GLsizei width, GLsizei height, float dpi, Windows::Graphics::Display::DisplayOrientations orientation);
37 | void QueuePointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
38 | void QueueKeyBoardEvent(Cocos2dKeyEvent type, Windows::UI::Core::KeyEventArgs^ e);
39 | void Pause();
40 | void Resume();
41 | void DeviceLost();
42 |
43 | private:
44 |
45 | int m_width;
46 | int m_height;
47 | float m_dpi;
48 |
49 | // The AppDelegate for the Cocos2D app
50 | AppDelegate* m_app;
51 | Platform::Agile m_dispatcher;
52 | Platform::Agile m_panel;
53 | Windows::Graphics::Display::DisplayOrientations m_orientation;
54 | };
55 | }
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/OpenGLES.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cocos2d-x http://www.cocos2d-x.org
3 | *
4 | * Copyright (c) 2010-2014 - cocos2d-x community
5 | *
6 | * Portions Copyright (c) Microsoft Open Technologies, Inc.
7 | * All Rights Reserved
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and limitations under the License.
17 | */
18 |
19 | #pragma once
20 |
21 | // OpenGL ES includes
22 | #include
23 | #include
24 |
25 | // EGL includes
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | class OpenGLES
32 | {
33 | public:
34 | OpenGLES();
35 | ~OpenGLES();
36 |
37 | EGLSurface CreateSurface(Windows::UI::Xaml::Controls::SwapChainPanel^ panel, const Windows::Foundation::Size* renderSurfaceSize);
38 | void DestroySurface(const EGLSurface surface);
39 | void MakeCurrent(const EGLSurface surface);
40 | EGLBoolean SwapBuffers(const EGLSurface surface);
41 | void Reset();
42 |
43 | private:
44 | void Initialize();
45 | void Cleanup();
46 |
47 | private:
48 | EGLDisplay mEglDisplay;
49 | EGLContext mEglContext;
50 | EGLConfig mEglConfig;
51 | };
52 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/filters-cpp-demo.Shared.vcxitems.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Classes
10 |
11 |
12 | Classes
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | {38ad799c-8c3c-44a2-8e41-516c8f62f556}
24 |
25 |
26 |
27 |
28 | Classes
29 |
30 |
31 | Classes
32 |
33 |
34 | Classes
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/pch.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Shared/pch.h:
--------------------------------------------------------------------------------
1 | //
2 | // pch.h
3 | // Header for standard system include files.
4 | //
5 |
6 | #pragma once
7 |
8 | #include
9 | #include
10 |
11 | #include "cocos2d.h"
12 | #include "cocos-ext.h"
13 |
14 |
15 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Windows/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | filters-cpp-demo.Windows
6 | dalestam
7 | Assets\StoreLogo.png
8 |
9 |
10 | 6.3.0
11 | 6.3.0
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Windows/filters-cpp-demo.Windows.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {1a9fa652-867e-41d2-8588-962f108d2d8f}
6 | bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Assets
18 |
19 |
20 | Assets
21 |
22 |
23 | Assets
24 |
25 |
26 | Assets
27 |
28 |
29 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.Windows/filters-cpp-demo.Windows_TemporaryKey.pfx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.win8.1-universal/App.Windows/filters-cpp-demo.Windows_TemporaryKey.pfx
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | filters-cpp-demo.WindowsPhone
7 | dalestam
8 | Assets\StoreLogo.png
9 |
10 |
11 | 6.3.1
12 | 6.3.1
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.win8.1-universal/App.WindowsPhone/filters-cpp-demo.WindowsPhone.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {c8beb60d-689b-4aaa-9749-99bd3e2dcf75}
6 | bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png
7 |
8 |
9 | Assets
10 |
11 |
12 | Assets
13 |
14 |
15 | Assets
16 |
17 |
18 | Assets
19 |
20 |
21 | Assets
22 |
23 |
24 | Assets
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/App/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/App/EditBox.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/App/LocalizedStrings.cs:
--------------------------------------------------------------------------------
1 | using cocos2d.Resources;
2 |
3 | namespace cocos2d
4 | {
5 | ///
6 | /// Provides access to string resources.
7 | ///
8 | public class LocalizedStrings
9 | {
10 | private static AppResources _localizedResources = new AppResources();
11 |
12 | public AppResources LocalizedResources { get { return _localizedResources; } }
13 | }
14 | }
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/App/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/App/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/App/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Resources;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("cocos2d")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("cocos2d")]
14 | [assembly: AssemblyCopyright("Copyright © 2012")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("e9152507-1b95-4fca-9d7f-444a024ccb98")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Revision and Build Numbers
34 | // by using the '*' as shown below:
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
38 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/App/Properties/WMAppManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Assets\ApplicationIcon.png
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Assets\Tiles\FlipCycleTileSmall.png
20 | 0
21 | Assets\Tiles\FlipCycleTileMedium.png
22 | filters-cpp-demo
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/App/SplashScreenImage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zrong/cocos2d-x-filters/9cc1b84ff5b6d3cd39e922e63775e1a462916858/demos/filters-cpp-demo/proj.wp8-xaml/App/SplashScreenImage.jpg
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/AppComponent/filters-cpp-demoComponent.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | src
6 |
7 |
8 | src
9 |
10 |
11 | src
12 |
13 |
14 | src
15 |
16 |
17 | src
18 |
19 |
20 | Classes
21 |
22 |
23 | Classes
24 |
25 |
26 | src
27 |
28 |
29 |
30 |
31 | src
32 |
33 |
34 | src
35 |
36 |
37 | src
38 |
39 |
40 | src
41 |
42 |
43 | src
44 |
45 |
46 | src
47 |
48 |
49 | Classes
50 |
51 |
52 | Classes
53 |
54 |
55 | src
56 |
57 |
58 |
59 |
60 | {ddb0f381-1dc4-44a0-ab28-0f672a551265}
61 |
62 |
63 | {6fcff44b-bb9f-4ed9-8553-558855bc91e3}
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/AppComponent/src/Direct3DContentProvider.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #include "Direct3DContentProvider.h"
27 | #include "Direct3DInterop.h"
28 |
29 | using namespace cocos2d;
30 |
31 | Direct3DContentProvider::Direct3DContentProvider(Direct3DInterop^ controller) :
32 | m_controller(controller)
33 | {
34 | m_controller->RequestAdditionalFrame += ref new RequestAdditionalFrameHandler([=] ()
35 | {
36 | if (m_host)
37 | {
38 | m_host->RequestAdditionalFrame();
39 | }
40 | });
41 | }
42 |
43 | // IDrawingSurfaceContentProviderNative interface
44 | HRESULT Direct3DContentProvider::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device)
45 | {
46 | m_host = host;
47 |
48 | return m_controller->Connect(host, device);
49 | }
50 |
51 | void Direct3DContentProvider::Disconnect()
52 | {
53 | m_controller->Disconnect();
54 | m_host = nullptr;
55 | }
56 |
57 | HRESULT Direct3DContentProvider::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Inout_ DrawingSurfaceSizeF* desiredRenderTargetSize)
58 | {
59 | return m_controller->PrepareResources(presentTargetTime, desiredRenderTargetSize);
60 | }
61 |
62 | HRESULT Direct3DContentProvider::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)
63 | {
64 | return m_controller->Draw(device, context, renderTargetView);
65 | }
66 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/AppComponent/src/Direct3DContentProvider.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | #include "Direct3DInterop.h"
33 |
34 | class Direct3DContentProvider : public Microsoft::WRL::RuntimeClass<
35 | Microsoft::WRL::RuntimeClassFlags,
36 | ABI::Windows::Phone::Graphics::Interop::IDrawingSurfaceBackgroundContentProvider,
37 | IDrawingSurfaceBackgroundContentProviderNative>
38 | {
39 | public:
40 | Direct3DContentProvider(cocos2d::Direct3DInterop^ controller);
41 |
42 | // IDrawingSurfaceContentProviderNative
43 | HRESULT STDMETHODCALLTYPE Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device);
44 | void STDMETHODCALLTYPE Disconnect();
45 |
46 | HRESULT STDMETHODCALLTYPE PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Inout_ DrawingSurfaceSizeF* desiredRenderTargetSize);
47 | HRESULT STDMETHODCALLTYPE Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView);
48 |
49 | private:
50 | cocos2d::Direct3DInterop^ m_controller;
51 | Microsoft::WRL::ComPtr m_host;
52 | };
53 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/AppComponent/src/DirectXHelper.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | //// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
27 | //// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
28 | //// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
29 | //// PARTICULAR PURPOSE.
30 | ////
31 | //// Copyright (c) Microsoft Corporation. All rights reserved
32 |
33 | #pragma once
34 |
35 |
36 | // This header defines helper utilities to make DirectX APIs work with exceptions.
37 | namespace DX
38 | {
39 | inline void ThrowIfFailed(HRESULT hr)
40 | {
41 | if (FAILED(hr))
42 | {
43 | // Set a breakpoint on this line to catch DX API errors.
44 | throw Platform::Exception::CreateException(hr);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/AppComponent/src/EditBoxEvent.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2014 cocos2d-x.org
3 |
4 | http://www.cocos2d-x.org
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 | ****************************************************************************/
24 |
25 | #include "EditBoxEvent.h"
26 |
27 | using namespace Platform;
28 |
29 | namespace cocos2d
30 | {
31 | EditBoxEvent::EditBoxEvent( Platform::Object^ sender, Platform::String^ arg, Windows::Foundation::EventHandler^ handle ):
32 | m_sender(sender),
33 | m_args(arg),
34 | m_handler(handle)
35 | {
36 |
37 | }
38 |
39 | void EditBoxEvent::execute()
40 | {
41 | if(m_handler.Get())
42 | {
43 | m_handler.Get()->Invoke(m_sender.Get(), m_args.Get());
44 | }
45 | }
46 |
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/AppComponent/src/EditBoxEvent.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2014 cocos2d-x.org
3 |
4 | http://www.cocos2d-x.org
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 | ****************************************************************************/
24 |
25 | #ifndef __EditBoxEVENT_H__
26 | #define __EditBoxEVENT_H__
27 |
28 | #include "InputEvent.h"
29 | #include
30 |
31 |
32 | namespace cocos2d
33 | {
34 | class EditBoxEvent : public cocos2d::InputEvent
35 | {
36 | public:
37 | EditBoxEvent(Platform::Object^ sender, Platform::String^ arg, Windows::Foundation::EventHandler^ handle);
38 |
39 | virtual void execute();
40 |
41 | private:
42 | Platform::Agile m_sender;
43 | Platform::Agile m_args;
44 | Platform::Agile^> m_handler;
45 | };
46 | }
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/AppComponent/src/pch.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 |
--------------------------------------------------------------------------------
/demos/filters-cpp-demo/proj.wp8-xaml/AppComponent/src/pch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "targetver.h"
4 |
5 | #ifndef WIN32_LEAN_AND_MEAN
6 | #define WIN32_LEAN_AND_MEAN
7 | #endif
8 |
9 | #include
10 | #include "cocos2d.h"
11 | #include "cocos-ext.h"
--------------------------------------------------------------------------------
/filters/Android.mk:
--------------------------------------------------------------------------------
1 |
2 | LOCAL_PATH := $(call my-dir)
3 | include $(CLEAR_VARS)
4 |
5 | LOCAL_MODULE := extra_filters_static
6 | LOCAL_MODULE_FILENAME := libextrafilters
7 |
8 |
9 | LOCAL_SRC_FILES := \
10 | $(LOCAL_PATH)/filters/CCBlurFilter.cpp \
11 | $(LOCAL_PATH)/filters/CCBrightnessFilter.cpp \
12 | $(LOCAL_PATH)/filters/CCContrastFilter.cpp \
13 | $(LOCAL_PATH)/filters/CCCustomFilter.cpp \
14 | $(LOCAL_PATH)/filters/CCDropShadowFilter.cpp \
15 | $(LOCAL_PATH)/filters/CCExposureFilter.cpp \
16 | $(LOCAL_PATH)/filters/CCFilter.cpp \
17 | $(LOCAL_PATH)/filters/CCGammaFilter.cpp \
18 | $(LOCAL_PATH)/filters/CCGrayFilter.cpp \
19 | $(LOCAL_PATH)/filters/CCHazeFilter.cpp \
20 | $(LOCAL_PATH)/filters/CCHueFilter.cpp \
21 | $(LOCAL_PATH)/filters/CCMaskFilter.cpp \
22 | $(LOCAL_PATH)/filters/CCRGBFilter.cpp \
23 | $(LOCAL_PATH)/filters/CCSaturationFilter.cpp \
24 | $(LOCAL_PATH)/filters/CCSepiaFilter.cpp \
25 | $(LOCAL_PATH)/filters/CCSharpenFilter.cpp \
26 | $(LOCAL_PATH)/filters/CCTestFilter.cpp \
27 | $(LOCAL_PATH)/nodes/CCFilteredSprite.cpp \
28 | $(LOCAL_PATH)/shaders/ccFilterShaders.cpp \
29 | $(LOCAL_PATH)/shaders/FilterShaders.cpp
30 |
31 |
32 | LOCAL_EXPORT_C_INCLUDES := \
33 | $(LOCAL_PATH) \
34 | $(LOCAL_PATH)/filters \
35 | $(LOCAL_PATH)/nodes \
36 | $(LOCAL_PATH)/shaders
37 |
38 |
39 | LOCAL_C_INCLUDES := \
40 | $(LOCAL_EXPORT_C_INCLUDES) \
41 | $(LOCAL_PATH)/../../../cocos2d-x/ \
42 | $(LOCAL_PATH)/../../../cocos2d-x/extensions \
43 | $(LOCAL_PATH)/../../../cocos2d-x/cocos \
44 | $(LOCAL_PATH)/../../../cocos2d-x/cocos/base \
45 | $(LOCAL_PATH)/../../../cocos2d-x/cocos/math \
46 | $(LOCAL_PATH)/../../../cocos2d-x/cocos/platform \
47 | $(LOCAL_PATH)/../../../cocos2d-x/cocos/platform/android \
48 | $(LOCAL_PATH)/../../../cocos2d-x/cocos/audio/include \
49 | $(LOCAL_PATH)/../../../cocos2d-x/cocos/scripting/lua-bindings/auto \
50 | $(LOCAL_PATH)/../../../cocos2d-x/cocos/scripting/lua-bindings/manual \
51 | $(LOCAL_PATH)/../../../cocos2d-x/external \
52 | $(LOCAL_PATH)/../../../cocos2d-x/external/lua/lua \
53 | $(LOCAL_PATH)/../../../cocos2d-x/external/lua/tolua \
54 | $(LOCAL_PATH)/../../../cocos2d-x/external/lua/quick \
55 | $(LOCAL_PATH)/../../../cocos2d-x/external/lua/luajit/include \
56 | $(LOCAL_PATH)/../../../cocos2d-x/external/chipmunk/include/chipmunk \
57 | $(LOCAL_PATH)/..
58 |
59 |
60 | LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API -DCC_LUA_ENGINE_ENABLED=1 $(ANDROID_COCOS2D_BUILD_FLAGS) -std=c++11
61 | #LOCAL_EXPORT_CFLAGS := -Wno-psabi -DUSE_FILE32API -DCC_LUA_ENGINE_ENABLED=1
62 |
63 | include $(BUILD_STATIC_LIBRARY)
--------------------------------------------------------------------------------
/filters/cocos2dFilters.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef __COCOS2D_FILTERS_H__
29 | #define __COCOS2D_FILTERS_H__
30 |
31 | // filters
32 | #include "filters/CCFilter.h"
33 | #include "filters/CCGrayFilter.h"
34 | #include "filters/CCBlurFilter.h"
35 | #include "filters/CCMaskFilter.h"
36 | #include "filters/CCSharpenFilter.h"
37 | #include "filters/CCRGBFilter.h"
38 | #include "filters/CCBrightnessFilter.h"
39 | #include "filters/CCExposureFilter.h"
40 | #include "filters/CCContrastFilter.h"
41 | #include "filters/CCDropShadowFilter.h"
42 | #include "filters/CCGammaFilter.h"
43 | #include "filters/CCHazeFilter.h"
44 | #include "filters/CCHueFilter.h"
45 | #include "filters/CCSaturationFilter.h"
46 | #include "filters/CCSepiaFilter.h"
47 | #include "filters/CCTestFilter.h"
48 | #include "filters/CCCustomFilter.h"
49 |
50 | // nodes
51 | #include "nodes/CCFilteredSprite.h"
52 |
53 | #endif //__COCOS2D_FILTERS_H__
--------------------------------------------------------------------------------
/filters/filters/CCBrightnessFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCBrightnessFilter.h"
2 | #include "filters/nodes/CCFilteredSprite.h"
3 |
4 | NS_CC_EXT_BEGIN
5 | //================== BrightnessFilter
6 |
7 | BrightnessFilter* BrightnessFilter::create()
8 | {
9 | BrightnessFilter* filter = new BrightnessFilter();
10 | filter->autorelease();
11 | return filter;
12 | }
13 |
14 | BrightnessFilter* BrightnessFilter::create(float brightness)
15 | {
16 | BrightnessFilter* filter = BrightnessFilter::create();
17 | filter->setParameter(brightness);
18 | return filter;
19 | }
20 |
21 | BrightnessFilter::BrightnessFilter()
22 | {
23 | this->shaderName = kCCFilterShader_brightness;
24 | _param = 0.f;
25 | }
26 |
27 | GLProgram* BrightnessFilter::loadShader()
28 | {
29 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_brightness_frag);
30 |
31 | // GLProgram* p = new GLProgram();
32 | // p->initWithByteArrays(ccPositionTexture_vert, ccFilterShader_brightness_frag);
33 | return p;
34 | }
35 |
36 | void BrightnessFilter::setParameter(float brightness)
37 | {
38 | _param = MIN(1.f, MAX(brightness, -1.f));
39 | initProgram();
40 | }
41 |
42 | void BrightnessFilter::setAttributes(GLProgram* cgp)
43 | {
44 | //CCLOG("CCRGBFilter::setAttributes");
45 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
46 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
47 | }
48 |
49 | void BrightnessFilter::setUniforms(GLProgram* cgp)
50 | {
51 | // int u_brightness = cgp->getUniformLocationForName("u_brightness");
52 | // cgp->setUniformLocationWith1f(u_brightness, _param);
53 |
54 | _pProgramState->setUniformFloat("u_brightness", _param);
55 | }
56 | NS_CC_EXT_END
--------------------------------------------------------------------------------
/filters/filters/CCBrightnessFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCBRIGHTNESS_FILTER
29 | #define CCBRIGHTNESS_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 | //================== BrightnessFilter
35 |
36 | class BrightnessFilter : public SingleFloatParamFilter
37 | {
38 |
39 | public:
40 | static BrightnessFilter* create();
41 | static BrightnessFilter* create(float brightness);
42 |
43 | BrightnessFilter();
44 |
45 | virtual void setParameter(float brightness);
46 | protected:
47 | virtual GLProgram* loadShader();
48 | virtual void setAttributes(GLProgram* glp);
49 | virtual void setUniforms(GLProgram* glp);
50 | };
51 |
52 | NS_CC_EXT_END
53 |
54 | #endif //CCBRIGHTNESS_FILTER
--------------------------------------------------------------------------------
/filters/filters/CCContrastFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCContrastFilter.h"
2 |
3 | NS_CC_EXT_BEGIN
4 | //================== ContrastFilter
5 |
6 | ContrastFilter* ContrastFilter::create()
7 | {
8 | ContrastFilter* filter = new ContrastFilter();
9 | filter->autorelease();
10 | return filter;
11 | }
12 |
13 | ContrastFilter* ContrastFilter::create(float brightness)
14 | {
15 | ContrastFilter* filter = ContrastFilter::create();
16 | filter->setParameter(brightness);
17 | return filter;
18 | }
19 |
20 | ContrastFilter::ContrastFilter()
21 | {
22 | this->shaderName = kCCFilterShader_contrast;
23 | _param = 1.f;
24 | }
25 |
26 | GLProgram* ContrastFilter::loadShader()
27 | {
28 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_contrast_frag);
29 |
30 | // GLProgram* p = new GLProgram();
31 | // p->initWithByteArrays(ccPositionTexture_vert, ccFilterShader_contrast_frag);
32 | return p;
33 | }
34 |
35 | void ContrastFilter::setParameter(float param)
36 | {
37 | _param = MIN(4.f, MAX(param, 0.f));
38 | initProgram();
39 | }
40 |
41 | void ContrastFilter::setAttributes(GLProgram* cgp)
42 | {
43 | //CCLOG("ContrastFilter::setAttributes");
44 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
45 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
46 | }
47 |
48 | void ContrastFilter::setUniforms(GLProgram* cgp)
49 | {
50 | // int u_contrast = cgp->getUniformLocationForName("u_contrast");
51 | // cgp->setUniformLocationWith1f(u_contrast, _param);
52 |
53 | _pProgramState->setUniformFloat("u_contrast", _param);
54 | }
55 |
56 | NS_CC_EXT_END
--------------------------------------------------------------------------------
/filters/filters/CCContrastFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCCONTRAST_FILTER
29 | #define CCCONTRAST_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== ContrastFilter
36 |
37 | class ContrastFilter : public SingleFloatParamFilter
38 | {
39 |
40 | public:
41 | static ContrastFilter* create();
42 | static ContrastFilter* create(float param);
43 |
44 | ContrastFilter();
45 |
46 | virtual void setParameter(float param);
47 | protected:
48 | virtual GLProgram* loadShader();
49 | virtual void setAttributes(GLProgram* glp);
50 | virtual void setUniforms(GLProgram* glp);
51 | };
52 |
53 | NS_CC_EXT_END
54 |
55 | #endif //CCCONTRAST_FILTER
--------------------------------------------------------------------------------
/filters/filters/CCCustomFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCCUSTOM_FILTER
29 | #define CCCUSTOM_FILTER
30 |
31 | #include "json/rapidjson.h"
32 | #include "json/document.h"
33 | #include "CCFilter.h"
34 |
35 | NS_CC_EXT_BEGIN
36 |
37 |
38 | //================== TestFilter
39 |
40 | class CustomFilter : public Filter
41 | {
42 |
43 | public:
44 | static CustomFilter* create();
45 | static CustomFilter* create(std::string paramsStr);
46 |
47 | CustomFilter();
48 |
49 | void setParameter(const char* paramsStr);
50 | protected:
51 | virtual GLProgram* loadShader();
52 | virtual void setUniforms(GLProgram* glp);
53 |
54 | std::string m_vertFile;
55 | std::string m_fragFile;
56 | rapidjson::Document m_json;
57 | };
58 |
59 | NS_CC_EXT_END
60 |
61 | #endif //CCCUSTOM_FILTER
62 |
--------------------------------------------------------------------------------
/filters/filters/CCDropShadowFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCDropShadowFilter.h"
2 | #include "filters/nodes/CCFilteredSprite.h"
3 |
4 | NS_CC_EXT_BEGIN
5 |
6 | //================== DropShadowFilter
7 |
8 | DropShadowFilter* DropShadowFilter::create()
9 | {
10 | DropShadowFilter* filter = new DropShadowFilter();
11 | filter->autorelease();
12 | return filter;
13 | }
14 |
15 | DropShadowFilter* DropShadowFilter::create(float resolation)
16 | {
17 | DropShadowFilter* filter = DropShadowFilter::create();
18 | filter->setParameter(resolation);
19 | return filter;
20 | }
21 |
22 | DropShadowFilter::DropShadowFilter()
23 | {
24 | this->shaderName = kCCFilterShader_drop_shadow;
25 | }
26 |
27 | GLProgram* DropShadowFilter::loadShader()
28 | {
29 | GLProgram* p = GLProgram::createWithByteArrays(ccFilterShader_drop_shadow_vert, ccFilterShader_drop_shadow_frag);
30 |
31 | // GLProgram* p = new GLProgram();
32 | // p->initWithByteArrays(ccFilterShader_drop_shadow_vert,
33 | // ccFilterShader_drop_shadow_frag);
34 | return p;
35 | }
36 |
37 | void DropShadowFilter::setParameter(float resolation)
38 | {
39 | //The initProgram() will perform in initSprite()
40 | }
41 |
42 | void DropShadowFilter::initSprite(FilteredSprite* sprite)
43 | {
44 | float aspectRatio = 1.0f;
45 | Size size = sprite->getContentSize();
46 | /*_textureWidth = size.width;
47 | _textureHeight = size.height;*/
48 | _textureWidth = 480;
49 | _textureHeight = 320;
50 | initProgram();
51 | }
52 |
53 | void DropShadowFilter::setAttributes(GLProgram* cgp)
54 | {
55 | //CCLOG("DropShadowFilter::setAttributes");
56 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
57 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
58 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
59 | }
60 |
61 | void DropShadowFilter::setUniforms(GLProgram* cgp)
62 | {
63 | // int u_resolution = cgp->getUniformLocationForName("u_resolution");
64 | // cgp->setUniformLocationWith2f(u_resolution, _textureWidth, _textureHeight);
65 |
66 | _pProgramState->setUniformVec2("u_resolution", Vec2(_textureWidth, _textureHeight));
67 | }
68 |
69 | NS_CC_EXT_END
70 |
--------------------------------------------------------------------------------
/filters/filters/CCDropShadowFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCDROP_SHADOW_FILTER
29 | #define CCDROP_SHADOW_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== DropShadowFilter
36 |
37 | class DropShadowFilter : public Filter
38 | {
39 |
40 | public:
41 | static DropShadowFilter* create();
42 | static DropShadowFilter* create(float resolation);
43 |
44 | DropShadowFilter();
45 |
46 | void setParameter(float resolation);
47 | virtual void initSprite(FilteredSprite* sprite);
48 | protected:
49 | virtual GLProgram* loadShader();
50 | virtual void setAttributes(GLProgram* glp);
51 | virtual void setUniforms(GLProgram* glp);
52 | float _textureWidth;
53 | float _textureHeight;
54 | };
55 |
56 |
57 | NS_CC_EXT_END
58 |
59 | #endif //CCDROP_SHADOW_FILTER
60 |
--------------------------------------------------------------------------------
/filters/filters/CCExposureFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCExposureFilter.h"
2 |
3 | NS_CC_EXT_BEGIN
4 |
5 | //================== ExposureFilter
6 |
7 | ExposureFilter* ExposureFilter::create()
8 | {
9 | ExposureFilter* filter = new ExposureFilter();
10 | filter->autorelease();
11 | return filter;
12 | }
13 |
14 | ExposureFilter* ExposureFilter::create(float brightness)
15 | {
16 | ExposureFilter* filter = ExposureFilter::create();
17 | filter->setParameter(brightness);
18 | return filter;
19 | }
20 |
21 | ExposureFilter::ExposureFilter()
22 | {
23 | this->shaderName = kCCFilterShader_exposure;
24 | _param = 0.f;
25 | }
26 |
27 | GLProgram* ExposureFilter::loadShader()
28 | {
29 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_exposure_frag);
30 |
31 | // GLProgram* p = new GLProgram();
32 | // p->initWithByteArrays(ccPositionTexture_vert, ccFilterShader_exposure_frag);
33 | return p;
34 | }
35 |
36 | void ExposureFilter::setParameter(float param)
37 | {
38 | _param = MIN(10.f, MAX(param, -10.f));
39 | initProgram();
40 | }
41 |
42 | void ExposureFilter::setAttributes(GLProgram* cgp)
43 | {
44 | //CCLOG("ExposureFilter::setAttributes");
45 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
46 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
47 | }
48 |
49 | void ExposureFilter::setUniforms(GLProgram* cgp)
50 | {
51 | // int param = cgp->getUniformLocationForName("u_exposure");
52 | // cgp->setUniformLocationWith1f(param, _param);
53 |
54 | _pProgramState->setUniformFloat("u_exposure", _param);
55 | }
56 |
57 | NS_CC_EXT_END
--------------------------------------------------------------------------------
/filters/filters/CCExposureFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCEXPOSURE_FILTER
29 | #define CCEXPOSURE_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== ExposureFilter
36 |
37 | class ExposureFilter : public SingleFloatParamFilter
38 | {
39 |
40 | public:
41 | static ExposureFilter* create();
42 | static ExposureFilter* create(float param);
43 |
44 | ExposureFilter();
45 |
46 | virtual void setParameter(float param);
47 | protected:
48 | virtual GLProgram* loadShader();
49 | virtual void setAttributes(GLProgram* glp);
50 | virtual void setUniforms(GLProgram* glp);
51 | };
52 |
53 | NS_CC_EXT_END
54 |
55 | #endif //CCEXPOSURE_FILTER
--------------------------------------------------------------------------------
/filters/filters/CCFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCFilter.h"
2 | #include "filters/nodes/CCFilteredSprite.h"
3 |
4 | NS_CC_EXT_BEGIN
5 |
6 | //================== Filter
7 |
8 | Filter::Filter()
9 | : shaderName(NULL)
10 | , _pProgramState(NULL)
11 | {
12 | }
13 |
14 | Filter::~Filter()
15 | {
16 | CC_SAFE_RELEASE_NULL(_pProgramState);
17 | }
18 |
19 | GLProgram* Filter::getProgram()
20 | {
21 | return _pProgramState->getGLProgram();
22 | }
23 |
24 | GLProgramState* Filter::getGLProgramState() {
25 | return _pProgramState;
26 | }
27 |
28 | void Filter::initProgram()
29 | {
30 | if (nullptr != _pProgramState) {
31 | return;
32 | }
33 |
34 | GLProgram* pProgram = nullptr;
35 | if (nullptr != shaderName) {
36 | pProgram = GLProgramCache::getInstance()->getGLProgram(shaderName);
37 | }
38 | //CCLOG("CCFilter::initProgram %s, program:%d", shaderName, pProgram);
39 | if (nullptr == pProgram)
40 | {
41 | pProgram = loadShader();
42 |
43 | if (nullptr != shaderName) {
44 | GLProgramCache::getInstance()->addGLProgram(pProgram, this->shaderName);
45 | }
46 | }
47 |
48 | _pProgramState = GLProgramState::getOrCreateWithGLProgram(pProgram);
49 | _pProgramState->retain();
50 | }
51 |
52 | void Filter::initSprite(FilteredSprite* sprite)
53 | {
54 | setUniforms(nullptr);
55 | }
56 |
57 | void Filter::draw()
58 | {
59 | //setUniforms(getProgram());
60 | }
61 |
62 | GLProgram* Filter::loadShader()
63 | {
64 | //CCLOG("Filter::loadShader");
65 | return nullptr;
66 | }
67 |
68 | void Filter::setAttributes(GLProgram* glp)
69 | {
70 | }
71 |
72 | void Filter::setUniforms(GLProgram* glp)
73 | {
74 | }
75 |
76 | //================== SingleFloatParamFilter
77 |
78 | SingleFloatParamFilter::SingleFloatParamFilter()
79 | : _param(0.f)
80 | {
81 | }
82 |
83 |
84 | void SingleFloatParamFilter::setParameter(float param)
85 | {
86 | _param = param;
87 | initProgram();
88 | }
89 |
90 | NS_CC_EXT_END
--------------------------------------------------------------------------------
/filters/filters/CCFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCSHADER_FILTER_H
29 | #define CCSHADER_FILTER_H
30 |
31 | #include "cocos2d.h"
32 | #include "extensions/ExtensionMacros.h"
33 | #include "platform/CCGL.h"
34 | #include "filters/shaders/ccFilterShaders.h"
35 |
36 | USING_NS_CC;
37 |
38 | NS_CC_EXT_BEGIN
39 |
40 | class FilteredSprite;
41 |
42 | //================== Filter
43 |
44 | class Filter : public Ref
45 | {
46 | public:
47 | Filter();
48 | ~Filter();
49 |
50 | virtual void initSprite(FilteredSprite* sprite);
51 | virtual void draw();
52 | GLProgram* getProgram();
53 | GLProgramState* getGLProgramState();
54 |
55 | const char* shaderName;
56 | protected:
57 | GLProgramState* _pProgramState;
58 | void initProgram();
59 | virtual GLProgram* loadShader();
60 | virtual void setAttributes(GLProgram* glp);
61 | virtual void setUniforms(GLProgram* glp);
62 | };
63 |
64 | class SingleFloatParamFilter : public Filter
65 | {
66 | public:
67 | SingleFloatParamFilter();
68 |
69 | virtual void setParameter(float param);
70 | protected:
71 | float _param;
72 | };
73 |
74 | typedef Vector Filters;
75 |
76 | NS_CC_EXT_END
77 |
78 | #endif /* CCSHADER_FILTER_H */
79 |
--------------------------------------------------------------------------------
/filters/filters/CCGammaFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCGammaFilter.h"
2 |
3 | NS_CC_EXT_BEGIN
4 |
5 | //================== GammaFilter
6 |
7 | GammaFilter* GammaFilter::create()
8 | {
9 | GammaFilter* filter = new GammaFilter();
10 | filter->autorelease();
11 | return filter;
12 | }
13 |
14 | GammaFilter* GammaFilter::create(float brightness)
15 | {
16 | GammaFilter* filter = GammaFilter::create();
17 | filter->setParameter(brightness);
18 | return filter;
19 | }
20 |
21 | GammaFilter::GammaFilter()
22 | {
23 | this->shaderName = kCCFilterShader_gamma;
24 | _param = 1.f;
25 | }
26 |
27 | GLProgram* GammaFilter::loadShader()
28 | {
29 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_gamma_frag);
30 |
31 | // GLProgram* p = new GLProgram();
32 | // p->initWithByteArrays(ccPositionTexture_vert, ccFilterShader_gamma_frag);
33 | return p;
34 | }
35 |
36 | void GammaFilter::setParameter(float param)
37 | {
38 | _param = MIN(3.f, MAX(param, 0.f));
39 | initProgram();
40 | }
41 |
42 | void GammaFilter::setAttributes(GLProgram* cgp)
43 | {
44 | //CCLOG("GammaFilter::setAttributes");
45 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
46 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
47 | }
48 |
49 | void GammaFilter::setUniforms(GLProgram* cgp)
50 | {
51 | // int param = cgp->getUniformLocationForName("u_gamma");
52 | // cgp->setUniformLocationWith1f(param, _param);
53 |
54 | _pProgramState->setUniformFloat("u_gamma", _param);
55 | }
56 |
57 | NS_CC_EXT_END
58 |
--------------------------------------------------------------------------------
/filters/filters/CCGammaFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCGAMMA_FILTER
29 | #define CCGAMMA_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== GammaFilter
36 |
37 | class GammaFilter : public SingleFloatParamFilter
38 | {
39 |
40 | public:
41 | static GammaFilter* create();
42 | static GammaFilter* create(float param);
43 |
44 | GammaFilter();
45 |
46 | virtual void setParameter(float param);
47 | protected:
48 | virtual GLProgram* loadShader();
49 | virtual void setAttributes(GLProgram* glp);
50 | virtual void setUniforms(GLProgram* glp);
51 |
52 | };
53 |
54 | NS_CC_EXT_END
55 |
56 | #endif //CCGAMMA_FILTER
57 |
--------------------------------------------------------------------------------
/filters/filters/CCGrayFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCGrayFilter.h"
2 |
3 | NS_CC_EXT_BEGIN
4 |
5 | //================== GrayFilter
6 |
7 | GrayFilter* GrayFilter::create()
8 | {
9 | GrayFilter* filter = new GrayFilter();
10 | filter->autorelease();
11 | filter->initProgram();
12 | return filter;
13 | }
14 |
15 | GrayFilter* GrayFilter::create(Color4F param)
16 | {
17 | GrayFilter* filter = GrayFilter::create();
18 | filter->setParameter(param);
19 | return filter;
20 | }
21 |
22 | GrayFilter* GrayFilter::create(float r, float g, float b, float a)
23 | {
24 | GrayFilter* filter = GrayFilter::create();
25 | filter->setParameter(r, a, b, a);
26 | return filter;
27 | }
28 |
29 |
30 | GrayFilter::GrayFilter()
31 | : _param(Color4F(0.299f, 0.587f, 0.114f, 0.0f))
32 | {
33 | this->shaderName = kCCFilterShader_gray;
34 | }
35 |
36 | void GrayFilter::setParameter(Color4F param)
37 | {
38 | _param = param;
39 | initProgram();
40 | }
41 |
42 | void GrayFilter::setParameter(float r, float g, float b, float a)
43 | {
44 | setParameter(Color4F(r, g, b, a));
45 | }
46 |
47 | GLProgram* GrayFilter::loadShader()
48 | {
49 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_gray_frag);
50 | // GLProgram* p = new GLProgram();
51 | // p->initWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_gray_frag);
52 | return p;
53 | }
54 |
55 | void GrayFilter::setAttributes(GLProgram* cgp)
56 | {
57 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
58 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
59 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
60 | }
61 |
62 | void GrayFilter::setUniforms(GLProgram* cgp)
63 | {
64 | //int grayParam = cgp->getUniformLocationForName("u_grayParam");
65 | //CCLOG("GrayFilter::setUniforms, u_grayParam:%d", grayParam);
66 | //cgp->setUniformLocationWith4f(grayParam, _param.r, _param.g, _param.b, _param.a);
67 | _pProgramState->setUniformVec4("u_grayParam", Vec4(_param.r, _param.g, _param.b, _param.a));
68 | }
69 |
70 | NS_CC_EXT_END
--------------------------------------------------------------------------------
/filters/filters/CCGrayFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCFILTER_GRAY_H
29 | #define CCFILTER_GRAY_H
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== GrayFilter
36 |
37 | class GrayFilter : public Filter
38 | {
39 | public:
40 | static GrayFilter* create();
41 | static GrayFilter* create(Color4F param);
42 | static GrayFilter* create(float r, float g, float b, float a=0.f);
43 |
44 | GrayFilter();
45 | void setParameter(Color4F param);
46 | void setParameter(float r, float g, float b, float a=0.f);
47 |
48 | protected:
49 | virtual GLProgram* loadShader();
50 | virtual void setAttributes(GLProgram* glp);
51 | virtual void setUniforms(GLProgram* glp);
52 |
53 | private:
54 | Color4F _param;
55 | };
56 |
57 | NS_CC_EXT_END
58 |
59 | #endif //CCFILTER_GRAY_H
--------------------------------------------------------------------------------
/filters/filters/CCHazeFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCHazeFilter.h"
2 |
3 | NS_CC_EXT_BEGIN
4 |
5 | //================== HazeFilter
6 |
7 | HazeFilter* HazeFilter::create()
8 | {
9 | HazeFilter* filter = new HazeFilter();
10 | filter->autorelease();
11 | return filter;
12 | }
13 |
14 | HazeFilter* HazeFilter::create(float hazeDistance, float slope)
15 | {
16 | HazeFilter* filter = HazeFilter::create();
17 | filter->setParameter(hazeDistance, slope);
18 | return filter;
19 | }
20 |
21 | HazeFilter::HazeFilter()
22 | : _hazeDistance(0.f)
23 | , _slope(0.f)
24 | {
25 | this->shaderName = kCCFilterShader_haze;
26 | }
27 |
28 | GLProgram* HazeFilter::loadShader()
29 | {
30 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_haze_frag);
31 |
32 | // GLProgram* p = new GLProgram();
33 | // p->initWithByteArrays(ccPositionTexture_vert, ccFilterShader_haze_frag);
34 | return p;
35 | }
36 |
37 | void HazeFilter::setParameter(float hazeDistance, float slope)
38 | {
39 | _hazeDistance = MIN(0.5f, MAX(hazeDistance, -0.5f));
40 | _slope = MIN(0.5f, MAX(slope, -0.5f));
41 | initProgram();
42 | }
43 |
44 | void HazeFilter::setAttributes(GLProgram* cgp)
45 | {
46 | //CCLOG("HazeFilter::setAttributes");
47 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
48 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
49 | }
50 |
51 | void HazeFilter::setUniforms(GLProgram* cgp)
52 | {
53 | // int hazeDistance = cgp->getUniformLocationForName("u_hazeDistance");
54 | // int slope = cgp->getUniformLocationForName("u_slope");
55 | // cgp->setUniformLocationWith1f(hazeDistance, _hazeDistance);
56 | // cgp->setUniformLocationWith1f(slope, _slope);
57 |
58 | _pProgramState->setUniformFloat("u_hazeDistance", _hazeDistance);
59 | _pProgramState->setUniformFloat("u_slope", _slope);
60 | }
61 | NS_CC_EXT_END
62 |
--------------------------------------------------------------------------------
/filters/filters/CCHazeFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCHAZE_FILTER
29 | #define CCHAZE_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== HazeFilter
36 |
37 | class HazeFilter : public Filter
38 | {
39 |
40 | public:
41 | static HazeFilter* create();
42 | static HazeFilter* create(float hazeDistance, float slope);
43 |
44 | HazeFilter();
45 |
46 | void setParameter(float hazeDistance, float slope);
47 | protected:
48 | virtual GLProgram* loadShader();
49 | virtual void setAttributes(GLProgram* glp);
50 | virtual void setUniforms(GLProgram* glp);
51 | float _hazeDistance;
52 | float _slope;
53 | };
54 |
55 | NS_CC_EXT_END
56 |
57 | #endif //CCHAZE_FILTER
58 |
--------------------------------------------------------------------------------
/filters/filters/CCHueFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCHueFilter.h"
2 | #include "filters/nodes/CCFilteredSprite.h"
3 |
4 | NS_CC_EXT_BEGIN
5 |
6 | //================== HueFilter
7 |
8 | HueFilter* HueFilter::create()
9 | {
10 | HueFilter* filter = new HueFilter();
11 | filter->autorelease();
12 | return filter;
13 | }
14 |
15 | HueFilter* HueFilter::create(float brightness)
16 | {
17 | HueFilter* filter = HueFilter::create();
18 | filter->setParameter(brightness);
19 | return filter;
20 | }
21 |
22 | HueFilter::HueFilter()
23 | {
24 | this->shaderName = kCCFilterShader_hue;
25 | _param = 0.f;
26 | }
27 |
28 | GLProgram* HueFilter::loadShader()
29 | {
30 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_hue_frag);
31 |
32 | // GLProgram* p = new GLProgram();
33 | // p->initWithByteArrays(ccPositionTexture_vert, ccFilterShader_hue_frag);
34 | return p;
35 | }
36 |
37 | void HueFilter::setParameter(float param)
38 | {
39 | _param = fmodf(param, 360.f)*M_PI / 180;
40 | initProgram();
41 | }
42 |
43 | void HueFilter::setAttributes(GLProgram* cgp)
44 | {
45 | //CCLOG("HueFilter::setAttributes");
46 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
47 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
48 | }
49 |
50 | void HueFilter::setUniforms(GLProgram* cgp)
51 | {
52 | // int u_hueAdjust = cgp->getUniformLocationForName("u_hueAdjust");
53 | // cgp->setUniformLocationWith1f(u_hueAdjust, _param);
54 |
55 | _pProgramState->setUniformFloat("u_hueAdjust", _param);
56 | }
57 |
58 | NS_CC_EXT_END
59 |
--------------------------------------------------------------------------------
/filters/filters/CCHueFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCHUE_FILTER
29 | #define CCHUE_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 |
36 | //================== HueFilter
37 |
38 | class HueFilter : public SingleFloatParamFilter
39 | {
40 |
41 | public:
42 | static HueFilter* create();
43 | static HueFilter* create(float param);
44 |
45 | HueFilter();
46 |
47 | void setParameter(float param);
48 | protected:
49 | virtual GLProgram* loadShader();
50 | virtual void setAttributes(GLProgram* glp);
51 | virtual void setUniforms(GLProgram* glp);
52 | };
53 |
54 | NS_CC_EXT_END
55 |
56 | #endif //CCHUE_FILTER
57 |
--------------------------------------------------------------------------------
/filters/filters/CCMaskFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCMaskFilter.h"
2 | #include "filters/nodes/CCFilteredSprite.h"
3 |
4 | NS_CC_EXT_BEGIN
5 |
6 | //================== MaskFilter
7 |
8 | MaskFilter* MaskFilter::create()
9 | {
10 | MaskFilter* filter = new MaskFilter();
11 | filter->autorelease();
12 | return filter;
13 | }
14 |
15 | MaskFilter* MaskFilter::create(std::string* maskImage)
16 | {
17 | MaskFilter* filter = MaskFilter::create();
18 | filter->setParameter(maskImage);
19 | filter->setIsSpriteFrame(false);
20 | return filter;
21 | }
22 |
23 | MaskFilter* MaskFilter::createWithSpriteFrameName(std::string* maskImage)
24 | {
25 | MaskFilter* filter = MaskFilter::create();
26 | filter->setParameter(maskImage);
27 | filter->setIsSpriteFrame(true);
28 | return filter;
29 | }
30 |
31 | MaskFilter::MaskFilter()
32 | : _param(NULL)
33 | , _isSpriteFrame(false)
34 | {
35 | this->shaderName = NULL;
36 | }
37 |
38 | void MaskFilter::initProgram()
39 | {
40 | //Do nothing in MaskFilter
41 | //CCLOG("MaskFilter initProgram");
42 | }
43 |
44 | void MaskFilter::initSprite(FilteredSprite* sprite)
45 | {
46 | //CCLOG("MaskFilter initSprite maskImage:%s", _param->c_str());
47 | BlendFunc maskBF = { GL_ONE, GL_ZERO };
48 | BlendFunc imgBF = { GL_DST_ALPHA, GL_ZERO };
49 |
50 | Sprite* pMask = _isSpriteFrame ?
51 | Sprite::create(_param->c_str()):
52 | Sprite::createWithSpriteFrameName(_param->c_str());
53 | pMask->setAnchorPoint(Vec2(0, 0));
54 | pMask->setPosition(Vec2(0, 0));
55 |
56 | Sprite* pImg = Sprite::createWithSpriteFrameName("helloworld.png");
57 | pImg->setAnchorPoint(Vec2(0, 0));
58 | pImg->setPosition(Vec2(0, 0));
59 |
60 | pMask->setBlendFunc(maskBF);
61 | pImg->setBlendFunc(imgBF);
62 |
63 | Size size = pImg->getContentSize();
64 | RenderTexture* pRender = RenderTexture::create(size.width, size.height);
65 | pRender->begin();
66 | pMask->visit();
67 | pImg->visit();
68 | pRender->end();
69 |
70 | Texture2D* pTex = new Texture2D();
71 | pTex->initWithImage(pRender->newImage(true));
72 | pTex->autorelease();
73 | sprite->setTexture(pTex);
74 | }
75 |
76 | void MaskFilter::setParameter(std::string* maskImage)
77 | {
78 | _param = maskImage;
79 | }
80 |
81 | NS_CC_EXT_END
--------------------------------------------------------------------------------
/filters/filters/CCMaskFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCMASK_FILTER
29 | #define CCMASK_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== MaskFilter
36 |
37 | class MaskFilter : public Filter
38 | {
39 |
40 | public:
41 | static MaskFilter* create();
42 | static MaskFilter* create(std::string* maskImage);
43 | static MaskFilter* createWithSpriteFrameName(std::string* maskImage);
44 |
45 | MaskFilter();
46 |
47 | void setParameter(std::string* param);
48 | virtual void initSprite(FilteredSprite* sprite);
49 | inline void setIsSpriteFrame(bool isSpriteFrame){ _isSpriteFrame = isSpriteFrame; };
50 | protected:
51 | void initProgram();
52 | std::string* _param;
53 | bool _isSpriteFrame;
54 |
55 | };
56 |
57 | NS_CC_EXT_END
58 |
59 | #endif //CCMASK_FILTER
--------------------------------------------------------------------------------
/filters/filters/CCRGBFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCRGBFilter.h"
2 | #include "filters/nodes/CCFilteredSprite.h"
3 |
4 | NS_CC_EXT_BEGIN
5 |
6 | //================== RGBFilter
7 |
8 | RGBFilter* RGBFilter::create()
9 | {
10 | RGBFilter* filter = new RGBFilter();
11 | filter->autorelease();
12 | return filter;
13 | }
14 |
15 | RGBFilter* RGBFilter::create(float readAdj, float greenAdj, float blueAdj)
16 | {
17 | RGBFilter* filter = RGBFilter::create();
18 | filter->setParameter(readAdj, greenAdj, blueAdj);
19 | return filter;
20 | }
21 |
22 | RGBFilter::RGBFilter()
23 | : _redAdj(1.f)
24 | , _greenAdj(1.f)
25 | , _blueAdj(1.f)
26 | {
27 | this->shaderName = kCCFilterShader_rgb;
28 | }
29 |
30 | GLProgram* RGBFilter::loadShader()
31 | {
32 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_rgb_frag);
33 |
34 | // GLProgram* p = new GLProgram();
35 | // p->initWithByteArrays(ccPositionTexture_vert, ccFilterShader_rgb_frag);
36 | return p;
37 | }
38 |
39 | void RGBFilter::setParameter(float redAdj, float greenAdj, float blueAdj)
40 | {
41 | _redAdj = redAdj;
42 | _greenAdj = greenAdj;
43 | _blueAdj = blueAdj;
44 | initProgram();
45 | }
46 |
47 | void RGBFilter::setAttributes(GLProgram* cgp)
48 | {
49 | //CCLOG("RGBFilter::setAttributes");
50 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
51 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
52 | }
53 |
54 | void RGBFilter::setUniforms(GLProgram* cgp)
55 | {
56 | // int redAdj = cgp->getUniformLocationForName("u_redAdj");
57 | // int greenAdj = cgp->getUniformLocationForName("u_greenAdj");
58 | // int blueAdj = cgp->getUniformLocationForName("u_blueAdj");
59 | // cgp->setUniformLocationWith1f(redAdj, _redAdj);
60 | // cgp->setUniformLocationWith1f(greenAdj, _greenAdj);
61 | // cgp->setUniformLocationWith1f(blueAdj, _blueAdj);
62 |
63 | _pProgramState->setUniformFloat("u_redAdj", _redAdj);
64 | _pProgramState->setUniformFloat("u_greenAdj", _greenAdj);
65 | _pProgramState->setUniformFloat("u_blueAdj", _blueAdj);
66 | }
67 |
68 | NS_CC_EXT_END
--------------------------------------------------------------------------------
/filters/filters/CCRGBFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCRGB_FILTER
29 | #define CCRGB_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== RGBFilter
36 |
37 | class RGBFilter : public Filter
38 | {
39 |
40 | public:
41 | static RGBFilter* create();
42 | static RGBFilter* create(float redAdj, float greenAdj, float blueAdj);
43 |
44 | RGBFilter();
45 |
46 | void setParameter(float redAdj, float greenAdj, float blueAdj);
47 | protected:
48 | virtual GLProgram* loadShader();
49 | virtual void setAttributes(GLProgram* glp);
50 | virtual void setUniforms(GLProgram* glp);
51 | float _redAdj;
52 | float _greenAdj;
53 | float _blueAdj;
54 | };
55 |
56 |
57 | NS_CC_EXT_END
58 |
59 | #endif //CCRGB_FILTER
--------------------------------------------------------------------------------
/filters/filters/CCSaturationFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCSaturationFilter.h"
2 |
3 | NS_CC_EXT_BEGIN
4 |
5 | //================== SaturationFilter
6 |
7 | SaturationFilter* SaturationFilter::create()
8 | {
9 | SaturationFilter* filter = new SaturationFilter();
10 | filter->autorelease();
11 | return filter;
12 | }
13 |
14 | SaturationFilter* SaturationFilter::create(float brightness)
15 | {
16 | SaturationFilter* filter = SaturationFilter::create();
17 | filter->setParameter(brightness);
18 | return filter;
19 | }
20 |
21 | SaturationFilter::SaturationFilter()
22 | {
23 | this->shaderName = kCCFilterShader_saturation;
24 | _param = 1.f;
25 | }
26 |
27 | GLProgram* SaturationFilter::loadShader()
28 | {
29 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, ccFilterShader_saturation_frag);
30 |
31 | // GLProgram* p = new GLProgram();
32 | // p->initWithByteArrays(ccPositionTexture_vert, ccFilterShader_saturation_frag);
33 | return p;
34 | }
35 |
36 | void SaturationFilter::setParameter(float param)
37 | {
38 | _param = MIN(2.f, MAX(param, 0.f));
39 | initProgram();
40 | }
41 |
42 | void SaturationFilter::setAttributes(GLProgram* cgp)
43 | {
44 | //CCLOG("SaturationFilter::setAttributes");
45 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
46 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
47 | }
48 |
49 | void SaturationFilter::setUniforms(GLProgram* cgp)
50 | {
51 | // int param = cgp->getUniformLocationForName("u_saturation");
52 | // cgp->setUniformLocationWith1f(param, _param);
53 |
54 | _pProgramState->setUniformFloat("u_saturation", _param);
55 | }
56 |
57 |
58 | NS_CC_EXT_END
59 |
--------------------------------------------------------------------------------
/filters/filters/CCSaturationFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCSATURATION_FILTER
29 | #define CCSATURATION_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 |
36 | //================== SaturationFilter
37 |
38 | class SaturationFilter : public SingleFloatParamFilter
39 | {
40 |
41 | public:
42 | static SaturationFilter* create();
43 | static SaturationFilter* create(float param);
44 |
45 | SaturationFilter();
46 |
47 | virtual void setParameter(float param);
48 | protected:
49 | virtual GLProgram* loadShader();
50 | virtual void setAttributes(GLProgram* glp);
51 | virtual void setUniforms(GLProgram* glp);
52 | };
53 |
54 |
55 | NS_CC_EXT_END
56 |
57 | #endif //CCSATURATION_FILTER
58 |
--------------------------------------------------------------------------------
/filters/filters/CCSepiaFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCSepiaFilter.h"
2 | #include "filters/nodes/CCFilteredSprite.h"
3 |
4 | NS_CC_EXT_BEGIN
5 | //================== SepiaFilter
6 |
7 | SepiaFilter* SepiaFilter::create()
8 | {
9 | SepiaFilter* filter = new SepiaFilter();
10 | filter->autorelease();
11 | return filter;
12 | }
13 |
14 | SepiaFilter* SepiaFilter::create(float resolation)
15 | {
16 | SepiaFilter* filter = SepiaFilter::create();
17 | filter->setParameter();
18 | return filter;
19 | }
20 |
21 | SepiaFilter::SepiaFilter()
22 | {
23 | this->shaderName = kCCFilterShader_sepia;
24 | }
25 |
26 | GLProgram* SepiaFilter::loadShader()
27 | {
28 | GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureColor_vert, ccFilterShader_sepia_frag);
29 |
30 | // GLProgram* p = new GLProgram();
31 | // p->initWithByteArrays(ccPositionTextureColor_vert,
32 | // ccFilterShader_sepia_frag);
33 | return p;
34 | }
35 |
36 | void SepiaFilter::setParameter()
37 | {
38 | initProgram();
39 | }
40 |
41 | void SepiaFilter::setAttributes(GLProgram* cgp)
42 | {
43 | //CCLOG("SepiaFilter::setAttributes");
44 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
45 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
46 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
47 | }
48 |
49 | void SepiaFilter::setUniforms(GLProgram* cgp)
50 | {
51 |
52 | }
53 |
54 | NS_CC_EXT_END
55 |
--------------------------------------------------------------------------------
/filters/filters/CCSepiaFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCSEPIA_FILTER
29 | #define CCSEPIA_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== SepiaFilter
36 |
37 | class SepiaFilter : public Filter
38 | {
39 |
40 | public:
41 | static SepiaFilter* create();
42 | static SepiaFilter* create(float resolation);
43 |
44 | SepiaFilter();
45 |
46 | void setParameter();
47 | protected:
48 | virtual GLProgram* loadShader();
49 | virtual void setAttributes(GLProgram* glp);
50 | virtual void setUniforms(GLProgram* glp);
51 | };
52 |
53 | NS_CC_EXT_END
54 |
55 | #endif //CCSEPIA_FILTER
56 |
--------------------------------------------------------------------------------
/filters/filters/CCSharpenFilter.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010-2012 cocos2d-x.org
3 | Copyright (c) 2008-2010 Ricardo Quesada
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2014 Jacky Tsang (zengrong.net)
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 |
28 | #ifndef CCSHARPEN_FILTER
29 | #define CCSHARPEN_FILTER
30 |
31 | #include "CCFilter.h"
32 |
33 | NS_CC_EXT_BEGIN
34 |
35 | //================== SharpenFilter
36 |
37 | class SharpenFilter : public Filter
38 | {
39 |
40 | public:
41 | static SharpenFilter* create();
42 | static SharpenFilter* create(float sharpness, float widthFactor, float heightFactor);
43 | static SharpenFilter* create(float sharpness, int amount);
44 |
45 | SharpenFilter();
46 |
47 | void setParameter(float sharpness, float widthFactor, float heightFactor);
48 | void setParameter(float sharpness, int amount);
49 | virtual void initSprite(FilteredSprite* sprite);
50 | protected:
51 | virtual GLProgram* loadShader();
52 | virtual void setAttributes(GLProgram* glp);
53 | virtual void setUniforms(GLProgram* glp);
54 | float _sharpness;
55 | float _widthFactor;
56 | float _heightFactor;
57 | int _amount;
58 |
59 | };
60 |
61 | NS_CC_EXT_END
62 |
63 | #endif //CCSHARPEN_FILTER
--------------------------------------------------------------------------------
/filters/filters/CCTestFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "CCTestFilter.h"
2 | #include "filters/nodes/CCFilteredSprite.h"
3 |
4 | NS_CC_EXT_BEGIN
5 |
6 |
7 | //================== TestFilter
8 |
9 | TestFilter* TestFilter::create()
10 | {
11 | TestFilter* filter = new TestFilter();
12 | filter->autorelease();
13 | return filter;
14 | }
15 |
16 | TestFilter* TestFilter::create(float resolation)
17 | {
18 | TestFilter* filter = TestFilter::create();
19 | filter->setParameter(resolation);
20 | return filter;
21 | }
22 |
23 | TestFilter::TestFilter()
24 | {
25 | this->shaderName = kCCFilterShader_test;
26 | }
27 |
28 | GLProgram* TestFilter::loadShader()
29 | {
30 | GLProgram* p = new GLProgram();
31 | CCLOG("TestFilter::loadShader, program: %p", p);
32 | p->initWithByteArrays(ccFilterShader_test_vert,
33 | ccFilterShader_test_frag);
34 | return p;
35 | }
36 |
37 | void TestFilter::setParameter(float resolation)
38 | {
39 | //The initProgram() will perform in initSprite()
40 | }
41 |
42 | void TestFilter::initSprite(FilteredSprite* sprite)
43 | {
44 | Size size = sprite->getContentSize();
45 | /*_textureWidth = size.width;
46 | _textureHeight = size.height;*/
47 | _textureWidth = 480;
48 | _textureHeight = 320;
49 | initProgram();
50 | }
51 |
52 | void TestFilter::setAttributes(GLProgram* cgp)
53 | {
54 | CCLOG("TestFilter::setAttributes");
55 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
56 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
57 | cgp->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
58 | }
59 |
60 | void TestFilter::setUniforms(GLProgram* cgp)
61 | {
62 | Texture2D* maskTex = Director::getInstance()->getTextureCache()->addImage("mask10.png");
63 | maskTex->setAntiAliasTexParameters();
64 |
65 | Texture2D* tex1 = Director::getInstance()->getTextureCache()->addImage("dirt.png");
66 | tex1->setAntiAliasTexParameters();
67 |
68 | int u_mask = cgp->getUniformLocationForName("u_mask");
69 | int u_texture1 = cgp->getUniformLocationForName("u_texture1");
70 | int u_cctexture = cgp->getUniformLocationForName("CC_Texture0");
71 |
72 | CCLOG("TestFilter::setUniforms u_mask:%d, u_texture1:%d, CC_Texture0:%d", u_mask, u_texture1, u_cctexture);
73 | cgp->setUniformLocationWith1i(u_mask, 2);
74 | cgp->setUniformLocationWith1i(u_texture1, 1);
75 |
76 | glActiveTexture(GL_TEXTURE2);
77 | glBindTexture(GL_TEXTURE_2D, maskTex->getName());
78 | glActiveTexture(GL_TEXTURE1);
79 | glBindTexture(GL_TEXTURE_2D, tex1->getName());
80 | glActiveTexture(GL_TEXTURE0);
81 |
82 | CCLOG("TestFilter::setUniforms _textureWidth:%.5f,_textureHeight:%.5f",
83 | _textureWidth, _textureHeight);
84 | }
85 |
86 | NS_CC_EXT_END
87 |
--------------------------------------------------------------------------------
/filters/filters/CCTestFilter.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef CCTEST_FILTER
3 | #define CCTEST_FILTER
4 |
5 | #include "CCFilter.h"
6 |
7 | NS_CC_EXT_BEGIN
8 |
9 |
10 | //================== TestFilter
11 |
12 | class TestFilter : public Filter
13 | {
14 |
15 | public:
16 | static TestFilter* create();
17 | static TestFilter* create(float resolation);
18 |
19 | TestFilter();
20 |
21 | void setParameter(float resolation);
22 | virtual void initSprite(FilteredSprite* sprite);
23 | protected:
24 | virtual GLProgram* loadShader();
25 | virtual void setAttributes(GLProgram* glp);
26 | virtual void setUniforms(GLProgram* glp);
27 | float _textureWidth;
28 | float _textureHeight;
29 | };
30 |
31 | NS_CC_EXT_END
32 |
33 | #endif //CCTEST_FILTER
34 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_blur_frag.h:
--------------------------------------------------------------------------------
1 | "\n\
2 | #ifdef GL_ES\n\
3 | precision mediump float;\n\
4 | #endif\n\
5 | \n\
6 | varying vec2 v_texCoord;\n\
7 | varying vec2 v_blurTexCoords[14];\n\
8 | \n\
9 | void main()\n\
10 | {\n\
11 | gl_FragColor = vec4(0.0);\n\
12 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 0])*0.0044299121055113265;\n\
13 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 1])*0.00895781211794;\n\
14 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 2])*0.0215963866053;\n\
15 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 3])*0.0443683338718;\n\
16 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 4])*0.0776744219933;\n\
17 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 5])*0.115876621105;\n\
18 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 6])*0.147308056121;\n\
19 | gl_FragColor += texture2D(CC_Texture0, v_texCoord )*0.159576912161;\n\
20 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 7])*0.147308056121;\n\
21 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 8])*0.115876621105;\n\
22 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[ 9])*0.0776744219933;\n\
23 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[10])*0.0443683338718;\n\
24 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[11])*0.0215963866053;\n\
25 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[12])*0.00895781211794;\n\
26 | gl_FragColor += texture2D(CC_Texture0, v_blurTexCoords[13])*0.0044299121055113265;\n\
27 | }";
28 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_brightness_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | varying vec2 v_texCoord;\n\
5 | \n\
6 | uniform float u_brightness;\n\
7 | \n\
8 | void main()\n\
9 | {\n\
10 | vec4 textureColor = texture2D(CC_Texture0, v_texCoord);\n\
11 | gl_FragColor = vec4((textureColor.rgb + vec3(u_brightness)), textureColor.w);\n\
12 | }";
13 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_colorramp_frag.h:
--------------------------------------------------------------------------------
1 | "\n\
2 | #ifdef GL_ES\n\
3 | precision mediump float;\n\
4 | #endif\n\
5 | \n\
6 | // 1\n\
7 | varying vec2 v_texCoord;\n\
8 | uniform sampler2D u_texture;\n\
9 | uniform sampler2D u_colorRampTexture;\n\
10 | \n\
11 | void main()\n\
12 | {\n\
13 | vec3 normalColor = texture2D(u_texture, v_texCoord).rgb;\n\
14 | \n\
15 | float rampedR = texture2D(u_colorRampTexture, vec2(normalColor.r, 0)).r;\n\
16 | float rampedG = texture2D(u_colorRampTexture, vec2(normalColor.g, 0)).g;\n\
17 | float rampedB = texture2D(u_colorRampTexture, vec2(normalColor.b, 0)).b;\n\
18 | \n\
19 | gl_FragColor = vec4(rampedR, rampedG, rampedB, 1);\n\
20 | }\n\
21 | ";
22 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_contrast_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | varying vec2 v_texCoord;\n\
5 | \n\
6 | uniform float u_contrast;\n\
7 | \n\
8 | void main()\n\
9 | {\n\
10 | vec4 textureColor = texture2D(CC_Texture0, v_texCoord);\n\
11 | gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * u_contrast + vec3(0.5)), textureColor.w);\n\
12 | }";
13 |
14 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_drop_shadow_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | uniform vec2 u_resolution;\n\
5 | \n\
6 | varying vec4 v_fragmentColor;\n\
7 | varying vec2 v_texCoord;\n\
8 | \n\
9 | const float RADIUS = 0.75;\n\
10 | const float SOFTNESS = 0.45;\n\
11 | const vec3 SEPIA = vec3(1.2, 1.0, 0.8);\n\
12 | \n\
13 | void main() {\n\
14 | vec4 texColor = texture2D(CC_Texture0, v_texCoord);\n\
15 | vec2 pos = (gl_FragCoord.xy/u_resolution.xy) - 0.5;\n\
16 | pos.x *= u_resolution.x/u_resolution.y;\n\
17 | float len = length(pos);\n\
18 | ////gl_FragColor = vec4(texColor.rgb*(1.0-len), 1.0);\n\
19 | float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);\n\
20 | //texColor.rgb *= mix(texColor.rgb, texColor.rgb*vignette, 0.5);\n\
21 | texColor.rgb = mix(texColor.rgb, texColor.rgb*vignette, 0.5);\n\
22 | //gl_FragColor=texColor;\n\
23 | //gl_FragColor=texColor*v_fragmentColor;\n\
24 | //gl_FragColor = vec4(texColor.rgb*(1.0-len), 1);\n\
25 | float gray = dot(texColor.rgb, vec3(0.299, 0.587, 0.144));\n\
26 | vec3 sepiaColor = vec3(gray)*SEPIA;\n\
27 | gl_FragColor = vec4(mix(texColor.rgb, sepiaColor, 0.75), 1.0);\n\
28 | }";
29 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_drop_shadow_vert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 | *
4 | * Copyright (c) 2011 Ricardo Quesada
5 | * Copyright (c) 2012 Zynga Inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | */
25 |
26 | " \n\
27 | attribute vec4 a_position; \n\
28 | attribute vec2 a_texCoord; \n\
29 | attribute vec4 a_color; \n\
30 | \n\
31 | #ifdef GL_ES \n\
32 | varying lowp vec4 v_fragmentColor; \n\
33 | varying mediump vec2 v_texCoord; \n\
34 | #else \n\
35 | varying vec4 v_fragmentColor; \n\
36 | varying vec2 v_texCoord; \n\
37 | #endif \n\
38 | \n\
39 | void main() \n\
40 | { \n\
41 | gl_Position = CC_MVPMatrix * a_position; \n\
42 | v_fragmentColor = a_color; \n\
43 | v_texCoord = a_texCoord; \n\
44 | } \n\
45 | ";
46 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_emboss_frag.h:
--------------------------------------------------------------------------------
1 | "precision mediump float;\n\
2 | varying vec2 v_texCoord;\n\
3 | uniform float u_factor;\n\
4 | \n\
5 | void main()\n\
6 | {\n\
7 | vec2 onePixel = vec2(0.5 / 480.0, 0.5 / 320.0);\n\
8 | \n\
9 | // 3\n\
10 | vec2 texCoord = v_texCoord;\n\
11 | \n\
12 | // 4\n\
13 | vec4 color;\n\
14 | color.rgb = vec3(0.5);\n\
15 | color -= texture2D(CC_Texture0, texCoord - onePixel) * 3.0;\n\
16 | color += texture2D(CC_Texture0, texCoord + onePixel) * 3.0;\n\
17 | // 5\n\
18 | color.rgb = vec3((color.r + color.g + color.b) / 3.0);\n\
19 | gl_FragColor = vec4(color.rgb, 1);\n\
20 | }";
21 |
22 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_embossmov_frag.h:
--------------------------------------------------------------------------------
1 | "\n\
2 | #ifdef GL_ES\n\
3 | precision mediump float;\n\
4 | #endif\n\
5 | \n\
6 | varying vec2 v_texCoord;\n\
7 | uniform sampler2D u_texture;\n\
8 | uniform float u_time;\n\
9 | \n\
10 | void main()\n\
11 | {\n\
12 | vec2 onePixel = vec2(1.0 / 480.0, 1.0 / 320.0);\n\
13 | \n\
14 | vec2 texCoord = v_texCoord;\n\
15 | texCoord.x += sin(u_time) * (onePixel.x * 20.0);\n\
16 | texCoord.y += cos(u_time) * (onePixel.y * 20.0);\n\
17 | \n\
18 | vec4 color;\n\
19 | color.rgb = vec3(0.5);\n\
20 | color -= texture2D(u_texture, texCoord - onePixel) * 2.0;\n\
21 | color += texture2D(u_texture, texCoord + onePixel) * 2.0;\n\
22 | color.rgb = vec3((color.r + color.g + color.b) / 3.0);\n\
23 | gl_FragColor = vec4(color.rgb, 1);\n\
24 | }";
25 |
26 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_exposure_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision highp float;\n\
3 | varying mediump vec2 v_texCoord;\n\
4 | #else\n\
5 | varying vec2 v_texCoord;\n\
6 | #endif\n\
7 | \n\
8 | uniform float u_exposure;\n\
9 | \n\
10 | void main()\n\
11 | {\n\
12 | vec4 textureColor = texture2D(CC_Texture0, v_texCoord);\n\
13 | gl_FragColor = vec4(textureColor.rgb * pow(2.0, u_exposure), textureColor.w);\n\
14 | }";
15 |
16 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_gamma_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | varying vec2 v_texCoord;\n\
5 | \n\
6 | uniform float u_gamma;\n\
7 | \n\
8 | void main()\n\
9 | {\n\
10 | vec4 textureColor = texture2D(CC_Texture0, v_texCoord);\n\
11 | gl_FragColor = vec4(pow(textureColor.rgb, vec3(u_gamma)), textureColor.w);\n\
12 | }";
13 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_gaussian_blur_frag.h:
--------------------------------------------------------------------------------
1 | "uniform float u_resolution;\n\
2 | uniform float u_radius;\n\
3 | uniform vec2 u_direction;\n\
4 | \n\
5 | varying vec4 v_fragmentColor;\n\
6 | varying vec2 v_texCoord;\n\
7 | \n\
8 | void main() {\n\
9 | //this will be our RGBA sum\n\
10 | vec4 sum = vec4(0.0);\n\
11 | \n\
12 | //our original texcoord for this fragment\n\
13 | vec2 tc = v_texCoord;\n\
14 | \n\
15 | //the amount to blur, i.e. how far off center to sample from \n\
16 | //1.0 -> blur by one pixel\n\
17 | //2.0 -> blur by two pixels, etc.\n\
18 | float blur = u_radius/u_resolution; \n\
19 | \n\
20 | //the u_direction of our blur\n\
21 | //(1.0, 0.0) -> x-axis blur\n\
22 | //(0.0, 1.0) -> y-axis blur\n\
23 | float hstep = u_direction.x;\n\
24 | float vstep = u_direction.y;\n\
25 | \n\
26 | \n\
27 | //apply blurring, using a 9-tap filter with predefined gaussian weights\n\
28 | \n\
29 | sum += texture2D(CC_Texture0, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.0162162162;\n\
30 | sum += texture2D(CC_Texture0, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.0540540541;\n\
31 | sum += texture2D(CC_Texture0, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.1216216216;\n\
32 | sum += texture2D(CC_Texture0, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.1945945946;\n\
33 | \n\
34 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y)) * 0.2270270270;\n\
35 | \n\
36 | sum += texture2D(CC_Texture0, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.1945945946;\n\
37 | sum += texture2D(CC_Texture0, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.1216216216;\n\
38 | sum += texture2D(CC_Texture0, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.0540540541;\n\
39 | sum += texture2D(CC_Texture0, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.0162162162;\n\
40 | \n\
41 | //discard alpha for our simple demo, multiply by vertex color and return\n\
42 | gl_FragColor = v_fragmentColor * vec4(sum.rgb, 1.0);\n\
43 | }";
44 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_gaussian_hblur_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | uniform float u_resolution;\n\
5 | uniform float u_radius;\n\
6 | \n\
7 | varying vec4 v_fragmentColor;\n\
8 | varying vec2 v_texCoord;\n\
9 | \n\
10 | const float f1 = 0.15;\n\
11 | const float f2 = 0.12;\n\
12 | const float f3 = 0.09;\n\
13 | const float f4 = 0.05;\n\
14 | const float fc = 0.16;\n\
15 | \n\
16 | void main() {\n\
17 | vec4 sum = vec4(0.0);\n\
18 | vec2 tc = v_texCoord;\n\
19 | float blur = u_radius/u_resolution; \n\
20 | \n\
21 | sum += texture2D(CC_Texture0, vec2(tc.x - 4.0*blur, tc.y)) * f4;\n\
22 | sum += texture2D(CC_Texture0, vec2(tc.x - 3.0*blur, tc.y)) * f3;\n\
23 | sum += texture2D(CC_Texture0, vec2(tc.x - 2.0*blur, tc.y)) * f2;\n\
24 | sum += texture2D(CC_Texture0, vec2(tc.x - 1.0*blur, tc.y)) * f1;\n\
25 | \n\
26 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y)) * fc;\n\
27 | \n\
28 | sum += texture2D(CC_Texture0, vec2(tc.x + 1.0*blur, tc.y)) * f1;\n\
29 | sum += texture2D(CC_Texture0, vec2(tc.x + 2.0*blur, tc.y)) * f2;\n\
30 | sum += texture2D(CC_Texture0, vec2(tc.x + 3.0*blur, tc.y)) * f3;\n\
31 | sum += texture2D(CC_Texture0, vec2(tc.x + 4.0*blur, tc.y)) * f4;\n\
32 | \n\
33 | gl_FragColor = v_fragmentColor * sum;\n\
34 | }";
35 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_gaussian_vblur_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | uniform float u_resolution;\n\
5 | uniform float u_radius;\n\
6 | \n\
7 | varying vec4 v_fragmentColor;\n\
8 | varying vec2 v_texCoord;\n\
9 | \n\
10 | const float f1 = 0.15;\n\
11 | const float f2 = 0.12;\n\
12 | const float f3 = 0.09;\n\
13 | const float f4 = 0.05;\n\
14 | const float fc = 0.16;\n\
15 | \n\
16 | void main() {\n\
17 | vec4 sum = vec4(0.0);\n\
18 | vec2 tc = v_texCoord;\n\
19 | float blur = u_radius/u_resolution; \n\
20 | \n\
21 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y - 4.0*blur)) * f4;\n\
22 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y - 3.0*blur)) * f3;\n\
23 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y - 2.0*blur)) * f2;\n\
24 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y - 1.0*blur)) * f1;\n\
25 | \n\
26 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y)) * fc;\n\
27 | \n\
28 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y + 1.0*blur)) * f1;\n\
29 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y + 2.0*blur)) * f2;\n\
30 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y + 3.0*blur)) * f3;\n\
31 | sum += texture2D(CC_Texture0, vec2(tc.x, tc.y + 4.0*blur)) * f4;\n\
32 | \n\
33 | gl_FragColor = v_fragmentColor * sum;\n\
34 | }";
35 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_grass_frag.h:
--------------------------------------------------------------------------------
1 | "\n\
2 | #ifdef GL_ES\n\
3 | precision mediump float;\n\
4 | #endif\n\
5 | \n\
6 | varying vec2 v_texCoord;\n\
7 | uniform sampler2D u_texture;\n\
8 | uniform float u_time;\n\
9 | \n\
10 | // 1\n\
11 | const float speed = 3.0;\n\
12 | const float bendFactor = 0.2;\n\
13 | void main()\n\
14 | {\n\
15 | // 2\n\
16 | float height = 1.0 - v_texCoord.y;\n\
17 | // 3\n\
18 | float offset = pow(height, 1.5);\n\
19 | \n\
20 | // 4 multiply by sin since it gives us nice bending\n\
21 | offset *= (sin(u_time * speed) * bendFactor);\n\
22 | \n\
23 | // 5\n\
24 | vec3 normalColor = texture2D(u_texture, fract(vec2(v_texCoord.x + offset, v_texCoord.y))).rgb;\n\
25 | gl_FragColor = vec4(normalColor, 1);\n\
26 | }";
27 |
28 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_gray_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | varying vec2 v_texCoord; \n\
5 | varying vec4 v_fragmentColor;\n\
6 | \n\
7 | uniform vec4 u_grayParam; \n\
8 | \n\
9 | void main(void) \n\
10 | { \n\
11 | vec4 texColor = texture2D(CC_Texture0, v_texCoord); \n\
12 | float grey = dot(texColor.rgba, u_grayParam); \n\
13 | gl_FragColor = vec4(vec3(grey), texColor.a) * v_fragmentColor; \n\
14 | }";
15 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_haze_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | uniform lowp float u_hazeDistance;\n\
4 | uniform highp float u_slope;\n\
5 | #else\n\
6 | uniform float u_hazeDistance;\n\
7 | uniform float u_slope;\n\
8 | #endif\n\
9 | varying vec2 v_texCoord;\n\
10 | \n\
11 | void main()\n\
12 | {\n\
13 | //todo reconsider precision modifiers \n\
14 | #ifdef GL_ES\n\
15 | highp vec4 color = vec4(1.0);//todo reimplement as a parameter\n\
16 | highp float d = v_texCoord.y * u_slope + u_hazeDistance;\n\
17 | highp vec4 c = texture2D(CC_Texture0, v_texCoord) ; // consider using unpremultiply\n\
18 | #else\n\
19 | vec4 color = vec4(1.0);//todo reimplement as a parameter\n\
20 | float d = v_texCoord.y * u_slope + u_hazeDistance;\n\
21 | vec4 c = texture2D(CC_Texture0, v_texCoord) ; // consider using unpremultiply\n\
22 | #endif\n\
23 | c = (c - d * color) / (1.0 -d);\n\
24 | \n\
25 | gl_FragColor = c; //consider using premultiply(c);\n\
26 | }";
27 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_hblur_vert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 | *
4 | * Copyright (c) 2011 Ricardo Quesada
5 | * Copyright (c) 2012 Zynga Inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | */
25 |
26 | " \n\
27 | attribute vec4 a_position; \n\
28 | attribute vec2 a_texCoord; \n\
29 | attribute vec4 a_color; \n\
30 | \n\
31 | #ifdef GL_ES \n\
32 | varying lowp vec4 v_fragmentColor; \n\
33 | varying mediump vec2 v_texCoord; \n\
34 | #else \n\
35 | varying vec4 v_fragmentColor; \n\
36 | varying vec2 v_texCoord; \n\
37 | #endif \n\
38 | \n\
39 | uniform float u_radius; \n\
40 | varying vec2 v_blurTexCoords[14]; \n\
41 | \n\
42 | void main() \n\
43 | { \n\
44 | gl_Position = CC_MVPMatrix * a_position; \n\
45 | v_fragmentColor = a_color; \n\
46 | v_texCoord = a_texCoord; \n\
47 | for (int i = 0; i < 7; ++i) {\n\
48 | vec2 c = vec2(u_radius / 7.0*(7.0 - float(i)), 0.0);\n\
49 | v_blurTexCoords[i] = v_texCoord - c;\n\
50 | v_blurTexCoords[13 - i] = v_texCoord + c;\n\
51 | }\n\
52 | } \n\
53 | ";
54 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_hue_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | varying vec2 v_texCoord;\n\
5 | \n\
6 | uniform float u_hueAdjust;\n\
7 | const vec4 kRGBToYPrime = vec4 (0.299, 0.587, 0.114, 0.0);\n\
8 | const vec4 kRGBToI = vec4 (0.595716, -0.274453, -0.321263, 0.0);\n\
9 | const vec4 kRGBToQ = vec4 (0.211456, -0.522591, 0.31135, 0.0);\n\
10 | \n\
11 | const vec4 kYIQToR = vec4 (1.0, 0.9563, 0.6210, 0.0);\n\
12 | const vec4 kYIQToG = vec4 (1.0, -0.2721, -0.6474, 0.0);\n\
13 | const vec4 kYIQToB = vec4 (1.0, -1.1070, 1.7046, 0.0);\n\
14 | \n\
15 | void main ()\n\
16 | {\n\
17 | // Sample the input pixel\n\
18 | vec4 color = texture2D(CC_Texture0, v_texCoord);\n\
19 | \n\
20 | // Convert to YIQ\n\
21 | float YPrime = dot (color, kRGBToYPrime);\n\
22 | float I = dot (color, kRGBToI);\n\
23 | float Q = dot (color, kRGBToQ);\n\
24 | \n\
25 | // Calculate the hue and chroma\n\
26 | float hue = atan (Q, I);\n\
27 | float chroma = sqrt (I * I + Q * Q);\n\
28 | \n\
29 | // Make the user's adjustments\n\
30 | hue += (-u_hueAdjust); //why negative rotation?\n\
31 | \n\
32 | // Convert back to YIQ\n\
33 | Q = chroma * sin (hue);\n\
34 | I = chroma * cos (hue);\n\
35 | \n\
36 | // Convert back to RGB\n\
37 | vec4 yIQ = vec4 (YPrime, I, Q, 0.0);\n\
38 | color.r = dot (yIQ, kYIQToR);\n\
39 | color.g = dot (yIQ, kYIQToG);\n\
40 | color.b = dot (yIQ, kYIQToB);\n\
41 | \n\
42 | // Save the result\n\
43 | gl_FragColor = color;\n\
44 | }";
45 |
46 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_motion_blur_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision highp float;\n\
3 | #endif\n\
4 | \n\
5 | \n\
6 | varying vec2 v_texCoord;\n\
7 | varying vec2 v_oneStepBackTextureCoordinate;\n\
8 | varying vec2 v_twoStepsBackTextureCoordinate;\n\
9 | varying vec2 v_threeStepsBackTextureCoordinate;\n\
10 | varying vec2 v_fourStepsBackTextureCoordinate;\n\
11 | varying vec2 v_oneStepForwardTextureCoordinate;\n\
12 | varying vec2 v_twoStepsForwardTextureCoordinate;\n\
13 | varying vec2 v_threeStepsForwardTextureCoordinate;\n\
14 | varying vec2 v_fourStepsForwardTextureCoordinate;\n\
15 | \n\
16 | void main()\n\
17 | {\n\
18 | #ifdef GL_ES\n\
19 | lowp vec4 fragmentColor = texture2D(CC_Texture0, v_texCoord) * 0.18;\n\
20 | #else\n\
21 | vec4 fragmentColor = texture2D(CC_Texture0, v_texCoord) * 0.18;\n\
22 | #endif\n\
23 | fragmentColor += texture2D(CC_Texture0, v_oneStepBackTextureCoordinate) * 0.15;\n\
24 | fragmentColor += texture2D(CC_Texture0, v_twoStepsBackTextureCoordinate) * 0.12;\n\
25 | fragmentColor += texture2D(CC_Texture0, v_threeStepsBackTextureCoordinate) * 0.09;\n\
26 | fragmentColor += texture2D(CC_Texture0, v_fourStepsBackTextureCoordinate) * 0.05;\n\
27 | fragmentColor += texture2D(CC_Texture0, v_oneStepForwardTextureCoordinate) * 0.15;\n\
28 | fragmentColor += texture2D(CC_Texture0, v_twoStepsForwardTextureCoordinate) * 0.12;\n\
29 | fragmentColor += texture2D(CC_Texture0, v_threeStepsForwardTextureCoordinate) * 0.09;\n\
30 | fragmentColor += texture2D(CC_Texture0, v_fourStepsForwardTextureCoordinate) * 0.05;\n\
31 | \n\
32 | gl_FragColor = fragmentColor;\n\
33 | }";
34 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_motion_blur_vert.h:
--------------------------------------------------------------------------------
1 | "attribute vec4 a_position;\n\
2 | attribute vec2 a_texCoord;\n\
3 | \n\
4 | uniform vec2 u_directionalTexelStep;\n\
5 | \n\
6 | varying vec2 v_texCoord;\n\
7 | varying vec2 v_oneStepBackTextureCoordinate;\n\
8 | varying vec2 v_twoStepsBackTextureCoordinate;\n\
9 | varying vec2 v_threeStepsBackTextureCoordinate;\n\
10 | varying vec2 v_fourStepsBackTextureCoordinate;\n\
11 | varying vec2 v_oneStepForwardTextureCoordinate;\n\
12 | varying vec2 v_twoStepsForwardTextureCoordinate;\n\
13 | varying vec2 v_threeStepsForwardTextureCoordinate;\n\
14 | varying vec2 v_fourStepsForwardTextureCoordinate;\n\
15 | \n\
16 | void main()\n\
17 | {\n\
18 | gl_Position = CC_PMatrix * a_position;\n\
19 | //gl_Position = a_position;\n\
20 | \n\
21 | v_texCoord = a_texCoord;\n\
22 | v_oneStepBackTextureCoordinate = a_texCoord - u_directionalTexelStep;\n\
23 | v_twoStepsBackTextureCoordinate = a_texCoord - 2.0 * u_directionalTexelStep;\n\
24 | v_threeStepsBackTextureCoordinate = a_texCoord - 3.0 * u_directionalTexelStep;\n\
25 | v_fourStepsBackTextureCoordinate = a_texCoord - 4.0 * u_directionalTexelStep;\n\
26 | v_oneStepForwardTextureCoordinate = a_texCoord + u_directionalTexelStep;\n\
27 | v_twoStepsForwardTextureCoordinate = a_texCoord + 2.0 * u_directionalTexelStep;\n\
28 | v_threeStepsForwardTextureCoordinate = a_texCoord + 3.0 * u_directionalTexelStep;\n\
29 | v_fourStepsForwardTextureCoordinate = a_texCoord + 4.0 * u_directionalTexelStep;\n\
30 | }";
31 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_rgb_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision mediump float;\n\
3 | #endif\n\
4 | varying vec2 v_texCoord;\n\
5 | \n\
6 | \n\
7 | uniform float u_redAdj;\n\
8 | uniform float u_greenAdj;\n\
9 | uniform float u_blueAdj;\n\
10 | \n\
11 | void main()\n\
12 | {\n\
13 | vec4 textureColor = texture2D(CC_Texture0, v_texCoord);\n\
14 | gl_FragColor = vec4(textureColor.r * u_redAdj, textureColor.g * u_greenAdj, textureColor.b * u_blueAdj, textureColor.a);\n\
15 | }";
16 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_saturation_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision lowp float;\n\
3 | varying highp vec2 v_texCoord;\n\
4 | #else\n\
5 | varying vec2 v_texCoord;\n\
6 | #endif\n\
7 | \n\
8 | uniform float u_saturation;\n\
9 | \n\
10 | const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);\n\
11 | \n\
12 | void main()\n\
13 | {\n\
14 | vec4 textureColor = texture2D(CC_Texture0, v_texCoord);\n\
15 | float luminance = dot(textureColor.rgb, luminanceWeighting);\n\
16 | vec3 greyScaleColor = vec3(luminance);\n\
17 | \n\
18 | gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, u_saturation), textureColor.w);\n\
19 | }";
20 |
21 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_sepia_frag.h:
--------------------------------------------------------------------------------
1 | "varying vec4 v_fragmentColor;\n\
2 | varying vec2 v_texCoord;\n\
3 | \n\
4 | const vec3 SEPIA = vec3(1.2, 1.0, 0.8);\n\
5 | \n\
6 | void main() {\n\
7 | vec4 texColor = texture2D(CC_Texture0, v_texCoord);\n\
8 | float gray = dot(texColor.rgb, vec3(0.299, 0.587, 0.144));\n\
9 | vec3 sepiaColor = vec3(gray)*SEPIA;\n\
10 | gl_FragColor = vec4(mix(texColor.rgb, sepiaColor, 0.75), 1.0)*v_fragmentColor;\n\
11 | }";
12 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_sharpen_frag.h:
--------------------------------------------------------------------------------
1 | "varying vec2 v_texCoord;\n\
2 | varying vec2 v_leftTexCoord;\n\
3 | varying vec2 v_rightTexCoord; \n\
4 | varying vec2 v_topTexCoord;\n\
5 | varying vec2 v_bottomTexCoord;\n\
6 | \n\
7 | varying float v_centerMultiplier;\n\
8 | varying float v_edgeMultiplier;\n\
9 | \n\
10 | void main()\n\
11 | {\n\
12 | vec3 textureColor = texture2D(CC_Texture0, v_texCoord).rgb;\n\
13 | vec3 leftTexColor = texture2D(CC_Texture0, v_leftTexCoord).rgb;\n\
14 | vec3 rightTexColor = texture2D(CC_Texture0, v_rightTexCoord).rgb;\n\
15 | vec3 topTexColor = texture2D(CC_Texture0, v_topTexCoord).rgb;\n\
16 | vec3 bottomTexColor = texture2D(CC_Texture0, v_bottomTexCoord).rgb;\n\
17 | \n\
18 | vec3 v1 = leftTexColor * v_edgeMultiplier + rightTexColor * v_edgeMultiplier + topTexColor * v_edgeMultiplier + bottomTexColor * v_edgeMultiplier;\n\
19 | vec3 v2 = textureColor * v_centerMultiplier - v1;\n\
20 | vec4 v3 = texture2D(CC_Texture0, v_bottomTexCoord);\n\
21 | \n\
22 | gl_FragColor = vec4(v2, v3.w);\n\
23 | }";
24 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_sharpen_vert.h:
--------------------------------------------------------------------------------
1 | "attribute vec4 a_position;\n\
2 | attribute vec2 a_texCoord;\n\
3 | attribute vec4 a_color; \n\
4 | \n\
5 | uniform float u_widthFactor; \n\
6 | uniform float u_heightFactor; \n\
7 | uniform float u_sharpness;\n\
8 | \n\
9 | varying vec2 v_texCoord;\n\
10 | varying vec2 v_leftTexCoord;\n\
11 | varying vec2 v_rightTexCoord; \n\
12 | varying vec2 v_topTexCoord;\n\
13 | varying vec2 v_bottomTexCoord;\n\
14 | \n\
15 | varying float v_centerMultiplier;\n\
16 | varying float v_edgeMultiplier;\n\
17 | \n\
18 | void main()\n\
19 | {\n\
20 | gl_Position = CC_PMatrix * a_position; \n\
21 | //gl_Position = a_position;\n\
22 | \n\
23 | vec2 widthStep = vec2(u_widthFactor, 0.0);\n\
24 | vec2 heightStep = vec2(0.0, u_heightFactor);\n\
25 | \n\
26 | v_texCoord = a_texCoord;\n\
27 | v_leftTexCoord = a_texCoord - widthStep;\n\
28 | v_rightTexCoord = a_texCoord + widthStep;\n\
29 | v_topTexCoord = a_texCoord + heightStep;\n\
30 | v_bottomTexCoord = a_texCoord - heightStep;\n\
31 | \n\
32 | v_centerMultiplier = 1.0 + 4.0 * u_sharpness;\n\
33 | v_edgeMultiplier = u_sharpness;\n\
34 | }";
35 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_test_frag.h:
--------------------------------------------------------------------------------
1 | "uniform sampler2D u_texture1;\n\
2 | uniform sampler2D u_mask;\n\
3 | \n\
4 | varying vec4 v_fragmentColor;\n\
5 | varying vec2 v_texCoord;\n\
6 | \n\
7 | void main() {\n\
8 | vec4 texColor0 = texture2D(CC_Texture0, v_texCoord);\n\
9 | vec4 texColor1 = texture2D(u_texture1, v_texCoord);\n\
10 | float mask = texture2D(u_mask, v_texCoord).a;\n\
11 | gl_FragColor = mix(texColor0, texColor1, mask);\n\
12 | }";
13 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_test_vert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 | *
4 | * Copyright (c) 2011 Ricardo Quesada
5 | * Copyright (c) 2012 Zynga Inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | */
25 |
26 | " \n\
27 | attribute vec4 a_position; \n\
28 | attribute vec2 a_texCoord; \n\
29 | attribute vec4 a_color; \n\
30 | \n\
31 | #ifdef GL_ES \n\
32 | varying lowp vec4 v_fragmentColor; \n\
33 | varying mediump vec2 v_texCoord; \n\
34 | #else \n\
35 | varying vec4 v_fragmentColor; \n\
36 | varying vec2 v_texCoord; \n\
37 | #endif \n\
38 | \n\
39 | void main() \n\
40 | { \n\
41 | gl_Position = CC_MVPMatrix * a_position; \n\
42 | v_fragmentColor = a_color; \n\
43 | v_texCoord = a_texCoord; \n\
44 | } \n\
45 | ";
46 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_vblur_vert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 | *
4 | * Copyright (c) 2011 Ricardo Quesada
5 | * Copyright (c) 2012 Zynga Inc.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | */
25 |
26 | " \n\
27 | attribute vec4 a_position; \n\
28 | attribute vec2 a_texCoord; \n\
29 | attribute vec4 a_color; \n\
30 | \n\
31 | #ifdef GL_ES \n\
32 | varying lowp vec4 v_fragmentColor; \n\
33 | varying mediump vec2 v_texCoord; \n\
34 | #else \n\
35 | varying vec4 v_fragmentColor; \n\
36 | varying vec2 v_texCoord; \n\
37 | #endif \n\
38 | \n\
39 | uniform float u_radius; \n\
40 | varying vec2 v_blurTexCoords[14]; \n\
41 | \n\
42 | void main() \n\
43 | { \n\
44 | gl_Position = CC_MVPMatrix * a_position; \n\
45 | v_fragmentColor = a_color; \n\
46 | v_texCoord = a_texCoord; \n\
47 | for (int i = 0; i < 7; ++i) {\n\
48 | vec2 c = vec2(0.0, u_radius / 7.0*(7.0 - float(i)));\n\
49 | v_blurTexCoords[i] = v_texCoord - c;\n\
50 | v_blurTexCoords[13 - i] = v_texCoord + c;\n\
51 | }\n\
52 | } \n\
53 | ";
54 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShader_zoom_blur_frag.h:
--------------------------------------------------------------------------------
1 | "#ifdef GL_ES\n\
2 | precision highp float;\n\
3 | #endif\n\
4 | varying vec2 v_texCoord;\n\
5 | \n\
6 | uniform vec2 u_blurCenter;\n\
7 | uniform float u_blurSize;\n\
8 | \n\
9 | void main()\n\
10 | {\n\
11 | // TODO: Do a more intelligent scaling based on resolution here\n\
12 | vec2 samplingOffset = 1.0/100.0 * (u_blurCenter - v_texCoord) * u_blurSize;\n\
13 | \n\
14 | #ifdef GL_ES\n\
15 | lowp vec4 fragmentColor = texture2D(CC_Texture0, v_texCoord) * 0.18;\n\
16 | #else\n\
17 | vec4 fragmentColor = texture2D(CC_Texture0, v_texCoord) * 0.18;\n\
18 | #endif\n\
19 | fragmentColor += texture2D(CC_Texture0, v_texCoord + samplingOffset) * 0.15;\n\
20 | fragmentColor += texture2D(CC_Texture0, v_texCoord + (2.0 * samplingOffset)) * 0.12;\n\
21 | fragmentColor += texture2D(CC_Texture0, v_texCoord + (3.0 * samplingOffset)) * 0.09;\n\
22 | fragmentColor += texture2D(CC_Texture0, v_texCoord + (4.0 * samplingOffset)) * 0.05;\n\
23 | fragmentColor += texture2D(CC_Texture0, v_texCoord - samplingOffset) * 0.15;\n\
24 | fragmentColor += texture2D(CC_Texture0, v_texCoord - (2.0 * samplingOffset)) * 0.12;\n\
25 | fragmentColor += texture2D(CC_Texture0, v_texCoord - (3.0 * samplingOffset)) * 0.09;\n\
26 | fragmentColor += texture2D(CC_Texture0, v_texCoord - (4.0 * samplingOffset)) * 0.05;\n\
27 | \n\
28 | gl_FragColor = fragmentColor;\n\
29 | }";
30 |
--------------------------------------------------------------------------------
/filters/shaders/ccFilterShaders.cpp:
--------------------------------------------------------------------------------
1 | #include "ccFilterShaders.h"
2 |
3 | NS_CC_EXT_BEGIN
4 |
5 | const GLchar * ccFilterShader_gray_frag =
6 | #include "ccFilterShader_gray_frag.h"
7 |
8 | const GLchar * ccFilterShader_hblur_vert =
9 | #include "ccFilterShader_hblur_vert.h"
10 | const GLchar * ccFilterShader_vblur_vert =
11 | #include "ccFilterShader_vblur_vert.h"
12 | const GLchar * ccFilterShader_blur_frag =
13 | #include "ccFilterShader_blur_frag.h"
14 |
15 | const GLchar * ccFilterShader_sharpen_vert =
16 | #include "ccFilterShader_sharpen_vert.h"
17 | const GLchar * ccFilterShader_sharpen_frag =
18 | #include "ccFilterShader_sharpen_frag.h"
19 |
20 | const GLchar * ccFilterShader_rgb_frag =
21 | #include "ccFilterShader_rgb_frag.h"
22 |
23 | const GLchar * ccFilterShader_brightness_frag =
24 | #include "ccFilterShader_brightness_frag.h"
25 |
26 | const GLchar * ccFilterShader_exposure_frag =
27 | #include "ccFilterShader_exposure_frag.h"
28 |
29 | const GLchar * ccFilterShader_contrast_frag =
30 | #include "ccFilterShader_contrast_frag.h"
31 |
32 | const GLchar * ccFilterShader_saturation_frag =
33 | #include "ccFilterShader_saturation_frag.h"
34 |
35 | const GLchar * ccFilterShader_gamma_frag =
36 | #include "ccFilterShader_gamma_frag.h"
37 |
38 | const GLchar * ccFilterShader_hue_frag =
39 | #include "ccFilterShader_hue_frag.h"
40 |
41 | const GLchar * ccFilterShader_haze_frag =
42 | #include "ccFilterShader_haze_frag.h"
43 |
44 | const GLchar * ccFilterShader_zoom_blur_frag =
45 | #include "ccFilterShader_zoom_blur_frag.h"
46 |
47 | const GLchar * ccFilterShader_motion_blur_vert =
48 | #include "ccFilterShader_motion_blur_vert.h"
49 | const GLchar * ccFilterShader_motion_blur_frag =
50 | #include "ccFilterShader_motion_blur_frag.h"
51 |
52 | const GLchar * ccFilterShader_drop_shadow_vert =
53 | #include "ccFilterShader_drop_shadow_vert.h"
54 | const GLchar * ccFilterShader_drop_shadow_frag =
55 | #include "ccFilterShader_drop_shadow_frag.h"
56 |
57 | const GLchar * ccFilterShader_sepia_frag =
58 | #include "ccFilterShader_sepia_frag.h"
59 |
60 | const GLchar * ccFilterShader_test_vert =
61 | #include "ccFilterShader_test_vert.h"
62 | const GLchar * ccFilterShader_test_frag =
63 | #include "ccFilterShader_test_frag.h"
64 |
65 | //==============================
66 | //
67 | const GLchar * ccFilterShader_gaussian_hblur_frag =
68 | #include "ccFilterShader_gaussian_hblur_frag.h"
69 | const GLchar * ccFilterShader_gaussian_vblur_frag =
70 | #include "ccFilterShader_gaussian_vblur_frag.h"
71 |
72 | const GLchar * ccFilterShader_colorramp_frag =
73 | #include "ccFilterShader_colorramp_frag.h"
74 |
75 | const GLchar * ccFilterShader_emboss_frag =
76 | #include "ccFilterShader_emboss_frag.h"
77 |
78 | const GLchar * ccFilterShader_embossmov_frag =
79 | #include "ccFilterShader_embossmov_frag.h"
80 |
81 | const GLchar * ccFilterShader_grass_frag =
82 | #include "ccFilterShader_grass_frag.h"
83 |
84 | NS_CC_EXT_END
--------------------------------------------------------------------------------
/filters/shaders/example_Blur.fsh:
--------------------------------------------------------------------------------
1 | const GLchar* FilterShader_blur_frag = STRINGIFY(
2 |
3 | \n#ifdef GL_ES\n
4 | precision mediump float;
5 | \n#endif\n
6 |
7 | varying vec4 v_fragmentColor;
8 | varying vec2 v_texCoord;
9 |
10 | uniform vec2 resolution;
11 | uniform float blurRadius;
12 | uniform float sampleNum;
13 |
14 | vec3 blur(vec2);
15 |
16 | void main(void)
17 | {
18 | vec3 col = blur(v_texCoord);
19 | gl_FragColor = vec4(col, 1.0) * v_fragmentColor;
20 | }
21 |
22 | vec3 blur(vec2 p)
23 | {
24 | if (blurRadius > 0.0 && sampleNum > 1.0)
25 | {
26 | vec3 col = vec3(0);
27 | vec2 unit = 1.0 / resolution.xy;
28 |
29 | float r = blurRadius;
30 | float sampleStep = r / sampleNum;
31 |
32 | float count = 0.0;
33 |
34 | for(float x = -r; x < r; x += sampleStep)
35 | {
36 | for(float y = -r; y < r; y += sampleStep)
37 | {
38 | float weight = (r - abs(x)) * (r - abs(y));
39 | col += texture2D(CC_Texture0, p + vec2(x * unit.x, y * unit.y)).rgb * weight;
40 | count += weight;
41 | }
42 | }
43 |
44 | return col / count;
45 | }
46 |
47 | return texture2D(CC_Texture0, p).rgb;
48 | }
49 |
50 | );
51 |
--------------------------------------------------------------------------------
/filters/shaders/example_ColorBars.fsh:
--------------------------------------------------------------------------------
1 | // http://www.cocos2d-iphone.org
2 |
3 | #ifdef GL_ES
4 | precision lowp float;
5 | #endif
6 |
7 | varying vec2 v_texCoord;
8 |
9 | vec4 getColorByCoord(int y){
10 | if(y < 5){
11 | if(y == 0){
12 | return vec4(1,0,0,1);
13 | } else if(y == 1){
14 | return vec4(0,1,0,1);
15 | } else if(y == 2){
16 | return vec4(0,0,1,1);
17 | } else if(y == 3){
18 | return vec4(0,1,1,1);
19 | } else{
20 | return vec4(1,0,1,1);
21 | }
22 | } else {
23 | if(y == 5){
24 | return vec4(1,1,0,1);
25 | } else if(y == 6){
26 | return vec4(1,1,1,1);
27 | } else if(y == 7){
28 | return vec4(1,0.5,0,1);
29 | } else if(y == 8){
30 | return vec4(1,0.5,0.5,1);
31 | }else {
32 | return vec4(0.5,0.5,1,1);
33 | }
34 | }
35 | }
36 |
37 | void main(void) {
38 | // inline to prevent "float" loss and keep using lowp
39 | //int y = int( mod(( (gl_FragCoord.y+gl_FragCoord.x)*mod(CC_Time[0],5.0)) / 10.0, 10.0 ) );
40 | //int y = int( mod( CC_Time[3] + (gl_FragCoord.y + gl_FragCoord.x) / 10.0, 10.0 ) );
41 | int y = int( mod(gl_FragCoord.y / 10.0, 10.0 ) );
42 | gl_FragColor = getColorByCoord(y) * texture2D(CC_Texture0, v_texCoord);
43 | }
44 |
--------------------------------------------------------------------------------
/filters/shaders/example_ColorBars.vsh:
--------------------------------------------------------------------------------
1 | // http://www.cocos2d-iphone.org
2 |
3 | attribute vec4 a_position;
4 | attribute vec2 a_texCoord;
5 |
6 | #ifdef GL_ES
7 | varying mediump vec2 v_texCoord;
8 | #else
9 | varying vec2 v_texCoord;
10 | #endif
11 |
12 | void main()
13 | {
14 | //gl_Position = CC_MVPMatrix * a_position;
15 | gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;
16 | v_texCoord = a_texCoord;
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/filters/shaders/example_Flower.fsh:
--------------------------------------------------------------------------------
1 | // Shader from http://www.iquilezles.org/apps/shadertoy/
2 |
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | uniform vec2 center;
8 | uniform vec2 resolution;
9 |
10 | //float u( float x ) { return 0.5+0.5*sign(x); }
11 | float u( float x ) { return (x>0.0)?1.0:0.0; }
12 | //float u( float x ) { return abs(x)/x; }
13 |
14 | void main(void)
15 | {
16 | float time = CC_Time[1];
17 | vec2 p = 2.0 * (gl_FragCoord.xy - center.xy) / resolution.xy;
18 |
19 | float a = atan(p.x,p.y);
20 | float r = length(p)*.75;
21 |
22 | float w = cos(3.1415927*time-r*2.0);
23 | float h = 0.5+0.5*cos(12.0*a-w*7.0+r*8.0);
24 | float d = 0.25+0.75*pow(h,1.0*r)*(0.7+0.3*w);
25 |
26 | float col = u( d-r ) * sqrt(1.0-r/d)*r*2.5;
27 | col *= 1.25+0.25*cos((12.0*a-w*7.0+r*8.0)/2.0);
28 | col *= 1.0 - 0.35*(0.5+0.5*sin(r*30.0))*(0.5+0.5*cos(12.0*a-w*7.0+r*8.0));
29 | gl_FragColor = vec4(
30 | col,
31 | col-h*0.5+r*.2 + 0.35*h*(1.0-r),
32 | col-h*r + 0.1*h*(1.0-r),
33 | 1.0);
34 | }
--------------------------------------------------------------------------------
/filters/shaders/example_Heart.fsh:
--------------------------------------------------------------------------------
1 | // Shader from http://www.iquilezles.org/apps/shadertoy/
2 |
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | uniform vec2 center;
8 | uniform vec2 resolution;
9 |
10 | void main(void)
11 | {
12 | float time = CC_Time[1];
13 | vec2 p = 2.0 * (gl_FragCoord.xy - center.xy) / resolution.xy;
14 |
15 | // animate
16 | float tt = mod(time,2.0)/2.0;
17 | float ss = pow(tt,.2)*0.5 + 0.5;
18 | ss -= ss*0.2*sin(tt*6.2831*5.0)*exp(-tt*6.0);
19 | p *= vec2(0.5,1.5) + ss*vec2(0.5,-0.5);
20 |
21 |
22 | float a = atan(p.x,p.y)/3.141593;
23 | float r = length(p);
24 |
25 | // shape
26 | float h = abs(a);
27 | float d = (13.0*h - 22.0*h*h + 10.0*h*h*h)/(6.0-5.0*h);
28 |
29 | // color
30 | float f = step(r,d) * pow(1.0-r/d,0.25);
31 |
32 | gl_FragColor = vec4(f,0.0,0.0,1.0);
33 | }
--------------------------------------------------------------------------------
/filters/shaders/example_HorizontalColor.fsh:
--------------------------------------------------------------------------------
1 | // http://www.cocos2d-iphone.org
2 |
3 | #ifdef GL_ES
4 | precision lowp float;
5 | #endif
6 |
7 | varying vec2 v_texCoord;
8 |
9 | vec4 colors[10];
10 |
11 | void main(void)
12 | {
13 | colors[0] = vec4(1,0,0,1);
14 | colors[1] = vec4(0,1,0,1);
15 | colors[2] = vec4(0,0,1,1);
16 | colors[3] = vec4(0,1,1,1);
17 | colors[4] = vec4(1,0,1,1);
18 | colors[5] = vec4(1,1,0,1);
19 | colors[6] = vec4(1,1,1,1);
20 | colors[7] = vec4(1,0.5,0,1);
21 | colors[8] = vec4(1,0.5,0.5,1);
22 | colors[9] = vec4(0.5,0.5,1,1);
23 |
24 | // inline to prevent "float" loss and keep using lowp
25 | int y = int( mod(gl_FragCoord.y / 3.0, 10.0 ) );
26 | gl_FragColor = colors[y] * texture2D(CC_Texture0, v_texCoord);
27 | }
--------------------------------------------------------------------------------
/filters/shaders/example_Julia.fsh:
--------------------------------------------------------------------------------
1 | // Shader from http://www.iquilezles.org/apps/shadertoy/
2 |
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | uniform vec2 center;
8 | uniform vec2 resolution;
9 |
10 | void main(void)
11 | {
12 | float time = CC_Time[1];
13 | vec2 p = 2.0 * (gl_FragCoord.xy - center.xy) / resolution.xy;
14 | vec2 cc = vec2( cos(.25*time), sin(.25*time*1.423) );
15 |
16 | float dmin = 1000.0;
17 | vec2 z = p*vec2(1.33,1.0);
18 | for( int i=0; i<64; i++ )
19 | {
20 | z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
21 | float m2 = dot(z,z);
22 | if( m2>100.0 ) break;
23 | dmin=min(dmin,m2);
24 | }
25 |
26 | float color = sqrt(sqrt(dmin))*0.7;
27 | gl_FragColor = vec4(color,color,color,1.0);
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/filters/shaders/example_Mandelbrot.fsh:
--------------------------------------------------------------------------------
1 | // Shader from http://www.iquilezles.org/apps/shadertoy/
2 |
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | uniform vec2 center;
8 | uniform vec2 resolution;
9 |
10 | void main(void)
11 | {
12 | vec2 p = 2.0 * (gl_FragCoord.xy - center.xy) / resolution.xy;
13 | p.x *= resolution.x/resolution.y;
14 |
15 | float zoo = .62+.38*sin(.1*CC_Time[1]);
16 | float coa = cos( 0.1*(1.0-zoo)*CC_Time[1] );
17 | float sia = sin( 0.1*(1.0-zoo)*CC_Time[1] );
18 | zoo = pow( zoo,8.0);
19 | vec2 xy = vec2( p.x*coa-p.y*sia, p.x*sia+p.y*coa);
20 | vec2 cc = vec2(-.745,.186) + xy*zoo;
21 |
22 | vec2 z = vec2(0.0);
23 | vec2 z2 = z*z;
24 | float m2;
25 | float co = 0.0;
26 |
27 | for( int i=0; i<256; i++ )
28 | {
29 | z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
30 | m2 = dot(z,z);
31 | if( m2>1024.0 ) break;
32 | co += 1.0;
33 | }
34 | co = co + 1.0 - log2(.5*log2(m2));
35 |
36 | co = sqrt(co/256.0);
37 | gl_FragColor = vec4( .5+.5*cos(6.2831*co+0.0),
38 | .5+.5*cos(6.2831*co+0.4),
39 | .5+.5*cos(6.2831*co+0.7),
40 | 1.0 );
41 | }
--------------------------------------------------------------------------------
/filters/shaders/example_Monjori.fsh:
--------------------------------------------------------------------------------
1 | // Shader from http://www.iquilezles.org/apps/shadertoy/
2 |
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | uniform vec2 center;
8 | uniform vec2 resolution;
9 |
10 | void main(void)
11 | {
12 | vec2 p = 2.0 * (gl_FragCoord.xy - center.xy) / resolution.xy;
13 | float a = CC_Time[1]*40.0;
14 | float d,e,f,g=1.0/40.0,h,i,r,q;
15 | e=400.0*(p.x*0.5+0.5);
16 | f=400.0*(p.y*0.5+0.5);
17 | i=200.0+sin(e*g+a/150.0)*20.0;
18 | d=200.0+cos(f*g/2.0)*18.0+cos(e*g)*7.0;
19 | r=sqrt(pow(i-e,2.0)+pow(d-f,2.0));
20 | q=f/r;
21 | e=(r*cos(q))-a/2.0;f=(r*sin(q))-a/2.0;
22 | d=sin(e*g)*176.0+sin(e*g)*164.0+r;
23 | h=((f+d)+a/2.0)*g;
24 | i=cos(h+r*p.x/1.3)*(e+e+a)+cos(q*g*6.0)*(r+h/3.0);
25 | h=sin(f*g)*144.0-sin(e*g)*212.0*p.x;
26 | h=(h+(f-e)*q+sin(r-(a+h)/7.0)*10.0+i/4.0)*g;
27 | i+=cos(h*2.3*sin(a/350.0-q))*184.0*sin(q-(r*4.3+a/12.0)*g)+tan(r*g+h)*184.0*cos(r*g+h);
28 | i=mod(i/5.6,256.0)/64.0;
29 | if(i<0.0) i+=4.0;
30 | if(i>=2.0) i=4.0-i;
31 | d=r/350.0;
32 | d+=sin(d*d*8.0)*0.52;
33 | f=(sin(a*g)+1.0)/2.0;
34 | gl_FragColor=vec4(vec3(f*i/1.6,i/2.0+d/13.0,i)*d*p.x+vec3(i/1.3+d/8.0,i/2.0+d/18.0,i)*d*(1.0-p.x),1.0);
35 | }
36 |
--------------------------------------------------------------------------------
/filters/shaders/example_MultiTexture.fsh:
--------------------------------------------------------------------------------
1 |
2 | #ifdef GL_ES
3 | precision mediump float;
4 | #endif
5 |
6 | varying vec4 v_fragmentColor;
7 | varying vec2 v_texCoord;
8 |
9 | uniform sampler2D u_texture1;
10 | uniform float u_interpolate;
11 |
12 | void main() {
13 | vec4 color1 = texture2D(CC_Texture0, v_texCoord);
14 | vec4 color2 = texture2D(u_texture1, v_texCoord);
15 | gl_FragColor = v_fragmentColor * mix( color1, color2, u_interpolate);
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/filters/shaders/example_MultiTexture.vsh:
--------------------------------------------------------------------------------
1 |
2 | attribute vec4 a_position;
3 | attribute vec2 a_texCoord;
4 | attribute vec4 a_color;
5 |
6 | #ifdef GL_ES
7 | varying lowp vec4 v_fragmentColor;
8 | varying mediump vec2 v_texCoord;
9 | #else
10 | varying vec4 v_fragmentColor;
11 | varying vec2 v_texCoord;
12 | #endif
13 |
14 | void main()
15 | {
16 | gl_Position = CC_PMatrix * a_position;
17 | v_fragmentColor = a_color;
18 | v_texCoord = a_texCoord;
19 | }
20 |
--------------------------------------------------------------------------------
/filters/shaders/example_Noisy.fsh:
--------------------------------------------------------------------------------
1 | // Shader taken from: http://webglsamples.googlecode.com/hg/electricflower/electricflower.html
2 |
3 | const GLchar * FilterShader_noisy_frag = STRINGIFY(
4 |
5 | \n#ifdef GL_ES\n
6 | precision mediump float;
7 | \n#endif\n
8 |
9 | varying vec4 v_fragmentColor;
10 | varying vec2 v_texCoord;
11 |
12 | uniform vec2 resolution;
13 |
14 | const float intensity = 0.05;
15 | vec3 noise(vec2 uv)
16 | {
17 | vec2 p = abs(sin(uv * 13.0 + uv.x * CC_Time[1] * sin(uv.y)));
18 |
19 | return vec3(sin (0.2 * CC_Time[1] + sin(p * 0.5) * CC_Time[1] / cos(50.0)) * 10.0,0.3+0.5 * abs(sin(CC_Time[1] * tan(5.0))));
20 |
21 | }
22 |
23 | void main(void)
24 | {
25 | gl_FragColor.xyz = intensity * noise(gl_FragCoord.xy / sin(resolution.xy * CC_Time[1] * 0.01)) + (1. - intensity) *
26 | texture2D(CC_Texture0,v_texCoord.xy).xyz;
27 | gl_FragColor.w = 1.;
28 | }
29 |
30 | );
31 |
--------------------------------------------------------------------------------
/filters/shaders/example_Plasma.fsh:
--------------------------------------------------------------------------------
1 | // Shader from http://www.iquilezles.org/apps/shadertoy/
2 |
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | uniform vec2 center;
8 | uniform vec2 resolution;
9 |
10 | void main(void)
11 | {
12 | float time = CC_Time[1];
13 | float x = gl_FragCoord.x - (center.x - resolution.x / 2.0);
14 | float y = gl_FragCoord.y - (center.y - resolution.y / 2.0);
15 | float mov0 = x+y+cos(sin(time)*2.)*100.+sin(x/100.)*1000.;
16 | float mov1 = y / resolution.y / 0.2 + time;
17 | float mov2 = x / resolution.x / 0.2;
18 | float c1 = abs(sin(mov1+time)/2.+mov2/2.-mov1-mov2+time);
19 | float c2 = abs(sin(c1+sin(mov0/1000.+time)+sin(y/40.+time)+sin((x+y)/100.)*3.));
20 | float c3 = abs(sin(c2+cos(mov1+mov2+c2)+cos(mov2)+sin(x/1000.)));
21 | gl_FragColor = vec4( c1,c2,c3,1.0);
22 | }
23 |
--------------------------------------------------------------------------------
/filters/shaders/example_Twist.fsh:
--------------------------------------------------------------------------------
1 | // Shader from here: http://www.iquilezles.org/
2 |
3 | #ifdef GL_ES
4 | precision highp float;
5 | #endif
6 |
7 | uniform vec2 resolution;
8 | uniform sampler2D tex0;
9 | uniform sampler2D tex1;
10 |
11 | void main(void)
12 | {
13 | float time = CC_Time[1];
14 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
15 | vec2 uv;
16 |
17 | float a = atan(p.y,p.x);
18 | float r = sqrt(dot(p,p));
19 |
20 | uv.x = r - CC_Time[2];
21 | uv.y = sin(a*10.0 + 2.0*CC_CosTime[0];
22 |
23 | vec3 col = (.5+.5*uv.y)*texture2D(tex0,uv).xyz;
24 |
25 | gl_FragColor = vec4(col,1.0);
26 | }
--------------------------------------------------------------------------------
/filters/shaders/example_bloom.fsh:
--------------------------------------------------------------------------------
1 | const GLchar* FilterShader_bloom_frag = STRINGIFY(
2 |
3 | \n#ifdef GL_ES\n
4 | precision mediump float;
5 | \n#endif\n
6 |
7 | varying vec4 v_fragmentColor;
8 | varying vec2 v_texCoord;
9 |
10 | const float blurSize = 1.0/512.0;
11 | const float intensity = 0.35;
12 | void main()
13 | {
14 | vec4 sum = vec4(0);
15 | vec2 texcoord = v_texCoord.xy;
16 | int j;
17 | int i;
18 |
19 | //thank you! http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ for the
20 | //blur tutorial
21 | // blur in y (vertical)
22 | // take nine samples, with the distance blurSize between them
23 | sum += texture2D(CC_Texture0, vec2(texcoord.x - 4.0*blurSize, texcoord.y)) * 0.05;
24 | sum += texture2D(CC_Texture0, vec2(texcoord.x - 3.0*blurSize, texcoord.y)) * 0.09;
25 | sum += texture2D(CC_Texture0, vec2(texcoord.x - 2.0*blurSize, texcoord.y)) * 0.12;
26 | sum += texture2D(CC_Texture0, vec2(texcoord.x - blurSize, texcoord.y)) * 0.15;
27 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y)) * 0.16;
28 | sum += texture2D(CC_Texture0, vec2(texcoord.x + blurSize, texcoord.y)) * 0.15;
29 | sum += texture2D(CC_Texture0, vec2(texcoord.x + 2.0*blurSize, texcoord.y)) * 0.12;
30 | sum += texture2D(CC_Texture0, vec2(texcoord.x + 3.0*blurSize, texcoord.y)) * 0.09;
31 | sum += texture2D(CC_Texture0, vec2(texcoord.x + 4.0*blurSize, texcoord.y)) * 0.05;
32 |
33 | // blur in y (vertical)
34 | // take nine samples, with the distance blurSize between them
35 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y - 4.0*blurSize)) * 0.05;
36 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y - 3.0*blurSize)) * 0.09;
37 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y - 2.0*blurSize)) * 0.12;
38 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y - blurSize)) * 0.15;
39 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y)) * 0.16;
40 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y + blurSize)) * 0.15;
41 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y + 2.0*blurSize)) * 0.12;
42 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y + 3.0*blurSize)) * 0.09;
43 | sum += texture2D(CC_Texture0, vec2(texcoord.x, texcoord.y + 4.0*blurSize)) * 0.05;
44 |
45 | //increase blur with intensity!
46 | gl_FragColor = sum*intensity + texture2D(CC_Texture0, texcoord);
47 | return;
48 | /*if(sin(iGlobalTime) > 0.0)
49 | gl_FragColor = sum * sin(iGlobalTime)+ texture2D(iChannel0, texcoord);
50 | else
51 | gl_FragColor = sum * -sin(iGlobalTime)+ texture2D(iChannel0, texcoord);
52 | */
53 | }
54 |
55 | );
56 |
--------------------------------------------------------------------------------
/filters/shaders/example_celShading.fsh:
--------------------------------------------------------------------------------
1 | const GLchar * FilterShader_celshading_frag = STRINGIFY(
2 |
3 | \n#ifdef GL_ES\n
4 | precision mediump float;
5 | \n#endif\n
6 |
7 | varying vec4 v_fragmentColor;
8 | varying vec2 v_texCoord;
9 |
10 | uniform vec2 resolution;
11 |
12 | \n#define FILTER_SIZE 3\n
13 | \n#define COLOR_LEVELS 7.0\n
14 | \n#define EDGE_FILTER_SIZE 3\n
15 | \n#define EDGE_THRESHOLD 0.05\n
16 |
17 | vec4 edgeFilter(in int px, in int py)
18 | {
19 | vec4 color = vec4(0.0);
20 |
21 | for (int y = -EDGE_FILTER_SIZE; y <= EDGE_FILTER_SIZE; ++y)
22 | {
23 | for (int x = -EDGE_FILTER_SIZE; x <= EDGE_FILTER_SIZE; ++x)
24 | {
25 | color += texture2D(CC_Texture0, v_texCoord + vec2(px + x, py + y) / resolution.xy);
26 | }
27 | }
28 |
29 | color /= float((2 * EDGE_FILTER_SIZE + 1) * (2 * EDGE_FILTER_SIZE + 1));
30 |
31 | return color;
32 | }
33 |
34 | void main(void)
35 | {
36 | // Shade
37 | vec4 color = vec4(0.0);
38 |
39 | for (int y = -FILTER_SIZE; y <= FILTER_SIZE; ++y)
40 | {
41 | for (int x = -FILTER_SIZE; x <= FILTER_SIZE; ++x)
42 | {
43 | color += texture2D(CC_Texture0, v_texCoord + vec2(x, y) / resolution.xy);
44 | }
45 | }
46 |
47 | color /= float((2 * FILTER_SIZE + 1) * (2 * FILTER_SIZE + 1));
48 |
49 | for (int c = 0; c < 3; ++c)
50 | {
51 | color[c] = floor(COLOR_LEVELS * color[c]) / COLOR_LEVELS;
52 | }
53 |
54 | // Highlight edges
55 | vec4 sum = abs(edgeFilter(0, 1) - edgeFilter(0, -1));
56 | sum += abs(edgeFilter(1, 0) - edgeFilter(-1, 0));
57 | sum /= 2.0;
58 |
59 | if (length(sum) > EDGE_THRESHOLD)
60 | {
61 | color.rgb = vec3(0.0);
62 | }
63 |
64 | gl_FragColor = color;
65 | }
66 |
67 | );
68 |
--------------------------------------------------------------------------------
/filters/shaders/example_edgeDetection.fsh:
--------------------------------------------------------------------------------
1 |
2 | const GLchar * FilterShader_edgedetection_frag = STRINGIFY(
3 |
4 | \n#ifdef GL_ES\n
5 | precision mediump float;
6 | \n#endif\n
7 |
8 | varying vec4 v_fragmentColor;
9 | varying vec2 v_texCoord;
10 |
11 | uniform vec2 resolution;
12 |
13 | float lookup(vec2 p, float dx, float dy)
14 | {
15 | vec2 uv = p.xy + vec2(dx , dy ) / resolution.xy;
16 | vec4 c = texture2D(CC_Texture0, uv.xy);
17 | return 0.2126*c.r + 0.7152*c.g + 0.0722*c.b;
18 | }
19 |
20 | void main(void)
21 | {
22 | vec2 p = v_texCoord.xy;
23 | // simple sobel edge detection
24 | float gx = 0.0;
25 | gx += -1.0 * lookup(p, -1.0, -1.0);
26 | gx += -2.0 * lookup(p, -1.0, 0.0);
27 | gx += -1.0 * lookup(p, -1.0, 1.0);
28 | gx += 1.0 * lookup(p, 1.0, -1.0);
29 | gx += 2.0 * lookup(p, 1.0, 0.0);
30 | gx += 1.0 * lookup(p, 1.0, 1.0);
31 |
32 | float gy = 0.0;
33 | gy += -1.0 * lookup(p, -1.0, -1.0);
34 | gy += -2.0 * lookup(p, 0.0, -1.0);
35 | gy += -1.0 * lookup(p, 1.0, -1.0);
36 | gy += 1.0 * lookup(p, -1.0, 1.0);
37 | gy += 2.0 * lookup(p, 0.0, 1.0);
38 | gy += 1.0 * lookup(p, 1.0, 1.0);
39 |
40 | float g = gx*gx + gy*gy;
41 |
42 | gl_FragColor.xyz = vec3(1.-g);
43 | gl_FragColor.w = 1.;
44 | }
45 |
46 | );
47 |
--------------------------------------------------------------------------------
/filters/shaders/example_greyScale.fsh:
--------------------------------------------------------------------------------
1 |
2 | const GLchar * FilterShader_greyscale_frag = STRINGIFY(
3 |
4 | \n#ifdef GL_ES\n
5 | precision mediump float;
6 | \n#endif\n
7 |
8 | varying vec4 v_fragmentColor;
9 | varying vec2 v_texCoord;
10 |
11 | void main(void)
12 | {
13 | vec4 c = texture2D(CC_Texture0, v_texCoord);
14 | gl_FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b);
15 | gl_FragColor.w = c.w;
16 | }
17 |
18 | );
--------------------------------------------------------------------------------
/filters/shaders/example_normal.fsh:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | #endif
4 |
5 | varying vec4 v_fragmentColor;
6 | varying vec2 v_texCoord;
7 |
8 | void main(void)
9 | {
10 | gl_FragColor = texture2D(CC_Texture0, v_texCoord);
11 | }
--------------------------------------------------------------------------------
/filters/shaders/example_outline.fsh:
--------------------------------------------------------------------------------
1 | /*
2 | Created by guanghui on 4/8/14.
3 | http://www.idevgames.com/forums/thread-3010.html
4 | */
5 |
6 | const GLchar * FilterShader_outline_frag = STRINGIFY(
7 |
8 | varying vec2 v_texCoord;
9 | varying vec4 v_fragmentColor;
10 |
11 | uniform vec3 u_outlineColor;
12 | uniform float u_threshold;
13 | uniform float u_radius;
14 |
15 | void main()
16 | {
17 | float radius = u_radius;
18 | vec4 accum = vec4(0.0);
19 | vec4 normal = vec4(0.0);
20 |
21 | normal = texture2D(CC_Texture0, vec2(v_texCoord.x, v_texCoord.y));
22 |
23 | accum += texture2D(CC_Texture0, vec2(v_texCoord.x - radius, v_texCoord.y - radius));
24 | accum += texture2D(CC_Texture0, vec2(v_texCoord.x + radius, v_texCoord.y - radius));
25 | accum += texture2D(CC_Texture0, vec2(v_texCoord.x + radius, v_texCoord.y + radius));
26 | accum += texture2D(CC_Texture0, vec2(v_texCoord.x - radius, v_texCoord.y + radius));
27 |
28 | accum *= u_threshold;
29 | accum.rgb = u_outlineColor * accum.a;
30 | accum.a = 1.0;
31 |
32 | normal = ( accum * (1.0 - normal.a)) + (normal * normal.a);
33 |
34 | gl_FragColor = v_fragmentColor * normal;
35 | }
36 |
37 | );
38 |
--------------------------------------------------------------------------------
/filters/shaders/example_sepia.fsh:
--------------------------------------------------------------------------------
1 |
2 | const GLchar * FilterShader_sepia_frag = STRINGIFY(
3 |
4 | \n#ifdef GL_ES\n
5 | precision mediump float;
6 | \n#endif\n
7 |
8 | varying vec4 v_fragmentColor;
9 | varying vec2 v_texCoord;
10 |
11 | void main(void)
12 | {
13 | vec4 c = texture2D(CC_Texture0, v_texCoord);
14 | vec4 final = c;
15 | final.r = (c.r * 0.393) + (c.g * 0.769) + (c.b * 0.189);
16 | final.g = (c.r * 0.349) + (c.g * 0.686) + (c.b * 0.168);
17 | final.b = (c.r * 0.272) + (c.g * 0.534) + (c.b * 0.131);
18 |
19 | gl_FragColor = final;
20 | }
21 |
22 | );
23 |
--------------------------------------------------------------------------------
/filters/shaders/shadertoy_FireBall.fsh:
--------------------------------------------------------------------------------
1 |
2 | uniform vec2 center;
3 | uniform vec2 resolution;
4 |
5 | vec2 iCenter = center;
6 | vec2 iResolution = resolution; // viewport resolution (in pixels)
7 | float iGlobalTime = CC_Time[1]; // shader playback time (in seconds)
8 | //uniform float iChannelTime[4]; // channel playback time (in seconds)
9 | //uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
10 | vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down),
11 |
12 |
13 |
14 | float snoise(vec3 uv, float res)
15 | {
16 | const vec3 s = vec3(1e0, 1e2, 1e4);
17 |
18 | uv *= res;
19 |
20 | vec3 uv0 = floor(mod(uv, res))*s;
21 | vec3 uv1 = floor(mod(uv+vec3(1.), res))*s;
22 |
23 | vec3 f = fract(uv); f = f*f*(3.0-2.0*f);
24 |
25 | vec4 v = vec4(uv0.x+uv0.y+uv0.z, uv1.x+uv0.y+uv0.z,
26 | uv0.x+uv1.y+uv0.z, uv1.x+uv1.y+uv0.z);
27 |
28 | vec4 r = fract(sin(v*1e-3)*1e5);
29 | float r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
30 |
31 | r = fract(sin((v + uv1.z - uv0.z)*1e-3)*1e5);
32 | float r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
33 |
34 | return mix(r0, r1, f.z)*2.-1.;
35 | }
36 |
37 | void main(void)
38 | {
39 | //vec2 p = -.5 + gl_FragCoord.xy / iResolution.xy;
40 |
41 | vec2 p = (gl_FragCoord.xy - center.xy) / iResolution.xy;
42 | p.x *= iResolution.x/iResolution.y;
43 |
44 | float color = 3.0 - (3.*length(2.*p));
45 |
46 | vec3 coord = vec3(atan(p.x,p.y)/6.2832+.5, length(p)*.4, .5);
47 |
48 | for(int i = 1; i <= 3; i++)
49 | {
50 | float power = pow(2.0, float(i));
51 | color += (1.5 / power) * snoise(coord + vec3(0.,-iGlobalTime*.05, iGlobalTime*.01), power*16.);
52 | }
53 | gl_FragColor = vec4( color, pow(max(color,0.),2.)*0.4, pow(max(color,0.),3.)*0.15 , 1.0);
54 | }
55 |
56 |
--------------------------------------------------------------------------------