aboutsummaryrefslogtreecommitdiff
path: root/09-september/tomcat/renderer/shader.h
blob: e4889f3668f2b960d11b154eb7438f1063d376f5 (plain)
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
#ifndef SHADER_H
#define SHADER_H

#include "../shared.h"

typedef struct _Shader
{
    GLuint id;
    char name[MAX_PATH_LENGTH];

    /* Layout */

    /* Program Attributes */
    GLint position;
    GLint uv;
    GLint normal;
    GLint tangent;

    /* Program Uniforms */
    GLint totalTransform;
    GLint modelToWorld;
    GLint lightPosition;
    GLint ambientLight;
    GLint lightColor;
    GLint lightAttenuation;
    GLint World_eyePosition;
    GLint Texture;
    GLint Normal_Map;

    /* Program Multi Purpose Uniforms */
    GLint extra0;
    GLint extra1;
    GLint extra2;
    GLint extra3;
    GLint extra4;
    GLint extra5;

    struct _Shader *_hash_next;
    unsigned int _hash;
} Shader;

/** Shaders **/
extern Shader *shader_new(const char *name, const char *vertexShaderPath, const char *fragShaderPath);
extern Shader *shader_get(const char *name);
extern void shader_purge(Shader *shader);
/**         **/

/** Shader functions **/
extern GLint shader_get_uniform_location( Shader *s, const char *uniformName );
extern GLint shader_get_attrib_location( Shader *s, const char *attributeName );
extern void shader_set_uniform_mat4( Shader *s, const char *name, const float matrix[16] );
extern void shader_set_uniform_float( Shader *s, const char *name, const float val );
extern void shader_set_uniform_vec2( Shader *s, const char *name, const float vec[2] );
extern void shader_set_uniform_vec3( Shader *s, const char *name, const float vec[3] );
extern void shader_set_uniform_vec4( Shader *s, const char *name, const float vec[4] );
extern void shader_set_uniform_int( Shader *s, const char *name, const int val );
/**                  **/

#endif // SHADER_H