ode_rs/
ds.rs

1//! ds implementation for trait Tdrawstuff and setter to change drawstuff later
2//!
3
4use crate::ode::ds::{dsFunctions_C, Tdrawstuff};
5
6use std::ffi::{c_uint, c_int, c_char};
7
8pub use drawstuff::drawstuff::*;
9
10/// Drawstuff
11pub struct Drawstuff {
12}
13
14/// Tdrawstuff for Drawstuff
15impl Tdrawstuff for Drawstuff {
16  /// dsDebug void dsDebug(const char *msg, ...);
17  fn Debug(&self, msg: *const c_char) {
18unsafe {
19    dsDebug(msg); // and some varargs
20}
21    // print!("{}", String::from_u8(unsafe { std::slice::from_raw_parts(msg as *const u8, c strlen(msg)) }));
22  }
23  /// dsError void dsError(const char *msg, ...);
24  fn Error(&self, msg: *const c_char) {
25unsafe {
26    dsError(msg); // and some varargs
27}
28    // print!("{}", String::from_u8(unsafe { std::slice::from_raw_parts(msg as *const u8, c strlen(msg)) }));
29  }
30  /// dsPrint void dsPrint(const char *msg, ...);
31  fn Print(&self, msg: *const c_char) {
32unsafe {
33    dsPrint(msg); // and some varargs
34}
35    // print!("{}", String::from_u8(unsafe { std::slice::from_raw_parts(msg as *const u8, c strlen(msg)) }));
36  }
37
38  /// dsDrawBox 3 12 3
39  fn DrawBox(&self, pos: *const f32, rot: *const f32, lxyz: *const f32) {
40unsafe {
41    dsDrawBox(pos, rot, lxyz);
42}
43  }
44  /// dsDrawBoxD 3 12 3
45  fn DrawBoxD(&self, pos: *const f64, rot: *const f64, lxyz: *const f64) {
46unsafe {
47    dsDrawBoxD(pos, rot, lxyz);
48}
49  }
50  /// dsDrawCapsule 3 12
51  fn DrawCapsule(&self, pos: *const f32, rot: *const f32, l: f32, r: f32) {
52unsafe {
53    dsDrawCapsule(pos, rot, l, r);
54}
55  }
56  /// dsDrawCapsuleD 3 12
57  fn DrawCapsuleD(&self, pos: *const f64, rot: *const f64, l: f32, r: f32) {
58unsafe {
59    dsDrawCapsuleD(pos, rot, l, r);
60}
61  }
62  /// dsDrawConvex 3 12 planecount pointcount x
63  fn DrawConvex(&self, pos: *const f32, rot: *const f32,
64    planes: *const f32, planecount: c_uint,
65    points: *const f32, pointcount: c_uint,
66    polygons: *const c_uint) {
67unsafe {
68    dsDrawConvex(pos, rot, planes, planecount, points, pointcount, polygons);
69}
70  }
71  /// dsDrawConvexD 3 12 planecount pointcount x
72  fn DrawConvexD(&self, pos: *const f64, rot: *const f64,
73    planes: *const f64, planecount: c_uint,
74    points: *const f64, pointcount: c_uint,
75    polygons: *const c_uint) {
76unsafe {
77    dsDrawConvexD(pos, rot, planes, planecount, points, pointcount, polygons);
78}
79  }
80  /// dsDrawCylinder 3 12
81  fn DrawCylinder(&self, pos: *const f32, rot: *const f32, l: f32, r: f32) {
82unsafe {
83    dsDrawCylinder(pos, rot, l, r);
84}
85  }
86  /// dsDrawCylinderD 3 12
87  fn DrawCylinderD(&self, pos: *const f64, rot: *const f64, l: f32, r: f32) {
88unsafe {
89    dsDrawCylinderD(pos, rot, l, r);
90}
91  }
92  /// dsDrawLine 3 3
93  fn DrawLine(&self, pos1: *const f32, pos2: *const f32) {
94unsafe {
95    dsDrawLine(pos1, pos2);
96}
97  }
98  /// dsDrawLineD 3 3
99  fn DrawLineD(&self, pos1: *const f64, pos2: *const f64) {
100unsafe {
101    dsDrawLineD(pos1, pos2);
102}
103  }
104  /// dsDrawSphere 3 12
105  fn DrawSphere(&self, pos: *const f32, rot: *const f32, radius: f32) {
106unsafe {
107    dsDrawSphere(pos, rot, radius);
108}
109  }
110  /// dsDrawSphereD 3 12
111  fn DrawSphereD(&self, pos: *const f64, rot: *const f64, radius: f32) {
112unsafe {
113    dsDrawSphereD(pos, rot, radius);
114}
115  }
116  /// dsDrawTriangle 3 12 (4 4 4) or (3 3 3)
117  fn DrawTriangle(&self, pos: *const f32, rot: *const f32,
118    v0: *const f32, v1: *const f32, v2: *const f32, solid: c_int) {
119unsafe {
120    dsDrawTriangle(pos, rot, v0, v1, v2, solid);
121}
122  }
123  /// dsDrawTriangleD 3 12 (4 4 4) or (3 3 3)
124  fn DrawTriangleD(&self, pos: *const f64, rot: *const f64,
125    v0: *const f64, v1: *const f64, v2: *const f64, solid: c_int) {
126unsafe {
127    dsDrawTriangleD(pos, rot, v0, v1, v2, solid);
128}
129  }
130  /// dsDrawTriangles 3 12 4n or 3n
131  fn DrawTriangles(&self, pos: *const f32, rot: *const f32,
132    v: *const f32, n: c_int, solid: c_int) {
133unsafe {
134    dsDrawTriangles(pos, rot, v, n, solid);
135}
136  }
137  /// dsDrawTrianglesD 3 12 4n or 3n
138  fn DrawTrianglesD(&self, pos: *const f64, rot: *const f64,
139    v: *const f64, n: c_int, solid: c_int) {
140unsafe {
141    dsDrawTrianglesD(pos, rot, v, n, solid);
142}
143  }
144  /// dsElapsedTime
145  fn ElapsedTime(&self) -> f64 {
146unsafe {
147    dsElapsedTime()
148}
149  }
150  /// dsGetViewpoint 3 3
151  fn GetViewpoint(&self, xyz: *mut f32, hpr: *mut f32) {
152unsafe {
153    dsGetViewpoint(xyz, hpr);
154}
155  }
156  /// dsSetCapsuleQuality default 3
157  fn SetCapsuleQuality(&self, n: c_int) {
158unsafe {
159    dsSetCapsuleQuality(n);
160}
161  }
162  /// dsSetColor
163  fn SetColor(&self, red: f32, green: f32, blue: f32) {
164unsafe {
165    dsSetColor(red, green, blue);
166}
167  }
168  /// dsSetColorAlpha
169  fn SetColorAlpha(&self, red: f32, green: f32, blue: f32, alpha: f32) {
170unsafe {
171    dsSetColorAlpha(red, green, blue, alpha);
172}
173  }
174  /// dsSetDrawMode
175  fn SetDrawMode(&self, mode: c_int) {
176unsafe {
177    dsSetDrawMode(mode);
178}
179  }
180  /// dsSetSphereQuality default 1
181  fn SetSphereQuality(&self, n: c_int) {
182unsafe {
183    dsSetSphereQuality(n);
184}
185  }
186  /// dsSetTexture
187  fn SetTexture(&self, texture_number: c_int) {
188unsafe {
189    dsSetTexture(texture_number);
190}
191  }
192  /// dsSetViewpoint 3 3
193  fn SetViewpoint(&self, xyz: *mut f32, hpr: *mut f32) {
194unsafe {
195    dsSetViewpoint(xyz, hpr);
196}
197  }
198  /// dsSimulationLoop
199  fn SimulationLoop(&self, argc: c_int, argv: *mut *mut c_char,
200    window_width: c_int, window_height: c_int, functions: *mut dsFunctions_C) {
201unsafe {
202    dsSimulationLoop(argc, argv, window_width, window_height,
203      functions as *mut dsFunctions); // (for compatibililty)
204}
205  }
206  /// dsStop
207  fn Stop(&self) {
208unsafe {
209    dsStop();
210}
211  }
212}
213
214/// Drawstuff
215impl Drawstuff {
216  /// constructor
217  pub fn new() -> Self {
218    Drawstuff{}
219  }
220  /// dispose
221  pub fn dispose(&mut self) {
222    ()
223  }
224}
225
226/// Drop for Drawstuff
227impl Drop for Drawstuff {
228  /// drop
229  fn drop(&mut self) {
230    self.dispose();
231  }
232}