当前位置:网站首页>cocos2d-x-3.2图片灰化效果
cocos2d-x-3.2图片灰化效果
2022-07-31 05:15:00 【xuyid】
//染灰色
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 using NTSC 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);
}
边栏推荐
猜你喜欢
Common JVM interview questions and answers
Digital twins will be an important way to enter the "metaverse"
Artifact SSMwar exploded Error deploying artifact.See server log for details
Access数据库的查询
feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
局部变量成员变量、引用类型、this,static(第五天)
How MySQL - depots table?A look at will understand
On the side of Ali, tell me what are the application scenarios of message middleware you know?
MySql to create data tables
NFTs: The Heart of Digital Ownership
随机推荐
"limit" query in Oracle database
Artifact SSMwar exploded Error deploying artifact.See server log for details
小白学爬虫——爬虫入门
【uiautomation】微信好友列表获取(存储到txt中)
sqlmap injection tutorial common commands
sqlmap注入教程 常用指令
[Cloud native] Simple introduction and use of microservice Nacos
(Crypto必备干货)详细分析目前NFT的几大交易市场
Access database query
C language tutorial (3) - if and loop
【云原生】SQL(及存储过程)跑得太慢怎么办?
著名网站msdn.itellyou.cn原理分析
[JVM Loading]---Class Loading Mechanism
Understanding SSRF, this article is enough
计网 Packet Tracer仿真 | 简单易懂集线器和交换机对比(理论+仿真)
The server time zone value ‘й‘ is unrecognized or represents more than one time zone
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
Getting to know regular expressions
在kali上搭建vulhub漏洞靶场