attribute vec3 vert_position;
void main() {
gl_PointSize = 10.0;
gl_Position = vec4(vert_position, 1.0);
}
attribute vec3 vert_position; declares that the
vertex to be processed has an attribute called vert_position.
It is a vec3, a vector with 3 components (xyz).
main() function that returns nothing.gl_Position variable, which is of type vec4,
i.e. a vector with 4 components (xyzw).
vec4, you use a constructor:
vec4(1.0, 2.0, 3.0, 4.0).vec4(vert_position, 1.0) where vert_position
is a vec3. So, a vec3 can replace 3 numbers in the constructor.
vec4(1.0, vert_position) is okay syntactically as well.gl_Position is a point in clip space, which has 4 dimensions.
gl_Position and the NDC is as follows:
$$ NDC.x = \frac{gl\_Position.x}{gl\_Position.w},
NDC.y = \frac{gl\_Position.y}{gl\_Position.w},
NDC.z = \frac{gl\_Position.z}{gl\_Position.w}$$
That is, the xyz-components of the NDC is obtained by dividing the same components
of gl_Position by the $w$-component of gl_Position.
This is called the perspective divide, which we will learn when we talk about
projective transformations in CS 4620.
gl_Position is 1, then
the NDC is just the xyz-components of gl_Position unchanged.
This is basically what happens in the vertex shader.
It sets the NDC to vert_position.
gl_PointSize, which is a float.
f like in C or in Java.
1.0 instead of 1.0f.precision highp float;
void main() {
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
precision highp float;, indicates that we want to
use high precision mathematics when dealing with floating-point numbers.
mediump and lowp.highp are suitable for less powerful devices
such as cellphones.main function, just like the vertex shader.
gl_FragColor variable, which is the color of the
fragment being processed.
vec4 (rgba).gl.drawArrays to actually draw the primitives.