Skip to content

Commit bd00b2e

Browse files
SiegeLordExSiegeLord
authored andcommitted
Wrap vertex/index buffers.
1 parent 0c4574c commit bd00b2e

6 files changed

Lines changed: 518 additions & 22 deletions

File tree

allegro/src/display.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ pub struct Display
112112
backbuffer: Bitmap,
113113
#[cfg(any(allegro_5_2_0, allegro_5_1_0))]
114114
shaders: Vec<Arc<Shader>>,
115+
tokens: Vec<Arc<String>>,
115116
}
116117

117118
impl Display
@@ -139,6 +140,7 @@ impl Display
139140
Display {
140141
allegro_display: d,
141142
backbuffer: backbuffer,
143+
tokens: vec![],
142144
}
143145
}
144146

@@ -149,6 +151,7 @@ impl Display
149151
allegro_display: d,
150152
backbuffer: backbuffer,
151153
shaders: vec![],
154+
tokens: vec![],
152155
}
153156
}
154157

@@ -346,6 +349,11 @@ impl Display
346349
Err(())
347350
}
348351
}
352+
353+
pub fn add_dependency_token(&mut self, token: Arc<String>)
354+
{
355+
self.tokens.push(token);
356+
}
349357
}
350358

351359
unsafe impl Send for Display {}
@@ -355,6 +363,13 @@ impl Drop for Display
355363
{
356364
fn drop(&mut self)
357365
{
366+
for token in &self.tokens
367+
{
368+
if Arc::strong_count(&token) != 1
369+
{
370+
panic!("Have an outstanding dependency token! Token name: {}", token);
371+
}
372+
}
358373
if self.has_outstanding_shaders()
359374
{
360375
panic!("Display has outstanding shaders!");

allegro_primitives-sys/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ pub mod allegro_primitives
108108
vtxs: *const c_void, decl: *const ALLEGRO_VERTEX_DECL, texture: *mut ALLEGRO_BITMAP,
109109
indices: *const c_int, num_vtx: c_int, _type: c_int,
110110
) -> c_int;
111+
pub fn al_draw_vertex_buffer(
112+
vertex_buffer: *mut ALLEGRO_VERTEX_BUFFER, texture: *mut ALLEGRO_BITMAP, start: c_int,
113+
end: c_int, type_: c_int,
114+
) -> c_int;
115+
116+
pub fn al_draw_indexed_buffer(
117+
vertex_buffer: *mut ALLEGRO_VERTEX_BUFFER, texture: *mut ALLEGRO_BITMAP,
118+
index_buffer: *mut ALLEGRO_INDEX_BUFFER, start: c_int, end: c_int, type_: c_int,
119+
) -> c_int;
111120

112121
pub fn al_create_vertex_decl(
113122
elements: *const ALLEGRO_VERTEX_ELEMENT, stride: c_int,

allegro_primitives/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ version = "=0.0.48" #auto
4040

4141
path = "../allegro_primitives-sys"
4242
version = "=0.0.48" #auto
43+
44+
[dependencies.allegro_util]
45+
46+
path = "../allegro_util"
47+
version = "=0.0.48" #auto

0 commit comments

Comments
 (0)