-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShaderSetup.h
88 lines (73 loc) · 1.76 KB
/
ShaderSetup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
** ShaderSetup
**
** Set up a GLSL shader based on supplied source files.
*/
#ifndef _SHADERSETUP_H_
#define _SHADERSETUP_H_
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
/*
** Error codes returned by ShaderSetup()
*/
#define E_NO_ERROR 0
#define E_VS_LOAD 1
#define E_FS_LOAD 2
#define E_VS_COMPILE 3
#define E_FS_COMPILE 4
#define E_SHADER_LINK 5
/*
** read_text_file(name)
**
** Read the text file given as 'name'.
**
** Returns the contents of the file in a dynamically-allocated
** string buffer, or NULL if an error occurs.
*/
GLchar *read_text_file( const char *name );
/*
** print_shader_info_log(shader)
**
** Print the information log from a shader compilation attempt
*/
void print_shader_info_log( GLuint shader );
/*
** print_program_info_log(shader)
**
** Print a program information log
**
** This is identical to print_shader_info_log(), except that it uses
** glGetProgramiv() and glGetProgramInfoLog() instead of the *Shader*()
** versions.
*/
void print_program_info_log( GLuint shader );
/*
** ErrorString(code)
**
** Returns a const char* with a text version of the supplied error code.
*/
const char *ErrorString( GLuint code );
/*
** ShaderSetup(vertex,fragment)
**
** Set up a GLSL shader program.
**
** Requires the name of a vertex program and a fragment
** program. Returns a handle to the created GLSL program
**
** Arguments:
** vert - vertex shader program source file
** frag - fragment shader program source file
** errors - pointer to variable to be incremented in case of error
**
** On success:
** returns the GLSL shader program handle, and *errors == 0
**
** On failure:
** returns 0, and *errors contains an error code
*/
GLuint ShaderSetup( const char *vert, const char *frag, GLuint *errors );
#endif