use std::ffi::c_void;
use std::os::raw::{c_int, c_uint};
pub const INTERSECTION: c_int = 0;
pub const SUBTRACTION: c_int = 1;
pub const ALGORITHM_AUTOMATIC: c_int = 0;
pub const ALGORITHM_GOLDFEATHER: c_int = 1;
pub const ALGORITHM_SCS: c_int = 2;
pub const OPTION_ALGORITHM: c_int = 0;
pub const OPTION_DEPTH_COMPLEXITY: c_int = 1;
pub const OPTION_OFFSCREEN: c_int = 2;
pub type RenderFn = unsafe extern "C" fn(*mut c_void);
#[repr(C)]
pub struct OcsgPrimitive {
_opaque: [u8; 0],
}
unsafe extern "C" {
pub safe fn opencsg_init_gl();
pub fn opencsg_primitive_new(
operation: c_int,
convexity: c_uint,
callback: RenderFn,
user_data: *mut c_void,
) -> *mut OcsgPrimitive;
pub fn opencsg_primitive_free(prim: *mut OcsgPrimitive);
pub fn opencsg_primitive_set_bounding_box(
prim: *mut OcsgPrimitive,
minx: f32,
miny: f32,
minz: f32,
maxx: f32,
maxy: f32,
maxz: f32,
);
pub fn opencsg_render_primitives(
primitives: *mut *mut OcsgPrimitive,
count: c_int,
);
pub safe fn opencsg_set_option(option_type: c_int, setting: c_int);
pub safe fn opencsg_free_resources();
}
pub fn init_gl() {
opencsg_init_gl();
}
pub fn set_option(option_type: c_int, setting: c_int) {
opencsg_set_option(option_type, setting);
}
pub fn free_resources() {
opencsg_free_resources();
}
pub unsafe fn render(primitives: &mut [*mut OcsgPrimitive]) {
if primitives.is_empty() {
return;
}
unsafe {
opencsg_render_primitives(
primitives.as_mut_ptr(),
primitives.len() as c_int,
);
}
}
pub unsafe fn primitive_new(
operation: c_int,
convexity: u32,
callback: RenderFn,
user_data: *mut c_void,
) -> *mut OcsgPrimitive {
unsafe {
opencsg_primitive_new(operation, convexity as c_uint, callback, user_data)
}
}
pub unsafe fn primitive_free(prim: *mut OcsgPrimitive) {
unsafe {
opencsg_primitive_free(prim);
}
}
pub unsafe fn primitive_set_bbox(
prim: *mut OcsgPrimitive,
minx: f32,
miny: f32,
minz: f32,
maxx: f32,
maxy: f32,
maxz: f32,
) {
unsafe {
opencsg_primitive_set_bounding_box(
prim, minx, miny, minz, maxx, maxy, maxz,
);
}
}