当前位置:网站首页>初识OpenGL (3)片段着色器(Fragment Shader)
初识OpenGL (3)片段着色器(Fragment Shader)
2022-07-26 15:51:00 【thefist11】
step1. 片段着色器
计算像素最后的颜色输出。 片段着色器只需要一个输出变量,这个变量是一个4分量向量,它表示的是最终的输出颜色,我们应该自己将其计算出来。
#version 330 core
out vec4 FragColor;
void main()
{
FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
}
声明输出变量可以使用out关键字,这里我们命名为FragColor。
step2. 编译片段着色器
与顶点着色器类似,使用GL_FRAGMENT_SHADER常量作为着色器类型:
unsigned int fragmentShader;
fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
glCompileShader(fragmentShader);
边栏推荐
- # 工欲善其事必先利其器-C语言拓展--嵌入式C语言(十一)
- Teach the big model to skip the "useless" layer and improve the reasoning speed × 3. The performance remains unchanged, and the new method of Google MIT is popular
- Question collection come and ask nllb authors! (Zhiyuan live issue 24)
- Google Earth engine - merra-2 m2t1nxlv: 1980 present global pressure, temperature, wind and other data sets
- API 版本控制【 Eolink 翻译】
- 2022 what is your sense of security? Volvo asked in the middle of the year
- PS + PL heterogeneous multicore case development manual for Ti C6000 tms320c6678 DSP + zynq-7045 (4)
- [dsctf2022] PWN supplementary question record
- kalibr标定realsenseD435i --多相机标定
- C# 给Word每一页设置不同文字水印
猜你喜欢

Refuse noise, the entry journey of earphone Xiaobai

HaWe screw cartridge check valve RK4

Bucher gear pump qx81-400r301

Zynq PS + PL heterogeneous multicore Case Development Manual of Ti C6000 tms320c6678 DSP + zynq-7045 (1)

单例模式

换把人体工学椅,缓解久坐写代码的老腰吧~
FTP协议

我们被一个 kong 的性能 bug 折腾了一个通宵

gcc/g++与动静库以及gdb

认识JS基础与浏览器引擎
随机推荐
线程和进程
Parker pump pv140r1k1t1pmmc
教大模型自己跳过“无用”层,推理速度×3性能不变,谷歌MIT这个新方法火了...
Daily1:SVM
邻接矩阵的COO格式
什么是GPIO,它有什么用
TI C6000 TMS320C6678 DSP+ Zynq-7045的PS + PL异构多核案例开发手册(2)
Refuse noise, the entry journey of earphone Xiaobai
DELTA控制器RMC200
如何通过ETL调度工具 TASKCTL 使用作业插件类型调用 kettle作业?
API version control [eolink translation]
Bucher gear pump qx81-400r301
ES6 advanced - query commodity cases
Sklearn clustering clustering
《硅谷之谜》读后感
Zynq PS + PL heterogeneous multicore Case Development Manual of Ti C6000 tms320c6678 DSP + zynq-7045 (1)
SAP ABAP 守护进程的实现方式
我们被一个 kong 的性能 bug 折腾了一个通宵
Google Earth engine - merra-2 m2t1nxaer: aerosol daily data set from 1980 to 2022
想让照片中的云飘起来?视频编辑服务一键动效3步就能实现