Expand description
§Gust
Gust is a graphical library written in Rust by myself (Alexandre Fourcat) Nothing really big or incredible but I inspired myself of SFML and kiss3D The idea behind it it’s to make the 2019 GGJ with this motor This project is based on learning purpose and abstract everything that put me in pain when I was trying to do computer graphics. Here is some gust code
extern crate gust;
extern crate glfw;
use gust::sprite::Sprite;
use gust::window::Window;
use gust::{Vector,Point,Key};
use gust::event;
use gust::event::{EventHandler,Events,Event};
use std::rc::Rc;
use gust::color::Color;
use gust::texture::{Texture};
use gust::draw::{Drawer,Movable};
use gust::draw::Drawable;
fn main()
{
let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
let tex_leave = Rc::new(Texture::new("examples/texture/Z.png"));
let tex_dirt = Rc::new(Texture::new("examples/texture/Dirt.png"));
let event_handler = EventHandler::new(&window);
let mut sprite = Sprite::from(&tex_dirt);
let mut leave = Sprite::from(&tex_leave);
leave.set_position(Point::new(300.0, 300.0));
window.set_clear_color(Color::new(0.0, 0.0, 1.0));
window.enable_cursor();
window.poll(None);
leave.set_scale(Vector::new(0.5, 0.5));
leave.set_origin_to_center().unwrap_or_else(|e| println!("{}", e));
while window.is_open() {
window.poll_events();
leave.rotate(1.0);
leave.update();
sprite.update();
for event in event_handler.fetch() {
event_process(event, &mut window);
}
window.clear();
window.draw(&sprite);
window.draw(&leave);
window.display();
}
}
fn event_process(event: Event, window: &mut Window) {
match event.1 {
Events::Key(Key::Escape, _, _, _) => {
window.close();
},
Events::MouseButton(_, _, _) => {
println!("Mouse button !");
},
Events::CursorPos(x, y) => {
println!("x: {}, y: {}", x, y);
},
_ => { println!("Another event !") }
}
}
Re-exports§
pub use resources::MutResource;
pub use resources::MutThreadResource;
pub use resources::Resource;
pub use resources::ThreadResource;
pub use glfw::MouseButtonLeft;
pub use glfw::MouseButtonMiddle;
pub use glfw::MouseButtonRight;
Modules§
- Color handling module
- Every traits needed by drawable object
- Module to handle keyboard and mouse event one day
- font datastructures and fonctions made from Font.cpp of SFML
- gl error system
- Rectangle struct and all fonction
- ressources trait and functions
- Shader module
- Module to handle drawable texture that are called Sprite
- spritebatch test system
- text render utils
- This module is for texture handling Importing, Loading, Pushing into OpenGl I’m using image crate that is really useful
- Transform this mod is a groupment of all traits dedicated to the movement of a gust entity. You can attach these trait to anything that you need to move.
- This is a module for vertex
- This module encapsulate the system of vertexBuffer Here you can create a drawable object easily with a VertexArray
- View system. A view is a point of view on a 2D scene. It’s like a camera filming paper. A view should be defined by sizes and left and down.
- Window module
Macros§
- Should expand from pressed!(W) -> Events::Key(Key::W, _, Action::Pressed, _)
Enums§
- Input actions.
- Input keys.
- Mouse buttons. The
MouseButtonLeft
,MouseButtonRight
, andMouseButtonMiddle
aliases are supplied for convenience.
Statics§
Type Aliases§
- A stack-allocated, column-major, 4x4 square matrix.