当前位置:网站首页>cocos2d-x-3.2 image graying effect
cocos2d-x-3.2 image graying effect
2022-07-31 06:01:00 【xuyid】
//dye grey
void GameTools::GrayShaderProgram(Node * node)
{
do{
const GLchar* pszFragSource =
"#ifdef GL_ES \n\
precision mediump float; \n\
#endif \n\
uniform sampler2D u_texture;\n\
varying vec2 v_texCoord; \n\
varying vec4 v_fragmentColor; \n\
void main(void) \n\
{ \n\
// Convert to greyscale usingNTSC weightings \n\
vec4 col = texture2D(u_texture, v_texCoord); \n\
float grey = dot(col.rgb, vec3(0.299, 0.587, 0.114)); \n\
gl_FragColor= vec4(grey, grey, grey, col.a); \n\
}";
GLProgram* pProgram = new GLProgram();
pProgram->initWithByteArrays(
ccPositionTextureColor_noMVP_vert
, pszFragSource);
node->setGLProgram(pProgram);
pProgram->release();
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->link();
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->updateUniforms();
CHECK_GL_ERROR_DEBUG();
} while (0);
}
边栏推荐
- SSH automatic reconnection script
- Linux modify MySQL database password
- cocos create EditBox 输入文字被刘海屏遮挡修改
- GUCCI, LV and other luxury giant universe how to layout yuan, other brands should keep up with?
- 2021美赛C题M奖思路
- [swagger close] The production environment closes the swagger method
- ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
- MySQL压缩包方式安装,傻瓜式教学
- Chinese garbled solution in UTF-8 environment in Powershell
- kotlin 插件更新到1.3.21
猜你喜欢

Sqlite column A data is copied to column B

Using IIS10 to build an asp website in win11

为什么bash中的read要配合while才能读取/dev/stdin的内容

WeChat applet source code acquisition and decompilation method

Access database query

Fragmented NFT (Fractional NFT)

Principle analysis of famous website msdn.itellyou.cn

场效应管 | N-mos内部结构详解

2021美赛C题M奖思路

腾讯云GPU桌面服务器驱动安装
随机推荐
Chinese garbled solution in UTF-8 environment in Powershell
For penetration testing methods where the output point is a timestamp (take Oracle database as an example)
js中的函数
understand js operators
How MySQL - depots table?A look at will understand
qt:cannot open C:\Users\某某某\AppData\Local\Temp\main.obj.15576.16.jom for write
Android software security and reverse analysis reading notes
Several solutions for mysql startup error The server quit without updating PID file
【云原生】微服务Nacos的简单介绍与使用
Hyper-V新建虚拟机注意事项
通信原理——纠错编码 | 汉明码(海明码)手算详解
The latest MySql installation teaching, very detailed
Sqlite column A data is copied to column B
[Elastic-Job source code analysis] - job listener
小米手机短信定位服务激活失败
SSH自动重连脚本
5 methods of MySQL paging query
flutter arr 依赖
powershell统计文件夹大小
unicloud 发布后小程序提示连接本地调试服务失败,请检查客户端是否和主机在同一局域网下