Skip to content

Commit 9bf6a00

Browse files
authored
Merge pull request glium#2070 from justincredible/doc-tests
Doc test fixes
2 parents 554e6e3 + 31ed711 commit 9bf6a00

File tree

13 files changed

+68
-28
lines changed

13 files changed

+68
-28
lines changed

src/buffer/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
//! `implement_buffer_content!` macro on them. You must then use the `empty_unsized` constructor.
2626
//!
2727
//! ```no_run
28-
//! # #[macro_use] extern crate glium;
29-
//! # fn example(display: glium::Display) {
28+
//! # use glium::implement_buffer_content;
29+
//! # use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
30+
//! # fn example<T>(display: glium::Display<T>) where T: SurfaceTypeTrait + ResizeableSurface {
3031
//! # use std::mem;
3132
//! # use glium::buffer::{BufferType, BufferMode};
3233
//! struct Data {

src/context/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ impl Context {
510510
/// ## Example
511511
///
512512
/// ```no_run
513-
/// # fn example(display: glium::Display) {
513+
/// # use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
514+
/// # fn example<T>(display: glium::Display<T>) where T: SurfaceTypeTrait + ResizeableSurface {
514515
/// let pixels: Result<Vec<Vec<(u8, u8, u8, u8)>>, _> = display.read_front_buffer();
515516
/// # }
516517
/// ```

src/debug.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ pub enum MessageType {
101101
/// ## Example
102102
///
103103
/// ```no_run
104-
/// # fn example(display: glium::Display) {
104+
/// # use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
105+
/// # fn example<T>(display: glium::Display<T>) where T: SurfaceTypeTrait + ResizeableSurface {
105106
/// let before = glium::debug::TimestampQuery::new(&display);
106107
/// // do some stuff here
107108
/// let after = glium::debug::TimestampQuery::new(&display);

src/draw_parameters/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
//! `SamplesPassedQuery` allows you to know the number of samples that have been drawn.
2121
//!
2222
//! ```no_run
23-
//! # fn example(display: glium::Display) {
23+
//! # use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
24+
//! # fn example<T>(display: glium::Display<T>) where T: SurfaceTypeTrait + ResizeableSurface {
2425
//! let query = glium::draw_parameters::SamplesPassedQuery::new(&display).unwrap();
2526
//! let params = glium::DrawParameters {
2627
//! samples_passed_query: Some((&query).into()),

src/framebuffer/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ In order to draw on a texture, use a `SimpleFrameBuffer`. This framebuffer is co
55
shaders that write to `gl_FragColor`.
66
77
```no_run
8-
# fn example(display: glium::Display, texture: glium::texture::Texture2d) {
8+
# use glium::texture::Texture2d;
9+
# use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
10+
# fn example<T>(display: glium::Display<T>, texture: Texture2d)
11+
# where T: SurfaceTypeTrait + ResizeableSurface {
912
let framebuffer = glium::framebuffer::SimpleFrameBuffer::new(&display, &texture);
1013
// framebuffer.draw(...); // draws over `texture`
1114
# }
@@ -16,7 +19,9 @@ a `MultiOutputFrameBuffer`.
1619
1720
```no_run
1821
# use glium::texture::Texture2d;
19-
# fn example(display: glium::Display, texture1: Texture2d, texture2: Texture2d) {
22+
# use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
23+
# fn example<T>(display: glium::Display<T>, texture1: Texture2d, texture2: Texture2d)
24+
# where T: SurfaceTypeTrait + ResizeableSurface {
2025
let output = [ ("output1", &texture1), ("output2", &texture2) ];
2126
let framebuffer = glium::framebuffer::MultiOutputFrameBuffer::new(&display, output.iter().cloned());
2227
// framebuffer.draw(...);

src/macros.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ macro_rules! uniform {
7777
/// ## Example
7878
///
7979
/// ```rust
80+
/// # #[macro_use] extern crate glium;
8081
/// # use glium::uniform;
8182
/// # fn main(){
82-
/// let uniforms = dynamic_uniform!{
83-
/// color: [1.0, 1.0, 0.0, 1.0],
84-
/// some_value: 12i32,
83+
/// let mut uniforms = dynamic_uniform!{
84+
/// color: &[1.0, 1.0, 0.0, 1.0],
85+
/// some_value: &12i32,
8586
/// };
8687
///
87-
/// uniforms.add("another_value", 1.5f32);
88+
/// uniforms.add("another_value", &1.5f32);
8889
/// # }
8990
/// ```
9091
///
@@ -139,6 +140,11 @@ macro_rules! dynamic_uniform{
139140
///
140141
/// You can specify a normalize option for attributes.
141142
/// ```
143+
/// # #[derive(Clone, Copy)]
144+
/// # struct Vertex {
145+
/// # position: [f32; 2],
146+
/// # tex_coords: [f32; 2],
147+
/// # }
142148
/// # use glium::implement_vertex;
143149
/// # fn main() {
144150
/// implement_vertex!(Vertex, position normalize(false), tex_coords normalize(false));
@@ -148,6 +154,11 @@ macro_rules! dynamic_uniform{
148154
///
149155
/// You can specify a location option for attributes.
150156
/// ```
157+
/// # #[derive(Clone, Copy)]
158+
/// # struct Vertex {
159+
/// # position: [f32; 2],
160+
/// # tex_coords: [f32; 2],
161+
/// # }
151162
/// # use glium::implement_vertex;
152163
/// # fn main() {
153164
/// implement_vertex!(Vertex, position location(0), tex_coords location(1));
@@ -516,7 +527,8 @@ macro_rules! implement_uniform_block {
516527
///
517528
/// ```no_run
518529
/// use glium::program;
519-
/// # fn example(display: glium::Display) {
530+
/// # use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
531+
/// # fn example<T>(display: glium::Display<T>) where T: SurfaceTypeTrait + ResizeableSurface {
520532
/// let program = program!(&display,
521533
/// 300 => {
522534
/// vertex: r#"

src/program/program.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ impl Program {
187187
/// # Example
188188
///
189189
/// ```no_run
190-
/// # fn example(display: glium::Display) {
190+
/// # use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
191+
/// # fn example<T>(display: glium::Display<T>) where T: SurfaceTypeTrait + ResizeableSurface {
191192
/// # let vertex_source = ""; let fragment_source = ""; let geometry_source = "";
192193
/// let program = glium::Program::from_source(&display, vertex_source, fragment_source,
193194
/// Some(geometry_source));

src/sync.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ pub struct SyncNotSupportedError;
2222
/// ## Example
2323
///
2424
/// ```no_run
25-
/// # fn example(display: glium::Display) {
25+
/// # use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
26+
/// # fn example<T>(display: glium::Display<T>) where T: SurfaceTypeTrait + ResizeableSurface {
2627
/// # fn do_something<T>(_: &T) {}
2728
/// let fence = glium::SyncFence::new(&display).unwrap();
2829
/// do_something(&display);

src/texture/bindless.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Bindless textures are a very recent feature that is supported only by recent har
1717
drivers. `resident` will return an `Err` if this feature is not supported.
1818
1919
```no_run
20-
# fn example(display: glium::Display, texture: glium::texture::Texture2d) {
20+
# use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
21+
# fn example<T>(display: glium::Display<T>, texture: glium::texture::Texture2d)
22+
# where T: SurfaceTypeTrait + ResizeableSurface {
2123
let texture = texture.resident().unwrap();
2224
# }
2325
```
@@ -42,7 +44,9 @@ struct UniformBuffer<'a> {
4244
4345
implement_uniform_block!(UniformBuffer<'a>, texture, some_value);
4446
45-
# fn example(display: glium::Display, texture: glium::texture::bindless::ResidentTexture) {
47+
# use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
48+
# fn example<T>(display: glium::Display<T>, texture: glium::texture::bindless::ResidentTexture)
49+
# where T: SurfaceTypeTrait + ResizeableSurface {
4650
let uniform_buffer = glium::uniforms::UniformBuffer::new(&display, UniformBuffer {
4751
texture: glium::texture::TextureHandle::new(&texture, &Default::default()),
4852
some_value: 5.0,

src/uniforms/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ The currently preferred way to do this is to use the `uniform!` macro provided b
77
88
```no_run
99
# use glium::uniform;
10-
# fn example(display: glium::Display) {
10+
# use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
11+
# fn example<T>(display: glium::Display<T>) where T: SurfaceTypeTrait + ResizeableSurface {
1112
# let tex: f32 = 0.0;
1213
# let matrix: f32 = 0.0;
1314
let uniforms = uniform! {
@@ -25,7 +26,9 @@ In order to customize the way a texture is being sampled, you must use a `Sample
2526
2627
```no_run
2728
# use glium::uniform;
28-
# fn example(display: glium::Display, texture: glium::texture::Texture2d) {
29+
# use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
30+
# fn example<T>(display: glium::Display<T>, texture: glium::texture::Texture2d)
31+
# where T: SurfaceTypeTrait + ResizeableSurface {
2932
let uniforms = uniform! {
3033
texture: glium::uniforms::Sampler::new(&texture)
3134
.magnify_filter(glium::uniforms::MagnifySamplerFilter::Nearest)
@@ -41,7 +44,9 @@ can link the buffer to the name of the block, just like any other uniform.
4144
4245
```no_run
4346
# use glium::uniform;
44-
# fn example(display: glium::Display, texture: glium::texture::Texture2d) {
47+
# use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
48+
# fn example<T>(display: glium::Display<T>, texture: glium::texture::Texture2d)
49+
# where T: SurfaceTypeTrait + ResizeableSurface {
4550
let program = glium::Program::from_source(&display,
4651
"
4752
#version 110
@@ -83,7 +88,9 @@ A subroutine uniform is unique per shader stage, and not per program.
8388
8489
```no_run
8590
# use glium::uniform;
86-
# fn example(display: glium::Display, texture: glium::texture::Texture2d) {
91+
# use glutin::surface::{ResizeableSurface, SurfaceTypeTrait};
92+
# fn example<T>(display: glium::Display<T>, texture: glium::texture::Texture2d)
93+
# where T: SurfaceTypeTrait + ResizeableSurface {
8794
let program = glium::Program::from_source(&display,
8895
"
8996
#version 150

0 commit comments

Comments
 (0)