当前位置:网站首页>初识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);
边栏推荐
- Promise, async await and the solution of cross domain problems -- the principle of proxy server
- js 对数组操作的 API 总结
- 如何通过ETL调度工具 TASKCTL 使用作业插件类型调用 kettle作业?
- 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
- 拒绝噪声,耳机小白的入门之旅
- Pandora IOT development board learning (RT thread) - Experiment 17 esp8266 experiment (learning notes)
- Daily1:SVM
- The solution to the display disorder of several events files in the tensorboard
- 哪本书才是编程领域的“九阴真经”
- Research and application of the whole configuration of large humanoid robot
猜你喜欢

PS + PL heterogeneous multicore case development manual for Ti C6000 tms320c6678 DSP + zynq-7045 (2)

Parker solenoid valve d1vw020dnypz5

Implementation of personalized healthy diet recommendation system based on SSM

马斯克被曝绿了谷歌创始人:导致挚友二婚破裂,曾下跪求原谅

A comprehensive review of image enhancement technology in deep learning

Bucher gear pump qx81-400r301

Understand │ XSS attack, SQL injection, CSRF attack, DDoS attack, DNS hijacking

Research and application of the whole configuration of large humanoid robot
FTP协议

【ARM学习(9) arm 编译器了解学习(armcc/armclang)】
随机推荐
TI C6000 TMS320C6678 DSP+ Zynq-7045的PS + PL异构多核案例开发手册(4)
小哥自创AI防拖延系统,一玩手机就被“闪瞎” | Reddit高热
共议公共数据开放,“数牍方案”亮相数字中国建设峰会
泰山OFFICE技术讲座:WORD的缩放比例与显示略有差异
一款可视化浏览器历史的 Firefox/Chrome 插件
TI C6000 TMS320C6678 DSP+ Zynq-7045的PS + PL异构多核案例开发手册(2)
德国emg电动执行器EB800-60II
Clojure 运行原理之字节码生成篇
邻接矩阵的COO格式
This article explains in detail the discovery and processing of bigkey and hotkey in redis
promise,async-await 和 跨域问题的解决--代理服务器的原理
ROS problems and Solutions - relying on package installation and unable to correct errors
FTP协议
Musk was exposed to be the founder of Google: he broke up his best friend's second marriage and knelt down to beg for forgiveness
The solution to the display disorder of several events files in the tensorboard
Using information entropy to construct decision tree
大型仿人机器人整机构型研究与应用
How to use job plug-in type to call a kettle job through ETL scheduling tool taskctl?
开发日常小结(11):文件上传功能改进:中文字符检测与文本内容处理
马斯克被曝绿了谷歌创始人:导致挚友二婚破裂,曾下跪求原谅