How to use “Opengl Shader” in cocos2d-x3.0
来源:互联网 发布:量化投资编程语言 编辑:程序博客网 时间:2024/05/21 18:35
http://discuss.cocos2d-x.org/t/how-to-use-opengl-shader-in-cocos2d-x3-0/12430
First step:
Add 2 shader files to projects Resource
Second step
bool HelloWorld::init(){ if ( !Layer::init() ) { return false; } ize visibleSize = Director::getInstance()->getVisibleSize(); auto sprite = Sprite::create("HelloWorld.png"); sprite->setAnchorPoint(Point(0.5, 0.5)); sprite->setPosition(Point(visibleSize.width / 3, visibleSize.height / 3)); this->addChild(sprite); graySprite(sprite); return true;}void HelloWorld::graySprite(Sprite * sprite){ if(sprite) { GLProgram * p = new GLProgram(); p->initWithFilenames("gray.vsh", "gray.fsh"); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); p->link(); p->updateUniforms(); sprite->setShaderProgram(p); }}
gray.vsh.zip (0.3 KB)
gray.fsh.zip (330 Bytes)
0 0
- How to use “Opengl Shader” in cocos2d-x3.0
- How to use pthread in cocos2d-x
- How To Use Animations and Sprite Sheets in Cocos2D
- How to use gdi+ in vc6.0
- [备忘]how to use user-provided mentalray shader in Maya?(如何在maya里用自定义mentalray shader)
- How to Use Animations and Sprite Sheets in Cocos2D 2.X
- How to use Serial Port in Windows
- How To Use Macro In Program.
- How to use virt-install in OpenSolaris
- How to use tinyfck in drupal
- How to use Regular Expression in LotusScript
- How to Use PeekMessage() Correctly in Windows
- How to use IMGDECMP.DLL in WindowsCE
- how to use deb files in ubuntu
- How to use Common Navigator in RCP
- How to use SCAT in ECC6
- HOW TO : use DDMS in Ubuntu
- How to use getBodyClass() in magento?
- 关于vs编译后bin下的dll文件重新出现的问题
- Xamarin.iOS Binding Notes about .dylib and clang compiler
- 复合内存管理系统
- 【LeetCode】Min Stack
- CSS垂直居中方法
- How to use “Opengl Shader” in cocos2d-x3.0
- js图片,文字 渐变处理
- linux下包查询
- Provisioning Profiles 文件删除
- GWT MVP 学习笔记
- linux 修改环境变量
- 高手详谈PHP二维数组
- Android 之成长笔记
- MFC-CDC