1#ifndef SHADER_UTIL_H
2#define SHADER_UTIL_H
3
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9
10struct uniform_info
11{
12   const char *name;
13   GLuint size;  /**< number of value[] elements: 1, 2, 3 or 4 */
14   GLenum type;  /**< GL_FLOAT, GL_FLOAT_VEC4, GL_INT, GL_FLOAT_MAT4, etc */
15   GLfloat value[16];
16   GLint location;  /**< filled in by InitUniforms() */
17};
18
19#define END_OF_UNIFORMS   { NULL, 0, GL_NONE, { 0, 0, 0, 0 }, -1 }
20
21
22struct attrib_info
23{
24   const char *name;
25   GLuint size;  /**< number of value[] elements: 1, 2, 3 or 4 */
26   GLenum type;  /**< GL_FLOAT, GL_FLOAT_VEC4, GL_INT, etc */
27   GLint location;
28};
29
30
31extern GLboolean
32ShadersSupported(void);
33
34extern GLuint
35CompileShaderText(GLenum shaderType, const char *text);
36
37extern GLuint
38CompileShaderFile(GLenum shaderType, const char *filename);
39
40extern GLuint
41LinkShaders(GLuint vertShader, GLuint fragShader);
42
43extern GLuint
44LinkShaders3(GLuint vertShader, GLuint geomShader, GLuint fragShader);
45
46extern GLuint
47LinkShaders3WithGeometryInfo(GLuint vertShader, GLuint geomShader, GLuint fragShader,
48                             GLint verticesOut, GLenum inputType, GLenum outputType);
49
50extern GLboolean
51ValidateShaderProgram(GLuint program);
52
53extern GLdouble
54GetShaderCompileTime(void);
55
56extern GLdouble
57GetShaderLinkTime(void);
58
59extern void
60SetUniformValues(GLuint program, struct uniform_info uniforms[]);
61
62extern GLuint
63GetUniforms(GLuint program, struct uniform_info uniforms[]);
64
65extern void
66PrintUniforms(const struct uniform_info uniforms[]);
67
68extern GLuint
69GetAttribs(GLuint program, struct attrib_info attribs[]);
70
71extern void
72PrintAttribs(const struct attrib_info attribs[]);
73
74/* These pointers are only valid after calling ShadersSupported.
75 */
76extern PFNGLCREATESHADERPROC CreateShader;
77extern PFNGLDELETESHADERPROC DeleteShader;
78extern PFNGLSHADERSOURCEPROC ShaderSource;
79extern PFNGLGETSHADERIVPROC GetShaderiv;
80extern PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog;
81extern PFNGLCREATEPROGRAMPROC CreateProgram;
82extern PFNGLDELETEPROGRAMPROC DeleteProgram;
83extern PFNGLATTACHSHADERPROC AttachShader;
84extern PFNGLLINKPROGRAMPROC LinkProgram;
85extern PFNGLUSEPROGRAMPROC UseProgram;
86extern PFNGLGETPROGRAMIVPROC GetProgramiv;
87extern PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog;
88extern PFNGLVALIDATEPROGRAMARBPROC ValidateProgramARB;
89extern PFNGLUNIFORM1IPROC Uniform1i;
90extern PFNGLUNIFORM1FVPROC Uniform1fv;
91extern PFNGLUNIFORM2FVPROC Uniform2fv;
92extern PFNGLUNIFORM3FVPROC Uniform3fv;
93extern PFNGLUNIFORM4FVPROC Uniform4fv;
94extern PFNGLGETACTIVEATTRIBPROC GetActiveAttrib;
95extern PFNGLGETATTRIBLOCATIONPROC GetAttribLocation;
96
97#ifdef __cplusplus
98}
99#endif
100
101#endif /* SHADER_UTIL_H */
102