JavaScript EditorFree JavaScript Editor     Ajax Editor 



Main Page
Previous Page
Next Page

7.14. Summary

The set of function calls added to OpenGL to create and manipulate shaders is actually quite small. The interface mimics the software development process followed by a C/C++ programmer. To install and use OpenGL shaders, do the following:

1.
Create one or more (empty) shader objects with glCreateShader.

2.
Provide source code for these shaders with glShaderSource.

3.
Compile each of the shaders with glCompileShader.

4.
Create a program object with glCreateProgram.

5.
Attach all the shader objects to the program object with glAttachShader.

6.
Link the program object with glLinkProgram.

7.
Install the executable program as part of OpenGL's current state with glUseProgram.

8.
If the shaders use user-defined uniform variables, query the locations of these variables with glGetUniformLocation and then set their values with glUniform.

User-defined attribute variables can be explicitly associated with a generic vertex attribute index with glBindAttribLocation, or such associations can be assigned implicitly at link time and queried with glGetAttribLocation. Generic vertex attribute values can then be supplied by the application a vertex at a time with one of the variants of glVertexAttrib or as vertex arrays by using glVertexAttribPointer and glEnableVertexArrayPointer in conjunction with standard OpenGL commands to draw vertex arrays.

A number of query functions obtain information about shader and program objects.


Previous Page
Next Page




JavaScript EditorAjax Editor     JavaScript Editor