September 2018
Intermediate to advanced
472 pages
15h 36m
English
In this example, the subroutine is defined within the vertex shader. The first step involves declaring the subroutine type, as follows:
subroutine vec3 shadeModelType( vec3 position, vec3 normal);
This defines a new subroutine type with the name shadeModelType. The syntax is very similar to a function prototype, in that it defines a name, a parameter list, and a return type. As with function prototypes, the parameter names are optional.
After creating the new subroutine type, we declare a uniform variable of that type named shadeModel:
subroutine uniform shadeModelType shadeModel;
This variable serves as our function pointer and will be assigned to one of the two possible functions in the OpenGL application.
We declare two ...
Read now
Unlock full access