当前位置:网站首页>First knowledge of OpenGL (4) link shader
First knowledge of OpenGL (4) link shader
2022-07-26 16:07:00 【thefist11】
1. Shader program
Shader program object (Shader Program Object) It's the version after merging multiple shaders and finally linking them . If we want to use the shaders just compiled, we must link them (Link) For a shader program object , Then activate the shader program when rendering the object . Shaders that have activated the shader program will be used when we send rendering calls .
When linking shaders to a program , It links the output of each shader to the input of the next shader . When the output and input don't match , You will get a connection error .
step1. Create shader program object
glCreateProgram Function to create a program , And returns the name of the newly created program object ID quote .
unsigned int shaderProgram;
shaderProgram = glCreateProgram();
step2. Attach the previously compiled shader to the program object , And then use glLinkProgram Link them
glAttachShader(shaderProgram, vertexShader);
glAttachShader(shaderProgram, fragmentShader);
glLinkProgram(shaderProgram);
step3. Failed to detect whether the linked shader program , And get the corresponding log .
Different from before , We won't call glGetShaderiv and glGetShaderInfoLog
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
if(!success) {
glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
...
}
step4. Activate this program object
call glUseProgram function , Use the newly created program object as its parameter .
glUseProgram(shaderProgram);
stay glUseProgram After the function call , Each shader call and rendering call uses this program object ( That is, the shader written before ) 了 .
step5. Delete shader object
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
Now? , We have sent the input vertex data to GPU, And indicated GPU How to handle it in vertex and clip shaders . It's almost finished , But it's not over yet ,OpenGL I don't know how it interprets vertex data in memory , And how it links vertex data to the attributes of the vertex shader . The next step is to tell OpenGL How do you do it? .
边栏推荐
- API version control [eolink translation]
- 我们被一个 kong 的性能 bug 折腾了一个通宵
- FTP协议
- 泰山OFFICE技术讲座:WORD的缩放比例与显示略有差异
- 2022年最新北京建筑安全员模拟题库及答案
- 请问一下各位大佬,mysql-cdc建表如何指定表的字符集呢,在官网没找到相应的连接器参数。我读一个
- Paper: all models are wrong, but many are useful: all models are wrong, but many are useful: understand the importance of variables by studying a whole class of prediction models at the same time
- Clojure 运行原理之字节码生成篇
- PAT甲级 1045 Favorite Color Stripe
- TKE集群节点max-pod是如何配置的
猜你喜欢

Research and application of the whole configuration of large humanoid robot
.net get injection object manually

parker泵PV140R1K1T1PMMC

潘多拉 IOT 开发板学习(RT-Thread)—— 实验17 ESP8266 实验(学习笔记)

小哥自创AI防拖延系统,一玩手机就被“闪瞎” | Reddit高热

“核弹级” Log4j 漏洞仍普遍存在,并造成持续影响

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]

测试用例千万不能随便,记录由一个测试用例异常引起的思考

如何通过ETL调度工具 TASKCTL 使用作业插件类型调用 kettle作业?

My brother created his own AI anti procrastination system, and he was "blinded" when playing with his mobile phone | reddit was hot
随机推荐
bucher齿轮泵QX81-400R301
FTP协议
Using information entropy to construct decision tree
PS + PL heterogeneous multicore case development manual for Ti C6000 tms320c6678 DSP + zynq-7045 (2)
【物理模拟】最简单的shape matching的原理与实践
PAT甲级 1049 Counting Ones
理解卷积神经网络中的权值共享
hawe螺旋插装式单向阀RK4
一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)
Alibaba cloud DMS MySQL cloud database report error, solve!!
Finally, someone explained the red blue confrontation clearly
We were tossed all night by a Kong performance bug
We were tossed all night by a Kong performance bug
tensorboard多个events文件显示紊乱的解决办法
【DSCTF2022】pwn补题记录
教大模型自己跳过“无用”层,推理速度×3性能不变,谷歌MIT这个新方法火了...
Build resume editor based on Nocode
辨析 Ruby 中的 Method 与 Proc
API version control [eolink translation]