![]() |
![]() |
OpenGL Shading Language Tutorials |
Uniform Variables: Communication between C++ and OGLSL ProgramUniform variables are used to communicate with your vertex or fragment shader. In your shader you use the 'uniform' qualifier to declare the variable, for example:
Uniform variables are read-only and have the same value among all processed vertices. You can only change them within your C++ program. A simple OGLSL Vertex Shader
In this example the z coordinate is being scaled with an uniform variable and then the scaled vertex is transformed with the concatenated modelview and projection matrix.
C++ CodeSetting variables is easy with the appropriate function in the object class:
Author: Martin Christen, christen@clockworkcoders.com (source code is included in Tutorial Version 0.2 and higher)
|
|
© 2003 by Martin Christen. All Rights Reserved. |