Shaders and Shader Program
We need to program at least a Vertex and Fragment shader to tell OpenGL what to do with the incomming Vertex and Pixel data.
Vertex Shader
A vertex shader is handling vertices. Lets create one with glCreateShader.
Now we have to tell where to find the source of it. We do that with glShaderSource.
After telling how the source looks like we have to compile the source with glCompileShader.
Fragment Shader
A fragment shader is handling pixels (multiple pixels = fragments). We create it with the same function as we used for the vertex shader but with a different parameter.
Then of course we have to tell again where to find the source as we did for the vertex shader.
And of course the same, we have to compile this fragment shader too.
Shader Program
The shader program holds different shader types and will be used during rendering. We create a shader program with glCreateProgram.
Now we need to attach the shaders we created before to this shader program. We do that with glAttachShader.
And finally as we do for normal c/c++ programs we have to link them to the shader program. This is done with glLinkProgram.
At this point if we don't have any errors, we are ready to use this shader program.
Last updated