1 #ifndef __al_included_allegro5_internal_aintern_shader_h
2 #define __al_included_allegro5_internal_aintern_shader_h
3 
4 #include "allegro5/internal/aintern_list.h"
5 #include "allegro5/internal/aintern_vector.h"
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 typedef struct ALLEGRO_SHADER_INTERFACE ALLEGRO_SHADER_INTERFACE;
12 
13 struct ALLEGRO_SHADER_INTERFACE
14 {
15    bool (*attach_shader_source)(ALLEGRO_SHADER *shader,
16          ALLEGRO_SHADER_TYPE type, const char *source);
17    bool (*build_shader)(ALLEGRO_SHADER *shader);
18    bool (*use_shader)(ALLEGRO_SHADER *shader, ALLEGRO_DISPLAY *dpy,
19             bool set_projview_matrix_from_display);
20    void (*unuse_shader)(ALLEGRO_SHADER *shader, ALLEGRO_DISPLAY *dpy);
21    void (*destroy_shader)(ALLEGRO_SHADER *shader);
22    void (*on_lost_device)(ALLEGRO_SHADER *shader);
23    void (*on_reset_device)(ALLEGRO_SHADER *shader);
24 
25    bool (*set_shader_sampler)(ALLEGRO_SHADER *shader, const char *name,
26          ALLEGRO_BITMAP *bitmap, int unit);
27    bool (*set_shader_matrix)(ALLEGRO_SHADER *shader, const char *name,
28          const ALLEGRO_TRANSFORM *matrix);
29    bool (*set_shader_int)(ALLEGRO_SHADER *shader, const char *name, int i);
30    bool (*set_shader_float)(ALLEGRO_SHADER *shader, const char *name, float f);
31    bool (*set_shader_int_vector)(ALLEGRO_SHADER *shader, const char *name,
32          int elem_size, const int *i, int num_elems);
33    bool (*set_shader_float_vector)(ALLEGRO_SHADER *shader, const char *name,
34          int elem_size, const float *f, int num_elems);
35    bool (*set_shader_bool)(ALLEGRO_SHADER *shader, const char *name, bool b);
36 };
37 
38 struct ALLEGRO_SHADER
39 {
40    ALLEGRO_USTR *vertex_copy;
41    ALLEGRO_USTR *pixel_copy;
42    ALLEGRO_USTR *log;
43    ALLEGRO_SHADER_PLATFORM platform;
44    ALLEGRO_SHADER_INTERFACE *vt;
45    _AL_VECTOR bitmaps; /* of ALLEGRO_BITMAP pointers */
46    _AL_LIST_ITEM *dtor_item;
47 };
48 
49 /* In most cases you should use _al_set_bitmap_shader_field. */
50 void _al_set_bitmap_shader_field(ALLEGRO_BITMAP *bmp, ALLEGRO_SHADER *shader);
51 void _al_register_shader_bitmap(ALLEGRO_SHADER *shader, ALLEGRO_BITMAP *bmp);
52 void _al_unregister_shader_bitmap(ALLEGRO_SHADER *shader, ALLEGRO_BITMAP *bmp);
53 
54 ALLEGRO_SHADER *_al_create_default_shader(int display_flags);
55 
56 #ifdef ALLEGRO_CFG_SHADER_GLSL
57 ALLEGRO_SHADER *_al_create_shader_glsl(ALLEGRO_SHADER_PLATFORM platform);
58 void _al_set_shader_glsl(ALLEGRO_DISPLAY *display, ALLEGRO_SHADER *shader);
59 #endif
60 
61 #ifdef ALLEGRO_CFG_SHADER_HLSL
62 ALLEGRO_SHADER *_al_create_shader_hlsl(ALLEGRO_SHADER_PLATFORM platform);
63 void _al_set_shader_hlsl(ALLEGRO_DISPLAY *display, ALLEGRO_SHADER *shader);
64 #endif
65 
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif
72 
73 /* vim: set sts=3 sw=3 et: */
74