use crate::core::drawing::RaylibDraw;
use crate::ffi;
use crate::ffi::Color;
#[repr(i32)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DrawMode {
Lines = ffi::RL_LINES as i32,
Triangles = ffi::RL_TRIANGLES as i32,
Quads = ffi::RL_QUADS as i32,
}
pub struct RlImmediate<'a, T: RaylibDraw>(#[allow(dead_code)] &'a mut T);
impl<T: RaylibDraw> Drop for RlImmediate<'_, T> {
fn drop(&mut self) {
unsafe { ffi::rlEnd() }
}
}
impl<'a, T: RaylibDraw> RlImmediate<'a, T> {
pub(crate) fn new(parent: &'a mut T) -> Self {
RlImmediate(parent)
}
#[inline]
pub fn vertex2f(&mut self, x: f32, y: f32) {
unsafe { ffi::rlVertex2f(x, y) }
}
#[inline]
pub fn vertex3f(&mut self, x: f32, y: f32, z: f32) {
unsafe { ffi::rlVertex3f(x, y, z) }
}
#[inline]
pub fn color4ub(&mut self, color: impl Into<Color>) {
let c = color.into();
unsafe { ffi::rlColor4ub(c.r, c.g, c.b, c.a) }
}
#[inline]
pub fn color3f(&mut self, r: f32, g: f32, b: f32) {
unsafe { ffi::rlColor3f(r, g, b) }
}
#[inline]
pub fn color4f(&mut self, r: f32, g: f32, b: f32, a: f32) {
unsafe { ffi::rlColor4f(r, g, b, a) }
}
#[inline]
pub fn texcoord2f(&mut self, x: f32, y: f32) {
unsafe { ffi::rlTexCoord2f(x, y) }
}
#[inline]
pub fn normal3f(&mut self, x: f32, y: f32, z: f32) {
unsafe { ffi::rlNormal3f(x, y, z) }
}
}