GLSL program
352
Shaders are parts of a whole thing. And the whole thing is a GLSL program. After successful compilation of shaders you have to create a program and link shaders into that program.
const vs = gl.createShader(gl.VERTEX_SHADER);
const fs = gl.createShader(gl.FRAGMENT_SHADER);
// Compile shaders
const program = gl.createProgram();
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
// Check the linkage status
if(!gl.getProgramParameter(program, gl.LINK_STATUS))
{
// The linkage has failed, alert the log
alert(gl.getProgramInfoLog(program));
}
else
{
alert("The linkage has been successfully completed!");
}
Finally, we've done with GLSL. Shaders are compiled, the program is linked. We are ready to render things with our program. But first we need to prepare a geometry to render.
Rate this post:
Lesson 7
Lesson 9
Share this page:
Learning plan
The very basics of steps you should perform to draw a triangle or a 3D model from scratch
Let's create a simple vertex shader, compile it, and check for compilation issues
Now let's create a fragment shader, compile it and check for errors
8. GLSL program
It's time to link our shaders into a completed GLSL program
Now we need to create a GPU buffer and transfer a geometry data into it
10. First triangle
Everything is ready to draw our first triangle
11. Uniforms
How to use draw call level parameters to control the shading process