fractorb

diff src/sdr.h @ 0:6e849d7377ff

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 18 Nov 2017 20:04:16 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/sdr.h	Sat Nov 18 20:04:16 2017 +0200
     1.3 @@ -0,0 +1,68 @@
     1.4 +#ifndef SDR_H_
     1.5 +#define SDR_H_
     1.6 +
     1.7 +#ifdef __cplusplus
     1.8 +extern "C" {
     1.9 +#endif	/* __cplusplus */
    1.10 +
    1.11 +/* ---- shaders ---- */
    1.12 +unsigned int create_vertex_shader(const char *src);
    1.13 +unsigned int create_pixel_shader(const char *src);
    1.14 +unsigned int create_tessctl_shader(const char *src);
    1.15 +unsigned int create_tesseval_shader(const char *src);
    1.16 +unsigned int create_geometry_shader(const char *src);
    1.17 +unsigned int create_shader(const char *src, unsigned int sdr_type);
    1.18 +void free_shader(unsigned int sdr);
    1.19 +
    1.20 +unsigned int load_vertex_shader(const char *fname);
    1.21 +unsigned int load_pixel_shader(const char *fname);
    1.22 +unsigned int load_tessctl_shader(const char *fname);
    1.23 +unsigned int load_tesseval_shader(const char *fname);
    1.24 +unsigned int load_geometry_shader(const char *fname);
    1.25 +unsigned int load_shader(const char *src, unsigned int sdr_type);
    1.26 +
    1.27 +int add_shader(const char *fname, unsigned int sdr);
    1.28 +int remove_shader(const char *fname);
    1.29 +
    1.30 +/* ---- gpu programs ---- */
    1.31 +unsigned int create_program(void);
    1.32 +unsigned int create_program_link(unsigned int sdr0, ...);
    1.33 +unsigned int create_program_load(const char *vfile, const char *pfile);
    1.34 +void free_program(unsigned int sdr);
    1.35 +
    1.36 +void attach_shader(unsigned int prog, unsigned int sdr);
    1.37 +int link_program(unsigned int prog);
    1.38 +int bind_program(unsigned int prog);
    1.39 +
    1.40 +int get_uniform_loc(unsigned int prog, const char *name);
    1.41 +
    1.42 +int set_uniform_int(unsigned int prog, const char *name, int val);
    1.43 +int set_uniform_float(unsigned int prog, const char *name, float val);
    1.44 +int set_uniform_float2(unsigned int prog, const char *name, float x, float y);
    1.45 +int set_uniform_float3(unsigned int prog, const char *name, float x, float y, float z);
    1.46 +int set_uniform_float4(unsigned int prog, const char *name, float x, float y, float z, float w);
    1.47 +int set_uniform_matrix4(unsigned int prog, const char *name, const float *mat);
    1.48 +int set_uniform_matrix4_transposed(unsigned int prog, const char *name, const float *mat);
    1.49 +
    1.50 +int get_attrib_loc(unsigned int prog, const char *name);
    1.51 +void set_attrib_float3(int attr_loc, float x, float y, float z);
    1.52 +
    1.53 +/* ---- shader composition ---- */
    1.54 +
    1.55 +/* clear shader header/footer text.
    1.56 + * pass the shader type to clear, or 0 to clear all types */
    1.57 +void clear_shader_header(unsigned int type);
    1.58 +void clear_shader_footer(unsigned int type);
    1.59 +/* append text to the header/footer of a specific shader type
    1.60 + * or use type 0 to add it to all shade types */
    1.61 +void add_shader_header(unsigned int type, const char *s);
    1.62 +void add_shader_footer(unsigned int type, const char *s);
    1.63 +/* get the current header/footer text for a specific shader type */
    1.64 +const char *get_shader_header(unsigned int type);
    1.65 +const char *get_shader_footer(unsigned int type);
    1.66 +
    1.67 +#ifdef __cplusplus
    1.68 +}
    1.69 +#endif	/* __cplusplus */
    1.70 +
    1.71 +#endif	/* SDR_H_ */