mirror of
https://github.com/LearnOpenGL-CN/LearnOpenGL-CN.git
synced 2025-08-23 04:35:28 +08:00
Update the code in 01-05
This commit is contained in:
@@ -39,7 +39,7 @@ int main()
|
||||
当我们特别谈论到顶点着色器的时候,每个输入变量也叫<def>顶点属性</def>(Vertex Attribute)。我们能声明的顶点属性是有上限的,它一般由硬件来决定。OpenGL确保至少有16个包含4分量的顶点属性可用,但是有些硬件或许允许更多的顶点属性,你可以查询<var>GL_MAX_VERTEX_ATTRIBS</var>来获取具体的上限:
|
||||
|
||||
```c++
|
||||
unsigned int nrAttributes;
|
||||
int nrAttributes;
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &nrAttributes);
|
||||
std::cout << "Maximum nr of vertex attributes supported: " << nrAttributes << std::endl;
|
||||
```
|
||||
@@ -405,15 +405,15 @@ if(!success)
|
||||
[...]
|
||||
|
||||
// 着色器程序
|
||||
this->Program = glCreateProgram();
|
||||
glAttachShader(this->Program, vertex);
|
||||
glAttachShader(this->Program, fragment);
|
||||
glLinkProgram(this->Program);
|
||||
ID = glCreateProgram();
|
||||
glAttachShader(ID, vertex);
|
||||
glAttachShader(ID, fragment);
|
||||
glLinkProgram(ID);
|
||||
// 打印连接错误(如果有的话)
|
||||
glGetProgramiv(this->Program, GL_LINK_STATUS, &success);
|
||||
glGetProgramiv(ID, GL_LINK_STATUS, &success);
|
||||
if(!success)
|
||||
{
|
||||
glGetProgramInfoLog(this->Program, 512, NULL, infoLog);
|
||||
glGetProgramInfoLog(ID, 512, NULL, infoLog);
|
||||
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
|
||||
}
|
||||
|
||||
@@ -425,9 +425,9 @@ glDeleteShader(fragment);
|
||||
<fun>use</fun>函数非常简单:
|
||||
|
||||
```c++
|
||||
void Use()
|
||||
void use()
|
||||
{
|
||||
glUseProgram(this->Program);
|
||||
glUseProgram(ID);
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user