当前位置:网站首页>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);
}
边栏推荐
- ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
- Markdown 帮助文档
- 【云原生】SQL(及存储过程)跑得太慢怎么办?
- sqlmap injection tutorial common commands
- For penetration testing methods where the output point is a timestamp (take Oracle database as an example)
- Understanding SSRF, this article is enough
- The latest MySql installation teaching, very detailed
- Xiaomi mobile phone SMS location service activation failed
- Filter out egrep itself when using ps | egrep
- 5 methods of MySQL paging query
猜你喜欢
MySQL高级学习笔记
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
著名网站msdn.itellyou.cn原理分析
GUCCI, LV and other luxury giant universe how to layout yuan, other brands should keep up with?
【云原生】SQL(及存储过程)跑得太慢怎么办?
VS2017 connects to MYSQL
NFTs: The Heart of Digital Ownership
Install mysqldb in mac10.14
this points to the problem
通信原理——纠错编码 | 汉明码(海明码)手算详解
随机推荐
MySQL分页查询的5种方法
MySQL高级学习笔记
Chinese garbled solution in UTF-8 environment in Powershell
kotlin 插件更新到1.3.21
2021美赛C题M奖思路
sql 外键约束【表关系绑定】
Getting to know regular expressions
Sqlite column A data is copied to column B
The latest MySql installation teaching, very detailed
VS connects to MYSQL through ODBC (1)
Markdown 帮助文档
MySQL高级SQL语句(二)
360 加固 file path not exists.
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?
著名网站msdn.itellyou.cn原理分析
Tencent Cloud Lightweight Server deletes all firewall rules
理解js运算符
configure:error no SDL library found
this points to the problem
The MySQL database in Alibaba Cloud was attacked, and the data was finally recovered