当前位置:网站首页>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);
}
边栏推荐
- MySql创建数据表
- On the side of Ali, tell me what are the application scenarios of message middleware you know?
- UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
- 【windows】--- SQL Server 2008 超详细安装教程
- 理解js运算符
- How MySQL - depots table?A look at will understand
- flutter arr 依赖
- 【Elastic-Job】分布式调度任务概览篇
- 为什么redis是单线程还那么快?
- First acquaintance with Flask
猜你喜欢

【云原生】开源数据分析 SPL 轻松应对 T+0

MySQL compressed package installation, fool teaching

常见JVM面试题及答案整理

UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装

通信原理——纠错编码 | 汉明码(海明码)手算详解

Install mysqldb in mac10.14

Access数据库的查询

How MySQL - depots table?A look at will understand

NFTs: The Heart of Digital Ownership

Year-end summary - the years are quiet~
随机推荐
Attribute Changer的几种形态
代码执行漏洞
【Elastic-Job源码分析】——作业监听器
Yuan prospect and four track of the universe
[swagger close] The production environment closes the swagger method
MySql创建数据表
mac10.14中安装mysqldb
MySQL高级学习笔记
[Cloud native] Simple introduction and use of microservice Nacos
2021年京东数据分析工程师秋招笔试编程题
【ubuntu20.04安装MySQL以及MySQL-workbench可视化工具】
On the side of Ali, tell me what are the application scenarios of message middleware you know?
C language tutorial (1) - preparation
【云原生】开源数据分析 SPL 轻松应对 T+0
What is the difference between NFT and digital collection?
[Cloud native] Ribbon is no longer used at the bottom layer of OpenFeign starting from the 2020.0.X version
DeFi Token in the project management
MySQL面试题大全(陆续更新)
DeFi 项目中的治理Token
数字孪生将成为进入“元宇宙”一项重要的途径