1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//! Draw your game with an explicit 2D graphics API.
//!
//! Graphics in Coffee focus on simplicity while __reducing global state__.
//! Operations like matrix transformations, off-screen rendering and draw calls
//! have always an explicit scope. In Coffee, you do not have to remember to pop
//! a transformation from the matrix stack, reset the render target, reset the
//! screen coordinates, etc. There are no global functions!
//!
//! # Basic concepts
//! The graphics module revolves around three concepts: [graphics processors],
//! [targets], and [resources].
//!
//! ## Graphics processors
//! A [`Gpu`] represents a link between your game and a graphics processor. It
//! is necessary to perform any kind of graphical operation, like loading
//! resources and drawing.
//!
//! As of now, you will only have one [`Gpu`] available at a given time.
//! However, in the future, the graphics module may allow recording graphical
//! operations concurrently.
//!
//! ## Targets
//! A [`Target`] represents a drawable target on a specific [`Gpu`]. A
//! [`Transformation`] can be applied to them.
//!
//! Any kind of draw operation needs an explicit [`Target`]. For example,
//! [`Image::draw`] needs a reference to a [`Target`] as the last argument.
//!
//! Currently, there are two ways to obtain a [`Target`]: either from a
//! [`Frame`] or a [`Canvas`], using the `as_target` method.
//!
//! ## Resources
//! A resource is the source of some drawable object. In Coffee, there is no
//! `Resource` or `Drawable` type/trait. Resources are represented by different
//! types like [`Image`], [`Font`], [`TextureArray`], etc.
//!
//! # Getting started
//! You should probably start your [`Game::draw`] implementation by clearing
//! the provided [`Frame`]:
//!
//! ```
//! use coffee::graphics::{Color, Frame, Window};
//! use coffee::{Game, Timer};
//! # use coffee::Result;
//! # use coffee::graphics::Gpu;
//! # use coffee::load::Task;
//! #
//! # struct MyGame;
//!
//! impl Game for MyGame {
//! # type Input = ();
//! # type LoadingScreen = ();
//! #
//! # fn load(window: &Window) -> Task<MyGame> {
//! # Task::succeed(|| MyGame)
//! # }
//! #
//! // ...
//!
//! fn draw(&mut self, frame: &mut Frame, _timer: &Timer) {
//! frame.clear(Color::BLACK);
//!
//! // Use your resources here...
//! // self.image.draw(Sprite { ... }, &mut frame.as_target());
//! }
//! }
//! ```
//!
//! You can load your resources during [`Game::load`]. Check out the different
//! types in this module to get a basic understanding of which kind of resources
//! are supported.
//!
//! [graphics processors]: #graphics-processors
//! [targets]: #targets
//! [resources]: #resources
//! [`Gpu`]: struct.Gpu.html
//! [`Target`]: struct.Target.html
//! [`Transformation`]: struct.Transformation.html
//! [`Frame`]: struct.Frame.html
//! [`Canvas`]: struct.Canvas.html
//! [`Image`]: struct.Image.html
//! [`Image::draw`]: struct.Image.html#method.draw
//! [`TextureArray`]: texture_array/struct.TextureArray.html
//! [`Font`]: struct.Font.html
//! [`Game::draw`]: ../trait.Game.html#tymethod.draw
//! [`Game::load`]: ../trait.Game.html#tymethod.load
use backend_gfx as gpu;
use backend_wgpu as gpu;
pub
pub use Image;
pub use Batch;
pub use Canvas;
pub use Color;
pub use Font;
pub use Gpu;
pub use Mesh;
pub use Point;
pub use ;
pub use Rectangle;
pub use Shape;
pub use Sprite;
pub use Target;
pub use ;
pub use TextureArray;
pub use Transformation;
pub use Vector;
pub use ;