当前位置:网站首页>初识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);
边栏推荐
- How to use job plug-in type to call a kettle job through ETL scheduling tool taskctl?
- 2021年软件测试工具趋势
- Quanzhi a40i industrial core board, 100% domestic 4-core arm cortex-a7, supports "dual screen abnormal display" [display interface capability, preferred scheme for industrial HMI]
- gcc/g++与动静库以及gdb
- 全志A40i工业核心板,100%国产4核ARM Cortex-A7,支持“双屏异显”【显示接口能力,工业HMI首选方案】
- 组件化开发基本规范、localStorage 和 sessionStorage、对象数据转基本值、原型链使用
- 剑指offer专项突击版第11天
- 基于SSM开发实现校园疫情防控管理系统
- OSPF comprehensive experiment
- ROS problems and Solutions - relying on package installation and unable to correct errors
猜你喜欢

Question collection come and ask nllb authors! (Zhiyuan live issue 24)

Development and implementation of campus epidemic prevention and control management system based on SSM

Google Earth Engine——MERRA-2 M2T1NXAER:1980-2022年气溶胶逐日数据集

Glyphs V3 Font Icon query
![[tool sharing] automatic generation of file directory structure tool mddir](/img/bc/1071c0dfb20d16f5fdde641092c1af.png)
[tool sharing] automatic generation of file directory structure tool mddir

How to use job plug-in type to call a kettle job through ETL scheduling tool taskctl?

Refuse noise, the entry journey of earphone Xiaobai

拒绝噪声,耳机小白的入门之旅

Bucher gear pump qx81-400r301

数智转型,管理先行|JNPF全力打造“全生命周期管理”平台
随机推荐
Using information entropy to construct decision tree
Refuse noise, the entry journey of earphone Xiaobai
潘多拉 IOT 开发板学习(RT-Thread)—— 实验17 ESP8266 实验(学习笔记)
ROS问题及解决方案——依赖包安装以及无法修正错误
Google Earth Engine——MERRA-2 M2T1NXSLV:1980-至今全球压力、温度、风等数据集
泰山OFFICE技术讲座:WORD的缩放比例与显示略有差异
TI C6000 TMS320C6678 DSP+ Zynq-7045的PS + PL异构多核案例开发手册(4)
“核弹级” Log4j 漏洞仍普遍存在,并造成持续影响
PS + PL heterogeneous multicore case development manual for Ti C6000 tms320c6678 DSP + zynq-7045 (3)
一文详解 Redis 中 BigKey、HotKey 的发现与处理
We were tossed all night by a Kong performance bug
博途PLC顺序开关机功能块(SCL)
Vs2019debug mode too laggy can't enter the breakpoint
哪本书才是编程领域的“九阴真经”
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
Daily1:SVM
2022 what is your sense of security? Volvo asked in the middle of the year
2022你的安全感是什么?沃尔沃年中问道
单例模式
LeetCode_ Prefix and_ Hash table_ Medium_ 525. Continuous array