Skip to content

Commit

Permalink
Shader setup example.
Browse files Browse the repository at this point in the history
  • Loading branch information
BSVino committed Aug 18, 2014
1 parent 3bf3099 commit ac5c487
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions html/examples/shader_setup.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
}
4 changes: 4 additions & 0 deletions opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
'description': 'Compile a program from a vertex shader and a fragment shader.',
'commands': [ 'glCreateShader', 'glShaderSource', 'glCompileShader', 'glGetShaderiv', 'glGetShaderInfoLog', 'glCreateProgram', 'glBindAttribLocation', 'glAttachShader', 'glLinkProgram', 'glGetProgramiv' ],
},
'shader_setup': {
'description': 'Retrieve uniform data after the shader has been compiled',
'commands': [ 'glGetAttribLocation', 'glBindFragDataLocation', 'glGetProgramiv', 'glGetActiveUniform' ],
},
}

def reverse_version_index(command_list):
Expand Down

0 comments on commit ac5c487

Please sign in to comment.