当前位置:网站首页>openGL_05 Shader的简单应用
openGL_05 Shader的简单应用
2022-06-09 04:15:00 【Hxm5211314】
在 VAO 中启用额外特性
之前我么你在顶点数组中只定义了顶点位置,在后面还可以加上颜色等其他信息,之后规则进行解析即可

解析顶点数据
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);//启用0号顶点属性
解析颜色数据
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(1);//启用1号顶点属性
对于每个顶点来说,位置顶点属性在前,所以它的偏移量是0。颜色属性紧随位置数据之后,所以偏移量就是3 * sizeof(float),用字节来计算就是12字节。

修改着色器


运行:

这样每个顶点都是不一样的颜色了
使用Uniform Uniform是一种从CPU中的应用向GPU中的着色器发送数据的方式

在CPU中进行传值
sin函数让数值在0.0到1.0之间改变,配上当前时间就是一个不断变化的值
如果glGetUniformLocation返回-1就代表没有找到这个位置值

看效果


边栏推荐
猜你喜欢

Golang-- concurrent runtime package

(3)数据绑定指令

Win10安装appium环境

人才缺口50万以上,平均薪资20K?网络安全,测试员的下一个风口~

How is the little red dot that you can't help but click when you see it on the app realized?
![[software tools] [tutorials] a useful tool for exporting CSDN blog articles to word](/img/40/556cd8c4868a93d4cc06a4a945475d.png)
[software tools] [tutorials] a useful tool for exporting CSDN blog articles to word

Iscc-2022-reverse-mobile- part WP

Mysql 查询数据库中哪个表的字段个数最多

Openinfra Foundation launched the "targeted fund" program to promote successful open source governance experience

《Attention-ocr-Chinese-Version-mas # ter》代碼運行邏輯
随机推荐
Test website construction + penetration + audit Part III penetration test of swagger interface
[从零开始学习FPGA编程-14]:快速入门篇 - 操作步骤3(功能仿真)-3-modelsim快速使用入门(8bits循环计数器)
通用泛型 列表 实现map max min
从刚入测试界到薪资翻倍:聊聊我的测试进阶历程,值得借鉴
hisi3559av100,MIPI相机输入接口调试
【6.824分布式系统】LEC 6&7: Fault Tolerance: Raft
big.js、bignumber.js 和 decimal.js 的区别
Golang--- concurrent goroutine
golang---各个类型变量的比较运算
golang---并发runtime包
P5354 [Ynoi2017] 由乃的 OJ(树剖、位运算)
lua 字符串
number-precision--使用/实例
Erreur! Il n'y a pas de texte de style spécifié dans le document. (1)
National information security competition for college students (ciscn) -reverse- recurrence (part)
Rich color changes
View local public IP
举例说明tf中LSTMCell的cell、num_unit是什么意思
[leetcode] day 48 - 1037 Effective boomerang
状态模式模拟电梯运行