132001f49Smrg#ifndef SHADER_UTIL_H
232001f49Smrg#define SHADER_UTIL_H
332001f49Smrg
432001f49Smrg
532001f49Smrg#ifdef __cplusplus
632001f49Smrgextern "C" {
732001f49Smrg#endif
832001f49Smrg
932001f49Smrg
1032001f49Smrgstruct uniform_info
1132001f49Smrg{
1232001f49Smrg   const char *name;
1332001f49Smrg   GLuint size;  /**< number of value[] elements: 1, 2, 3 or 4 */
1432001f49Smrg   GLenum type;  /**< GL_FLOAT, GL_FLOAT_VEC4, GL_INT, GL_FLOAT_MAT4, etc */
1532001f49Smrg   GLfloat value[16];
1632001f49Smrg   GLint location;  /**< filled in by InitUniforms() */
1732001f49Smrg};
1832001f49Smrg
1932001f49Smrg#define END_OF_UNIFORMS   { NULL, 0, GL_NONE, { 0, 0, 0, 0 }, -1 }
2032001f49Smrg
2132001f49Smrg
2232001f49Smrgstruct attrib_info
2332001f49Smrg{
2432001f49Smrg   const char *name;
2532001f49Smrg   GLuint size;  /**< number of value[] elements: 1, 2, 3 or 4 */
2632001f49Smrg   GLenum type;  /**< GL_FLOAT, GL_FLOAT_VEC4, GL_INT, etc */
2732001f49Smrg   GLint location;
2832001f49Smrg};
2932001f49Smrg
3032001f49Smrg
3132001f49Smrgextern GLboolean
3232001f49SmrgShadersSupported(void);
3332001f49Smrg
3432001f49Smrgextern GLuint
3532001f49SmrgCompileShaderText(GLenum shaderType, const char *text);
3632001f49Smrg
3732001f49Smrgextern GLuint
3832001f49SmrgCompileShaderFile(GLenum shaderType, const char *filename);
3932001f49Smrg
4032001f49Smrgextern GLuint
4132001f49SmrgLinkShaders(GLuint vertShader, GLuint fragShader);
4232001f49Smrg
4332001f49Smrgextern GLuint
4432001f49SmrgLinkShaders3(GLuint vertShader, GLuint geomShader, GLuint fragShader);
4532001f49Smrg
4632001f49Smrgextern GLuint
4732001f49SmrgLinkShaders3WithGeometryInfo(GLuint vertShader, GLuint geomShader, GLuint fragShader,
4832001f49Smrg                             GLint verticesOut, GLenum inputType, GLenum outputType);
4932001f49Smrg
5032001f49Smrgextern GLboolean
5132001f49SmrgValidateShaderProgram(GLuint program);
5232001f49Smrg
5332001f49Smrgextern GLdouble
5432001f49SmrgGetShaderCompileTime(void);
5532001f49Smrg
5632001f49Smrgextern GLdouble
5732001f49SmrgGetShaderLinkTime(void);
5832001f49Smrg
5932001f49Smrgextern void
6032001f49SmrgSetUniformValues(GLuint program, struct uniform_info uniforms[]);
6132001f49Smrg
6232001f49Smrgextern GLuint
6332001f49SmrgGetUniforms(GLuint program, struct uniform_info uniforms[]);
6432001f49Smrg
6532001f49Smrgextern void
6632001f49SmrgPrintUniforms(const struct uniform_info uniforms[]);
6732001f49Smrg
6832001f49Smrgextern GLuint
6932001f49SmrgGetAttribs(GLuint program, struct attrib_info attribs[]);
7032001f49Smrg
7132001f49Smrgextern void
7232001f49SmrgPrintAttribs(const struct attrib_info attribs[]);
7332001f49Smrg
7432001f49Smrg/* These pointers are only valid after calling ShadersSupported.
7532001f49Smrg */
7632001f49Smrgextern PFNGLCREATESHADERPROC CreateShader;
7732001f49Smrgextern PFNGLDELETESHADERPROC DeleteShader;
7832001f49Smrgextern PFNGLSHADERSOURCEPROC ShaderSource;
7932001f49Smrgextern PFNGLGETSHADERIVPROC GetShaderiv;
8032001f49Smrgextern PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog;
8132001f49Smrgextern PFNGLCREATEPROGRAMPROC CreateProgram;
8232001f49Smrgextern PFNGLDELETEPROGRAMPROC DeleteProgram;
8332001f49Smrgextern PFNGLATTACHSHADERPROC AttachShader;
8432001f49Smrgextern PFNGLLINKPROGRAMPROC LinkProgram;
8532001f49Smrgextern PFNGLUSEPROGRAMPROC UseProgram;
8632001f49Smrgextern PFNGLGETPROGRAMIVPROC GetProgramiv;
8732001f49Smrgextern PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog;
8832001f49Smrgextern PFNGLVALIDATEPROGRAMARBPROC ValidateProgramARB;
8932001f49Smrgextern PFNGLUNIFORM1IPROC Uniform1i;
9032001f49Smrgextern PFNGLUNIFORM1FVPROC Uniform1fv;
9132001f49Smrgextern PFNGLUNIFORM2FVPROC Uniform2fv;
9232001f49Smrgextern PFNGLUNIFORM3FVPROC Uniform3fv;
9332001f49Smrgextern PFNGLUNIFORM4FVPROC Uniform4fv;
9432001f49Smrgextern PFNGLGETACTIVEATTRIBPROC GetActiveAttrib;
9532001f49Smrgextern PFNGLGETATTRIBLOCATIONPROC GetAttribLocation;
9632001f49Smrg
9732001f49Smrg#ifdef __cplusplus
9832001f49Smrg}
9932001f49Smrg#endif
10032001f49Smrg
10132001f49Smrg#endif /* SHADER_UTIL_H */
102