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

54 lines
1.2 KiB
Rust

use able_graphics_library::{AglApi, HEIGHT, WIDTH};
use able_graphics_library::{Point, RGBA};
use graphics_api_impl::GraphicsRenderer;
mod graphics_api_impl;
extern crate mini_gl_fb;
fn main() {
let mut xyz = GraphicsRenderer::new();
// Create the event loop and framebuffer
let (mut event_loop, mut fb) = mini_gl_fb::gotta_go_fast("AGL", WIDTH as f64, HEIGHT as f64);
// 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,
},
);
// 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)
}