#ifndef SHADERS_H_
#define SHADERS_H_

void setUniform1i(const GLuint* shader, char *name, int i1);
void setUniform1f(const GLuint* shader, char *name, float f1);

void setUniform3f(const GLuint* shader, char *name, float x, float y,float z);

void setUniform4m(const GLuint* shader, char *name, mat4x4 m4);

extern int bidx;
typedef struct BoundsDrawList { // bound box 2d/3d (2d=z=d)
    unsigned int i;
    float x,y,z;
    float w,h,d;
    float r,g,b;
    int mode;
    mat4x4 m;
    UT_hash_handle hh; /* makes this structure hashable */
} BoundsDrawList;
void add_bdl(struct BoundsDrawList *s);
struct BoundsDrawList *find_bdl(int bdl_id);
void delete_bdl(struct BoundsDrawList *s);

extern int lidx;
typedef struct LinesDrawList { // single lines
    unsigned int i;
    float x1,y1,z1;
    float x2,y2,z2;
    float r,g,b;
    int mode;
    mat4x4 m;
    UT_hash_handle hh; /* makes this structure hashable */
} LinesDrawList;
void add_ldl(struct LinesDrawList *s);
struct LinesDrawList *find_ldl(int ldl_id);
void delete_ldl(struct LinesDrawList *s);

// shader program list
extern unsigned int program, programPost, programCube;
extern unsigned int programText, programT3D, programUI, programLine;
extern unsigned int programTerrain, programStencil, programDepth;
extern unsigned int programWater, programWaterHeight, programWaterDepth;
extern unsigned int programLava, programFire, programFireBall, programVortex;
extern unsigned int programSky, programSun, programMoon, programClouds;


extern mat4x4 proj_ortho;

extern mat4x4 m, p, v, v2, mvp, uVp, ip, iv;

int setRenderModeOrthographic();
int execRenderModeOrthographic(mat4x4 v2);

int setRenderModePerspective();
int execRenderModePerspective(mat4x4 v);

int loadAllShaders();
char *readShader(char *filename);

int cleanupAllShaders(int reload);

extern unsigned int vsm, fsm; // main/spinquad
extern unsigned int vst, fst; // text(glyph)
extern unsigned int vsu, fsu; // ui(ortho)
extern unsigned int vst3, fst3; // text3d
extern unsigned int vsl, fsl; // line
extern unsigned int vsp, fsp; // underwater
extern unsigned int vspm, fspm; // msaa
extern unsigned int vsc, fsc; // cube
extern unsigned int vsg, fsg; // terrain/ground
extern unsigned int vsw, fsw; // water
extern unsigned int vswd, fswd; // water depth (no longer used)
extern unsigned int vswh, fswh; // water height
extern unsigned int vse, fse; // stencil custom
extern unsigned int vsd, fsd; // depth custom
extern unsigned int vsf, fsf; // fire
extern unsigned int vsfb, fsfb; // fireball
extern unsigned int vsx, fsx; // vortex
extern unsigned int vsa, fsa; // lava
extern unsigned int vss, fss; // sky/gradient
extern unsigned int vsss, fsss; // sun
extern unsigned int vssm, fssm; // moon
extern unsigned int vssc, fssc; // clouds

int InitializeShadersAll();

int RenderAllLines();
int RenderLine(float x1, float y1, float z1, float x2, float y2, float z2, int mode, mat4x4 m);

int RenderAllBounds();
int RenderBoundBox(float x, float y, float z, float w, float h, float d, int mode, mat4x4 m);

int RenderGridLines();
int RenderGridLines2();
int RenderGridLines3();

extern char* vertex_shader_line;
extern char* fragment_shader_line;
extern char* vertex_shader_ui;
extern char* fragment_shader_ui;
extern char* vertex_shader_t3d;
extern char* fragment_shader_t3d;
extern char* vertex_shader_text;
extern char* fragment_shader_text;
extern char* vertex_shader_main;
extern char* fragment_shader_main;
extern char* vertex_shader_cube;
extern char* fragment_shader_cube;
extern char* vertex_shader_terrain;
extern char* fragment_shader_terrain;
extern char* vertex_shader_water;
extern char* fragment_shader_water;
extern char* vertex_shader_water_depth;
extern char* fragment_shader_water_depth;
extern char* vertex_shader_water_height;
extern char* fragment_shader_water_height;
extern char* vertex_shader_stencil;
extern char* fragment_shader_stencil;
extern char* vertex_shader_depth;
extern char* fragment_shader_depth;
extern char* vertex_shader_fire;
extern char* fragment_shader_fire;
extern char* vertex_shader_fireball;
extern char* fragment_shader_fireball;
extern char* vertex_shader_vortex;
extern char* fragment_shader_vortex;
extern char* vertex_shader_lava;
extern char* fragment_shader_lava;
extern char* vertex_shader_sky;
extern char* fragment_shader_sky;
extern char* vertex_shader_sun;
extern char* fragment_shader_sun;
extern char* vertex_shader_moon;
extern char* fragment_shader_moon;
extern char* vertex_shader_post;
extern char* fragment_shader_post;
extern char* vertex_shader_clouds;
extern char* fragment_shader_clouds;

#endif
