Skip to main content

d3d11/context/
draw.rs

1use crate::Buffer;
2
3use super::DeviceContext;
4
5impl DeviceContext {
6    pub fn draw(&self, vertex_count: u32, start_vertex_location: u32) {
7        unsafe {
8            self.0.Draw(vertex_count, start_vertex_location);
9        }
10    }
11
12    pub fn draw_auto(&self) {
13        unsafe {
14            self.0.DrawAuto();
15        }
16    }
17
18    pub fn draw_indexed(
19        &self,
20        index_count: u32,
21        start_index_location: u32,
22        base_vertex_location: i32,
23    ) {
24        unsafe {
25            self.0
26                .DrawIndexed(index_count, start_index_location, base_vertex_location);
27        }
28    }
29
30    pub fn draw_indexed_instanced(
31        &self,
32        index_count_per_instance: u32,
33        instance_count: u32,
34        start_index_location: u32,
35        base_vertex_location: i32,
36        start_instance_location: u32,
37    ) {
38        unsafe {
39            self.0.DrawIndexedInstanced(
40                index_count_per_instance,
41                instance_count,
42                start_index_location,
43                base_vertex_location,
44                start_instance_location,
45            );
46        }
47    }
48
49    pub fn draw_indexed_instanced_indirect(
50        &self,
51        buffer_for_args: &Buffer,
52        aligned_byte_offset_for_args: u32,
53    ) {
54        unsafe {
55            self.0
56                .DrawIndexedInstancedIndirect(&buffer_for_args.0, aligned_byte_offset_for_args);
57        }
58    }
59
60    pub fn draw_instanced(
61        &self,
62        vertex_count_per_instance: u32,
63        instance_count: u32,
64        start_vertex_location: u32,
65        start_instance_location: u32,
66    ) {
67        unsafe {
68            self.0.DrawInstanced(
69                vertex_count_per_instance,
70                instance_count,
71                start_vertex_location,
72                start_instance_location,
73            );
74        }
75    }
76
77    pub fn draw_instanced_indirect(
78        &self,
79        buffer_for_args: &Buffer,
80        aligned_byte_offset_for_args: u32,
81    ) {
82        unsafe {
83            self.0
84                .DrawInstancedIndirect(&buffer_for_args.0, aligned_byte_offset_for_args);
85        }
86    }
87}