当前位置:网站首页>初识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);
边栏推荐
- Development and implementation of campus epidemic prevention and control management system based on SSM
- ROS问题及解决方案——依赖包安装以及无法修正错误
- 想让照片中的云飘起来?视频编辑服务一键动效3步就能实现
- A coal mine in Yangquan, Shanxi Province, suffered a safety accident that killed one person and was ordered to stop production for rectification
- 基于SSM开发实现校园疫情防控管理系统
- 组件化开发基本规范、localStorage 和 sessionStorage、对象数据转基本值、原型链使用
- Google Earth engine - merra-2 m2t1nxaer: aerosol daily data set from 1980 to 2022
- FTP protocol
- Pandora IOT development board learning (RT thread) - Experiment 17 esp8266 experiment (learning notes)
- zabbix 6.2.0部署
猜你喜欢

使用verdaccio搭建自己的npm私有库

Google Earth engine - merra-2 m2t1nxaer: aerosol daily data set from 1980 to 2022

04 callable and common auxiliary classes

# 工欲善其事必先利其器-C语言拓展--嵌入式C语言(十一)

德国EMG易安基推动器ED301/6 HS

hawe螺旋插装式单向阀RK4

Reflection, enumeration, and lambda expressions

博途PLC顺序开关机功能块(SCL)

Some cutting-edge research work sharing of SAP ABAP NetWeaver containerization

2022 what is your sense of security? Volvo asked in the middle of the year
随机推荐
Change an ergonomic chair to relieve the old waist of sitting and writing code~
全志A40i工业核心板,100%国产4核ARM Cortex-A7,支持“双屏异显”【显示接口能力,工业HMI首选方案】
Zynq PS + PL heterogeneous multicore Case Development Manual of Ti C6000 tms320c6678 DSP + zynq-7045 (1)
Google Earth engine - merra-2 m2t1nxaer: aerosol daily data set from 1980 to 2022
[expdp export data] expdp exports a table with 23 rows of records and no lob field. It takes 48 minutes. Please help us have a look
VS2019Debug模式太卡进不去断点
Desktop application layout
tensorboard多个events文件显示紊乱的解决办法
机器人手眼标定Ax=xB(eye to hand和eye in hand)及平面九点法标定
DELTA控制器RMC200
德国emg电动执行器EB800-60II
js 对数组操作的 API 总结
【ARM学习(9) arm 编译器了解学习(armcc/armclang)】
[tool sharing] automatic generation of file directory structure tool mddir
请问一下各位大佬,mysql-cdc建表如何指定表的字符集呢,在官网没找到相应的连接器参数。我读一个
TKE集群节点max-pod是如何配置的
Pandora IOT development board learning (RT thread) - Experiment 17 esp8266 experiment (learning notes)
The solution to the display disorder of several events files in the tensorboard
Question collection come and ask nllb authors! (Zhiyuan live issue 24)
Specific practice cases of "card note taking method" in Siyuan