当前位置:网站首页>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);
}
边栏推荐
- Understanding of objects and functions in js
- Build DVWA with phpstudy
- MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
- SSH automatic reconnection script
- 自定dialog 布局没有居中解决方案
- Powershell中UTF-8环境中文乱码解决办法
- [Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]
- Gradle sync failed: Uninitialized object exists on backward branch 142
- cocos2d-x 实现跨平台的目录遍历
- Judgment of database in SQL injection
猜你喜欢
This in js points to the prototype object
Why does read in bash need to cooperate with while to read the contents of /dev/stdin
[Cloud native] Ribbon is no longer used at the bottom layer of OpenFeign starting from the 2020.0.X version
VS2017 connects to MYSQL
Install mysqldb in mac10.14
qt:cannot open C:\Users\某某某\AppData\Local\Temp\main.obj.15576.16.jom for write
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?
安装Multisim出现 No software will be installed or removed解决方法
[windows]--- SQL Server 2008 super detailed installation tutorial
Eternal blue bug reappears
随机推荐
cocos create EditBox 输入文字被刘海屏遮挡修改
对js的数组的理解
This in js points to the prototype object
mysql常用命令
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
带你搞懂MySQL隔离级别,两个事务同时操作同一行数据会怎样?
break and continue exit in js
【云原生】SQL(及存储过程)跑得太慢怎么办?
[JVM Loading]---Class Loading Mechanism
cocos2d-x-3.2图片灰化效果
powershell统计文件夹大小
MySQL高级语句(一)
工件SSMwar exploded 部署工件时出错。请参阅服务器日志了解详细信息
[uiautomation] Get WeChat friend list (stored in txt)
The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
SSH自动重连脚本
VS2017 connects to MYSQL
cocoscreator 显示刘海内容
this points to the problem
[swagger close] The production environment closes the swagger method