1+ //! viewport.rs - Low level viewport management for the render context.
2+
3+ /// Viewport is a rectangle that defines the area of the screen that will be
4+ /// rendered to. For instance, if the viewport is set to x=0, y=0, width=100,
5+ /// height=100, then only the top left 100x100 pixels of the screen will be
6+ /// rendered to.
17#[ derive( Debug , Clone , PartialEq ) ]
28pub struct ViewPort {
39 viewport : gfx_hal:: pso:: Viewport ,
410}
511
6- impl ViewPort { }
7-
12+ /// A builder for `Viewport`.
813pub struct ViewPortBuilder {
914 x : i16 ,
1015 y : i16 ,
1116}
1217
1318impl ViewPortBuilder {
19+ /// Create a new `ViewportBuilder`.
1420 pub fn new ( ) -> Self {
1521 return ViewPortBuilder { x : 0 , y : 0 } ;
1622 }
@@ -49,13 +55,16 @@ pub mod internal {
4955
5056#[ cfg( test) ]
5157pub mod tests {
58+ /// Test the viewport builder in it's default state.
5259 #[ test]
53- fn viewport_builder_defaults ( ) {
60+ fn viewport_builder_default_initial_state ( ) {
5461 let viewport_builder = super :: ViewPortBuilder :: new ( ) ;
5562 assert_eq ! ( viewport_builder. x, 0 ) ;
5663 assert_eq ! ( viewport_builder. y, 0 ) ;
5764 }
5865
66+ /// Test that the viewport builder can be configured with specific
67+ /// coordinates.
5968 #[ test]
6069 fn viewport_builder_with_coordinates ( ) {
6170 let viewport_builder =
@@ -65,7 +74,7 @@ pub mod tests {
6574 }
6675
6776 #[ test]
68- fn viewport_builder_build ( ) {
77+ fn viewport_builder_builds_successfully ( ) {
6978 let viewport_builder =
7079 super :: ViewPortBuilder :: new ( ) . with_coordinates ( 10 , 10 ) ;
7180 let viewport = viewport_builder. build ( 100 , 100 ) ;
0 commit comments