forked from BSVino/docs.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shader_setup.htm
19 lines (17 loc) · 968 Bytes
/
shader_setup.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// The index returned from these GLint functions gets passed to {%glEnableVertexAttribArray} during rendering.
GLint position_attrib_index = {%glGetAttribLocation}(program, "position"); // program is what is returned by {%glCreateProgram}.
GLint texcoord_attrib_index = {%glGetAttribLocation}(program, "texcoord");
GLint normal_attrib_index = {%glGetAttribLocation}(program, "normal");
GLint color_attrib_index = {%glGetAttribLocation}(program, "color");
{%glBindFragDataLocation}(program, 0, "output_color"); // "output_color" is an output value in your vertex shader and an input value in your fragment shader.
GLint num_uniforms;
{%glGetProgramiv}(program, GL_ACTIVE_UNIFORMS, &num_uniforms);
GLchar uniform_name[256];
GLsizei length;
GLint size;
GLenum type;
for (int i = 0; i < num_uniforms; i++)
{
{%glGetActiveUniform}(program, i, sizeof(uniform_name), &length, &size, &type, uniform_name);
// ... save this uniform data so it can be used during rendering
}