Skip to content

Commit 48e7c80

Browse files
committed
fix and improve docs
1 parent 48441c1 commit 48e7c80

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/sdl2/render.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,8 +2081,8 @@ impl<T: RenderTarget> Canvas<T> {
20812081
/// Render triangles, optionally using a texture.
20822082
///
20832083
/// If you have vertices in a different format, [`Canvas::render_geometry_raw`] (the advanced
2084-
/// version of this function) might allow you to do the same as this function without
2085-
/// converting the parameters.
2084+
/// version of this function) might allow you to do the same as this function without having to
2085+
/// convert the parameters to use [`Vertex`].
20862086
///
20872087
/// `indices` can be of any of the following:
20882088
/// - [`VertexIndices::Sequential`]: Vertices are rendered in sequential order. The number of
@@ -2097,7 +2097,8 @@ impl<T: RenderTarget> Canvas<T> {
20972097
/// - `&[[u8; 3]]`, `&[[u16; 3]]`, `&[[u32; 3]]` or `&[[i32; 3]]`, which work like `&[u8]`,
20982098
/// `&[u16]`, `&[u32]` or `&[i32]` but ensure at compile time that the number of indices is
20992099
/// divisible by 3.
2100-
/// - Any other (possibly user defined) type that implements `Into<VertexIndices<'_>>`.
2100+
/// - Any other (possibly user defined) type that implements
2101+
/// [`Into<VertexIndices<'_>>`][VertexIndices#trait-implementations].
21012102
#[doc(alias = "SDL_RenderGeometry")]
21022103
pub fn render_geometry<'a>(
21032104
&mut self,
@@ -2134,6 +2135,10 @@ impl<T: RenderTarget> Canvas<T> {
21342135
///
21352136
/// See the documentation of [`Canvas::render_geometry`] for usage of the `indices` parameter.
21362137
///
2138+
/// When a texture is not used, the vertex type must still be specified (because of a Rust
2139+
/// limitation, more info [here](https://github.com/rust-lang/rust/issues/36887)). This can be
2140+
/// done with turbofish syntax after `None` like so: `None::<RenderGeometryTextureParams<()>>`.
2141+
///
21372142
/// # Safety
21382143
///
21392144
/// It must be sound to [create references to](core::ptr#pointer-to-reference-conversion):
@@ -2154,9 +2159,13 @@ impl<T: RenderTarget> Canvas<T> {
21542159
/// - `positions.len() == tex_coords.len()`
21552160
///
21562161
/// Offsets must be correct.
2157-
/// - `position_offset + size_of::<FPoint>() <= size_of::<PosVertex>()`: an [`FPoint`] must fit in `PosVertex` at `position_offset` bytes from the start.
2158-
/// - `color_offset + size_of::<Color>() <= size_of::<ColorVertex>()`: a [`Color`][pixels::Color] must fit in `ColorVertex` at `color_offset` bytes from the start.
2159-
/// - `tex_coord_offset + size_of::<FPoint>() <= size_of::<TexCoordVertex>()`: an [`FPoint`] must fit in `TexCoordVertex` at `tex_coord_offset` bytes from the start.
2162+
/// - `position_offset + size_of::<FPoint>() <= size_of::<PosVertex>()`: an [`FPoint`] must fit
2163+
/// in `PosVertex` at `position_offset` bytes from the start.
2164+
/// - `color_offset + size_of::<Color>() <= size_of::<ColorVertex>()`: a
2165+
/// [`Color`][pixels::Color] must fit in `ColorVertex` at `color_offset` bytes from the
2166+
/// start.
2167+
/// - `tex_coord_offset + size_of::<FPoint>() <= size_of::<TexCoordVertex>()`: an [`FPoint`]
2168+
/// must fit in `TexCoordVertex` at `tex_coord_offset` bytes from the start.
21602169
///
21612170
/// Various sizes must fit in a [C `int`][c_int].
21622171
/// - `positions.len() <= c_int::MAX`

0 commit comments

Comments
 (0)