gust_render/lib.rs
1//! # Gust
2//! Gust is a **graphical library** written in Rust by myself (Alexandre Fourcat)
3//! Nothing really big or incredible but I inspired myself of SFML and kiss3D
4//! The idea behind it it's to make the 2019 GGJ with this motor
5//! This project is based on learning purpose and abstract everything that put me in pain
6//! when I was trying to do computer graphics.
7//! Here is some gust code
8//! ```no_run
9//! extern crate gust;
10//! extern crate glfw;
11//!
12//! use gust::sprite::Sprite;
13//! use gust::window::Window;
14//! use gust::{Vector,Point,Key};
15//! use gust::event;
16//! use gust::event::{EventHandler,Events,Event};
17//! use std::rc::Rc;
18//! use gust::color::Color;
19//! use gust::texture::{Texture};
20//! use gust::draw::{Drawer,Movable};
21//! use gust::draw::Drawable;
22//!
23//! fn main()
24//! {
25//! let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
26//! let tex_leave = Rc::new(Texture::new("examples/texture/Z.png"));
27//! let tex_dirt = Rc::new(Texture::new("examples/texture/Dirt.png"));
28//! let event_handler = EventHandler::new(&window);
29//! let mut sprite = Sprite::from(&tex_dirt);
30//! let mut leave = Sprite::from(&tex_leave);
31//!
32//! leave.set_position(Point::new(300.0, 300.0));
33//! window.set_clear_color(Color::new(0.0, 0.0, 1.0));
34//! window.enable_cursor();
35//! window.poll(None);
36//! leave.set_scale(Vector::new(0.5, 0.5));
37//! leave.set_origin_to_center().unwrap_or_else(|e| println!("{}", e));
38//! while window.is_open() {
39//! window.poll_events();
40//! leave.rotate(1.0);
41//! leave.update();
42//! sprite.update();
43//!
44//! for event in event_handler.fetch() {
45//! event_process(event, &mut window);
46//! }
47//!
48//! window.clear();
49//! window.draw(&sprite);
50//! window.draw(&leave);
51//! window.display();
52//! }
53//! }
54//!
55//! fn event_process(event: Event, window: &mut Window) {
56//! match event.1 {
57//! Events::Key(Key::Escape, _, _, _) => {
58//! window.close();
59//! },
60//! Events::MouseButton(_, _, _) => {
61//! println!("Mouse button !");
62//! },
63//! Events::CursorPos(x, y) => {
64//! println!("x: {}, y: {}", x, y);
65//! },
66//! _ => { println!("Another event !") }
67//! }
68//! }
69//! ```
70
71#![allow(dead_code)]
72#![feature(test)]
73
74extern crate freetype;
75extern crate gl;
76extern crate glfw;
77extern crate nalgebra;
78#[macro_use]
79extern crate lazy_static;
80extern crate alga;
81extern crate image;
82
83pub mod color;
84pub mod draw;
85pub mod event;
86pub mod font;
87pub mod gl_error;
88pub mod rect;
89pub mod resources;
90pub mod shader;
91pub mod shared_window;
92pub mod sprite;
93pub mod spritebatch;
94pub mod text;
95pub mod texture;
96pub mod transform;
97pub mod vertex;
98pub mod vertex_buffer;
99pub mod view;
100pub mod window;
101
102pub mod prelude {
103 pub use super::{Action, Coord, Key, MouseButtonLeft, MouseButtonRight, Point, Vector};
104 pub use color::Color;
105 pub use draw::{Context, Drawable, DrawableMut, Drawer};
106 pub use event::{Event, EventHandler, Events};
107 pub use font::Font;
108 pub use sprite::Sprite;
109 pub use spritebatch::{SpriteBatch, SpriteData};
110 pub use text::Text;
111 pub use texture::Texture;
112 pub use transform::{Movable, Rotable, Scalable, Transformable};
113 pub use view::View;
114 pub use window::Window;
115}
116
117pub use glfw::Action;
118pub use glfw::Key;
119pub use glfw::MouseButton;
120pub use glfw::MouseButtonLeft;
121pub use glfw::MouseButtonMiddle;
122pub use glfw::MouseButtonRight;
123pub use nalgebra::Matrix4;
124pub use resources::{MutResource, MutThreadResource, Resource, ThreadResource};
125
126pub type Vector<T> = nalgebra::Vector2<T>;
127pub type Point<T> = Vector<T>;
128pub type Coord = nalgebra::Vector2<usize>;
129
130pub static HEIGHT: u32 = 900;
131pub static WIDTH: u32 = 1600;