Skip to content

Commit 4a20785

Browse files
TRDarioSiegeLord
authored andcommitted
Add al_get_current_shader
Requested on Discord.
1 parent 634fdc8 commit 4a20785

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

docs/src/refman/shader.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,15 @@ Since: 5.1.6
264264

265265
See also: [al_destroy_shader], [al_set_shader_sampler], [al_set_shader_matrix],
266266
[al_set_shader_int], [al_set_shader_float], [al_set_shader_bool],
267-
[al_set_shader_int_vector], [al_set_shader_float_vector]
267+
[al_set_shader_int_vector], [al_set_shader_float_vector], [al_get_current_shader]
268+
269+
## API: al_get_current_shader
270+
271+
Return the shader of the target bitmap, or NULL if one isn't being used.
272+
273+
Since: 5.2.9
274+
275+
See also: [al_use_shader]
268276

269277
## API: al_destroy_shader
270278

include/allegro5/shader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ AL_FUNC(bool, al_build_shader, (ALLEGRO_SHADER *shader));
5959
AL_FUNC(const char *, al_get_shader_log, (ALLEGRO_SHADER *shader));
6060
AL_FUNC(ALLEGRO_SHADER_PLATFORM, al_get_shader_platform, (ALLEGRO_SHADER *shader));
6161
AL_FUNC(bool, al_use_shader, (ALLEGRO_SHADER *shader));
62+
AL_FUNC(ALLEGRO_SHADER *, al_get_current_shader, (void));
6263
AL_FUNC(void, al_destroy_shader, (ALLEGRO_SHADER *shader));
6364

6465
AL_FUNC(bool, al_set_shader_sampler, (const char *name, ALLEGRO_BITMAP *bitmap,

src/shader.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,20 @@ bool al_use_shader(ALLEGRO_SHADER *shader)
211211
}
212212
}
213213

214+
/* Function: al_get_current_shader
215+
*/
216+
ALLEGRO_SHADER *al_get_current_shader()
217+
{
218+
ALLEGRO_BITMAP* bmp = al_get_target_bitmap();
219+
220+
if (bmp != NULL) {
221+
return bmp->shader;
222+
}
223+
else {
224+
return NULL;
225+
}
226+
}
227+
214228
/* Function: al_destroy_shader
215229
*/
216230
void al_destroy_shader(ALLEGRO_SHADER *shader)

0 commit comments

Comments
 (0)