allegro_sys/
shader.rs

1// Copyright (c) 2014 by SiegeLord
2//
3// All rights reserved. Distributed under ZLib. For full terms see the file LICENSE.
4
5use crate::bitmap::*;
6use crate::transformations::*;
7
8use allegro_util::c_bool;
9use libc::*;
10
11allegro_util::opaque!(ALLEGRO_SHADER);
12
13pub type ALLEGRO_SHADER_TYPE = c_uint;
14pub const ALLEGRO_VERTEX_SHADER: c_uint = 1;
15pub const ALLEGRO_PIXEL_SHADER: c_uint = 2;
16
17pub type ALLEGRO_SHADER_PLATFORM = c_uint;
18pub const ALLEGRO_SHADER_AUTO: c_uint = 0;
19pub const ALLEGRO_SHADER_GLSL: c_uint = 1;
20pub const ALLEGRO_SHADER_HLSL: c_uint = 2;
21
22unsafe extern "C" {
23	pub fn al_create_shader(platform: ALLEGRO_SHADER_PLATFORM) -> *mut ALLEGRO_SHADER;
24	pub fn al_attach_shader_source(
25		shader: *mut ALLEGRO_SHADER, _type: ALLEGRO_SHADER_TYPE, source: *const c_char,
26	) -> c_bool;
27	pub fn al_attach_shader_source_file(
28		shader: *mut ALLEGRO_SHADER, _type: ALLEGRO_SHADER_TYPE, filename: *const c_char,
29	) -> c_bool;
30	pub fn al_build_shader(shader: *mut ALLEGRO_SHADER) -> c_bool;
31	pub fn al_get_shader_log(shader: *mut ALLEGRO_SHADER) -> *const c_char;
32	pub fn al_get_shader_platform(shader: *mut ALLEGRO_SHADER) -> ALLEGRO_SHADER_PLATFORM;
33	pub fn al_use_shader(shader: *mut ALLEGRO_SHADER) -> c_bool;
34	pub fn al_destroy_shader(shader: *mut ALLEGRO_SHADER) -> ();
35	pub fn al_set_shader_sampler(
36		name: *const c_char, bitmap: *mut ALLEGRO_BITMAP, unit: c_int,
37	) -> c_bool;
38	pub fn al_set_shader_matrix(name: *const c_char, matrix: *const ALLEGRO_TRANSFORM) -> c_bool;
39	pub fn al_set_shader_int(name: *const c_char, i: c_int) -> c_bool;
40	pub fn al_set_shader_float(name: *const c_char, f: c_float) -> c_bool;
41	pub fn al_set_shader_int_vector(
42		name: *const c_char, num_components: c_int, i: *mut c_int, num_elems: c_int,
43	) -> c_bool;
44	pub fn al_set_shader_float_vector(
45		name: *const c_char, num_components: c_int, f: *mut c_float, num_elems: c_int,
46	) -> c_bool;
47	pub fn al_set_shader_bool(name: *const c_char, b: c_bool) -> c_bool;
48	pub fn al_get_default_shader_source(
49		platform: ALLEGRO_SHADER_PLATFORM, _type: ALLEGRO_SHADER_TYPE,
50	) -> *const c_char;
51}