polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

shader.h (1140B)


      1 #ifndef POLYADVENT_SHADER_H
      2 #define POLYADVENT_SHADER_H
      3 
      4 #include <time.h>
      5 #include "gl.h"
      6 
      7 #define SHADER(f) "etc/shaders/" f
      8 
      9 #define MAX_SHADER_INCLUDES 16
     10 #define MAX_INCLUDE_FNAME_LEN 64
     11 #define MAX_SHADERS 5
     12 #define MAX_UNIFORMS 16
     13 
     14 struct shader {
     15 	GLenum type;
     16 	GLuint handle;
     17     int n_includes;
     18 	const char *filename;
     19     char includes[MAX_SHADER_INCLUDES][MAX_INCLUDE_FNAME_LEN];
     20     time_t include_mtimes[MAX_SHADER_INCLUDES];
     21 	time_t load_mtime;
     22 };
     23 
     24 struct gpu_program {
     25 	struct shader shaders[MAX_SHADERS];
     26     int n_shaders;
     27 	GLuint handle;
     28 };
     29 
     30 #define NO_GEOM_SHADER NULL
     31 
     32 int reload_program(struct gpu_program *program);
     33 int make_shader(GLenum type, const char *filename, struct shader *shader);
     34 
     35 void init_gpu_program(struct gpu_program *program);
     36 int make_program_from_shaders(struct shader **shaders,
     37                               int n_shaders,
     38                               struct gpu_program *program);
     39 
     40 struct shader *get_program_shader(struct gpu_program *program, GLenum type);
     41 
     42 int make_program(struct shader *vertex,
     43 		 struct shader *fragment,
     44 		 struct gpu_program *program);
     45 
     46 #endif /* POLYADVENT_SHADER_H */