use hao_il2cpp_runtime::Result;
use crate::{
bindings::{
GL_BEGIN, GL_CLEAR, GL_COLOR, GL_END, GL_LOAD_ORTHO, GL_LOAD_PIXEL_MATRIX, GL_POP_MATRIX,
GL_PUSH_MATRIX, GL_TEXCOORD2, GL_VERTEX3,
},
Color,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "reflect", derive(facet::Facet))]
#[cfg_attr(feature = "reflect", repr(C))]
pub enum Mode {
Lines = 1,
LineStrip = 2,
Triangles = 4,
TriangleStrip = 5,
Quads = 7,
}
pub fn begin(mode: Mode) -> Result<()> {
GL_BEGIN.call((mode as i32,))
}
pub fn end() -> Result<()> {
GL_END.call(())
}
pub fn draw(mode: Mode, body: impl FnOnce()) -> Result<()> {
begin(mode)?;
body();
end()
}
pub fn color(color: Color) -> Result<()> {
GL_COLOR.call((color,))
}
pub fn vertex3(x: f32, y: f32, z: f32) -> Result<()> {
GL_VERTEX3.call((x, y, z))
}
pub fn vertex(x: f32, y: f32) -> Result<()> {
vertex3(x, y, 0.0)
}
pub fn tex_coord(u: f32, v: f32) -> Result<()> {
GL_TEXCOORD2.call((u, v))
}
pub fn load_pixel_matrix(left: f32, right: f32, bottom: f32, top: f32) -> Result<()> {
GL_LOAD_PIXEL_MATRIX.call((left, right, bottom, top))
}
pub fn load_ortho() -> Result<()> {
GL_LOAD_ORTHO.call(())
}
pub fn clear(clear_depth: bool, color: Color) -> Result<()> {
GL_CLEAR.call((clear_depth, true, color, 1.0))
}
pub fn push_matrix() -> Result<()> {
GL_PUSH_MATRIX.call(())
}
pub fn pop_matrix() -> Result<()> {
GL_POP_MATRIX.call(())
}