当前位置:网站首页>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);
}
边栏推荐
- 什么是EVM兼容链?
- 数据库 | SQL增删改查基础语法
- On the side of Ali, tell me what are the application scenarios of message middleware you know?
- 自定dialog 布局没有居中解决方案
- mysql password modification method in Linux (pro-test available)
- Detailed explanation of pointers in C language
- vulhub靶场学习日记hackme2
- 对js的数组的理解
- 动态规划(一)| 斐波那契数列和归递
- Why is the redis single-threaded also so fast?
猜你喜欢
随机推荐
What is the difference between NFT and digital collection?
First acquaintance with Flask
Three-party login using wallet Metamask based on web3.0
MySql to create data tables
[uiautomation] Get WeChat friend list (stored in txt)
[swagger close] The production environment closes the swagger method
数据库 | SQL查询进阶语法
sql 添加 default 约束
this指向问题
Build vulhub vulnerability shooting range on kali
DeFi Token in the project management
Digital twins will be an important way to enter the "metaverse"
vulhub靶场学习日记hackme1
MySQL高级学习笔记
SQLite 查询表中每天插入的数量
MySQL高级SQL语句(二)
代码块、Package,Import,封装(第六天)
MySQL-如何分库分表?一看就懂
Several solutions for mysql startup error The server quit without updating PID file
Artifact SSMwar exploded Error deploying artifact.See server log for details