use crate::{dx::*, ext::tdx::*};
pub struct Screen {
pub d: bool,
pub h: i32
}
impl Tr for Screen {
fn as_screen(&self) -> Screen { Screen{d: false, h: self.h} }
fn handle(&self) -> i32 { self.h }
fn dispose(&mut self) {
if self.d && self.h != 0 {
unsafe { DeleteGraph(self.h, FALSE); } self.h = 0;
}
}
}
impl Drop for Screen {
fn drop(&mut self) { self.dispose(); }
}
impl Screen {
pub fn make(xsz: i32, ysz: i32, trans: i32) -> Self {
Screen{d: true, h: unsafe { MakeScreen(xsz, ysz, trans) } }
}
pub fn set_draw(&self) {
unsafe { SetDrawScreen(self.h); }
}
}
pub struct Graph {
pub d: bool,
pub h: i32
}
impl Tr for Graph {
fn as_graph(&self) -> Graph { Graph{d: false, h: self.h} }
fn handle(&self) -> i32 { self.h }
fn dispose(&mut self) {
if self.d && self.h != 0 {
unsafe { DeleteGraph(self.h, FALSE); }
self.h = 0;
}
}
}
impl Drop for Graph {
fn drop(&mut self) { self.dispose(); }
}
impl Graph {
pub fn make(xsz: i32, ysz: i32, not_use_3d_flag: i32) -> Self {
Graph{d: true, h: unsafe { MakeGraph(xsz, ysz, not_use_3d_flag) } }
}
pub fn load(n: &String) -> Self {
Graph{d: true, h: unsafe { LoadGraph(n.as_ptr()) } }
}
pub fn get_draw_screen(&self, l: i32, t: i32, r: i32, b: i32,
use_client_flag: i32) {
unsafe { GetDrawScreenGraph(l, t, r, b, self.h, use_client_flag); }
}
pub fn draw(&self, x: i32, y: i32, trans: i32) {
unsafe { DrawGraph(x, y, self.h, trans); }
}
pub fn draw_turn(&self, x: i32, y: i32, trans: i32) {
unsafe { DrawTurnGraph(x, y, self.h, trans); }
}
pub fn draw_extend(&self, l: i32, t: i32, r: i32, b: i32, trans: i32) {
unsafe { DrawExtendGraph(l, t, r, b, self.h, trans); }
}
pub fn draw_rota(&self, x: i32, y: i32, extrate: f64, angle: f64,
trans: i32, reversex: i32, reversey: i32) {
unsafe {
DrawRotaGraph(x, y, extrate, angle, self.h, trans, reversex, reversey);
}
}
pub fn draw_modi(&self, xlt: i32, ylt: i32, xrt: i32, yrt: i32,
xrb: i32, yrb: i32, xlb: i32, ylb: i32, trans: i32) {
unsafe {
DrawModiGraph(xlt, ylt, xrt, yrt, xrb, yrb, xlb, ylb, self.h, trans);
}
}
pub fn draw_rect(&self, x: i32, y: i32, srcx: i32, srcy: i32, w: i32, h: i32,
trans: i32, reversex: i32, reversey: i32) {
unsafe {
DrawRectGraph(x, y, srcx, srcy, w, h, self.h, trans, reversex, reversey);
}
}
pub fn draw_rect_extend(&self, l: i32, t: i32, r: i32, b: i32,
srcx: i32, srcy: i32, w: i32, h: i32, trans: i32) {
unsafe {
DrawRectExtendGraph(l, t, r, b, srcx, srcy, w, h, self.h, trans);
}
}
pub fn set_to_shader(&self, i: i32) {
unsafe { SetUseTextureToShader(i, self.h); }
}
pub fn get_size(&self) -> (i32, i32) {
let mut w = 0i32;
let mut h = 0i32;
unsafe { GetGraphSize(self.h, &mut w as *mut i32, &mut h as *mut i32); }
(w, h)
}
}