This repository has been archived on 2021-12-01. You can view files and clone it, but cannot push or open issues/pull-requests.
AGL_Simple_Impl/src/main.rs

109 lines
2.3 KiB
Rust

use able_graphics_library::{AglApi, HEIGHT, WIDTH};
use able_graphics_library::{Point, RGBA};
use graphics_api_impl::GraphicsRenderer;
use mini_gl_fb::{
config,
glutin::{dpi::LogicalSize, event_loop::EventLoop},
};
mod graphics_api_impl;
extern crate mini_gl_fb;
fn main() {
let mut xyz = GraphicsRenderer::new();
// Create the event loop and framebuffer
// mini_gl_fb::gotta_go_fast( );
let mut event_loop = EventLoop::new();
let mut fb = mini_gl_fb::get_fancy(
config! {
window_title: String::from("AGL"),
window_size: LogicalSize::new(WIDTH as f64, HEIGHT as f64),
buffer_size: Some(LogicalSize::new(WIDTH as u32, HEIGHT as u32)),
resizable: true
},
&event_loop,
);
// Fill the buffer with something
let mut buffer = vec![[0, 0, 0, 0]; WIDTH * HEIGHT];
// Use cool fancy drawing api
{
xyz.clear(RGBA {
r: 255,
g: 255,
b: 255,
a: 255,
});
xyz.put_pixel(
Point { x: 34, y: 43 },
RGBA {
r: 123,
g: 123,
b: 123,
a: 123,
},
);
xyz.put_pixel(
Point { x: 346, y: 199 },
RGBA {
r: 255,
g: 0,
b: 0,
a: 123,
},
);
}
xyz.put_line(
Point { x: 3, y: 30 },
Point { x: 324, y: 50 },
1,
RGBA {
r: 0,
g: 0,
b: 0,
a: 0,
},
);
xyz.draw_text(
Point { x: 100, y: 90 },
24,
RGBA {
r: 0,
g: 0,
b: 0,
a: 0,
},
"Hello".to_string(),
);
xyz.put_triangle(
Point { x: 10, y: 40 },
Point { x: 30, y: 100 },
Point { x: 10, y: 90 },
8,
RGBA {
r: 8,
g: 7,
b: 7,
a: 255,
},
);
// update pixels
for x in 0..600 * 400 {
buffer[x] = [xyz.buff[x].r, xyz.buff[x].g, xyz.buff[x].b, xyz.buff[x].a]
}
fb.update_buffer(&buffer);
fb.persist(&mut event_loop);
// Show the window until the user decides to quit (close button, or Esc)
}