Crate gust_render

Source
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
Color handling module
draw
Every traits needed by drawable object
event
Module to handle keyboard and mouse event one day
font
font datastructures and fonctions made from Font.cpp of SFML
gl_error
gl error system
prelude
rect
Rectangle struct and all fonction
resources
ressources trait and functions
shader
Shader module
shared_window
sprite
Module to handle drawable texture that are called Sprite
spritebatch
spritebatch test system
text
text render utils
texture
This module is for texture handling Importing, Loading, Pushing into OpenGl I’m using image crate that is really useful
transform
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.
vertex
This is a module for vertex
vertex_buffer
This module encapsulate the system of vertexBuffer Here you can create a drawable object easily with a VertexArray
view
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
Window module

Macros§

pressed
Should expand from pressed!(W) -> Events::Key(Key::W, _, Action::Pressed, _)
release
repeat

Enums§

Action
Input actions.
Key
Input keys.
MouseButton
Mouse buttons. The MouseButtonLeft, MouseButtonRight, and MouseButtonMiddle aliases are supplied for convenience.

Statics§

HEIGHT
WIDTH

Type Aliases§

Coord
Matrix4
A stack-allocated, column-major, 4x4 square matrix.
Point
Vector