Expand description
The graphics module performs the perhaps most important task of ggez, which is drawing things onto the screen.
The rough workflow for this is usually as follows:
- Create something that you want to render (
Meshes,Images,InstanceArrays orTexts). - Create a
Canvasto render them onto (usually by callingCanvas::from_frame, to draw directly onto the screen). - (Select a custom shader and/or blend mode if you desire.)
- Queue draw calls by calling the appropriate draw method on
Canvas(Canvas::draw,Canvas::draw_<whatever>). - (Go back to step 3 if you want to add more draw calls with different shaders or blend modes.)
- Submit the draw queue by calling
Canvas::finish.
A Canvas represents a single render pass, operating on a certain render target.
You can create Canvases that render to an image, instead of directly to the screen, with
Canvas::from_image and other related functions. With these you can, for example, render your
scene onto an Image held by a Canvas first and then render that Image onto the screen,
using a different shader, to do some post-processing.
The module also handles the creation of Images and other drawable objects and the screen
coordinate system / projection matrix through Canvas.
Re-exports§
pub use context::*;
Modules§
- context
- Module for the graphics context dealing with wgpu
Structs§
- Blend
Component - Describes a blend component of a
BlendState. - Blend
Mode - Describes the blend mode used when drawing images.
- Canvas
- Canvases are the main method of drawing meshes and text to images in ggez.
- Color
- A RGBA color in the
sRGBcolor space represented asf32’s in the range[0.0-1.0] - Draw
Param - A struct containing all the necessary info for drawing with parameters.
- Fill
Options - Parameters for the fill tessellator.
- Font
Data - Font data that can be used to create a new font in
GraphicsContext. - Image
- Handle to an image stored in GPU memory.
- Instance
Array - Array of instances for fast rendering of many meshes.
- Linear
Color - A RGBA color in the linear color space, suitable for shoving into a shader.
- Mesh
- Mesh data stored on the GPU as a vertex and index buffer. Cheap to clone.
- Mesh
Builder - Builder pattern for constructing meshes.
- Mesh
Data - Borrowed mesh data.
- PxScale
- Pixel scale.
- Quad
- A
Drawableunit type that maps to a simple 1x1 quad mesh. - Rect
- A simple 2D rectangle.
- Sampler
- Sampler state that is used when sampling images on the GPU.
- Screen
Image - An image which is sized relative to the screen. This is primarily for canvas images.
- Shader
- A custom shader that can be used to render with shader effects.
- Shader
Builder - Builder pattern for assembling shaders.
- Shader
Params - Parameters that can be passed to a custom shader, including uniforms, images, and samplers.
- Shader
Params Builder - A builder for
ShaderParams - Stroke
Options - Parameters for the tessellator.
- Text
- Drawable text object. Essentially a list of
TextFragment. and some cached size information. - Text
Fragment - Parameters of a single piece (“fragment”) of text, including font, color, and size.
- Text
Layout - Describes text alignment along both axes.
- Vertex
- Vertex format uploaded to vertex buffers.
Enums§
- Blend
Factor - Alpha blend factor.
- Blend
Operation - Alpha blend operation.
- Clamp
Mode - Describes the clamping mode of a sampler, used when the shader writes to sample outside of texture boundaries.
- Draw
Mode - Specifies whether a mesh should be drawn filled or as an outline.
- Fill
Rule - The fill rule defines how to determine what is inside and what is outside of the shape.
- Filter
Mode - Describes the filter mode of a sampler, used when magnification or minification of a texture occurs (i.e. scaling).
- LineCap
- Line cap as defined by the SVG specification.
- Line
Join - Line join as defined by the SVG specification.
- Text
Align - Describes text alignment along a single axis.
- Transform
- A struct that represents where to put a drawable object.
Traits§
- Drawable
- All types that can be drawn onto a canvas implement the
Drawabletrait.
Functions§
- default_
shader - The default shader.
- default_
text_ shader - The default text shader.
- draw
Deprecated - Draws the given Drawable object to the screen by calling its draw() method.
- draw_
queued_ text Deprecated - Draws all of the Texts added via
queue_text. - queue_
text Deprecated - Draws text.
- set_
window_ icon Deprecated - Sets the window icon.
Nonefor path removes the icon. - set_
window_ position Deprecated - Sets the window position.
- set_
window_ title Deprecated - Sets the window title.
- transform_
rect - Applies
DrawParamtoRect. - window
Deprecated - Returns a reference to the Winit window.
Type Aliases§
- Image
Encoding Format - Describes the format of an encoded image.
- Image
Format - Describes the pixel format of an image.
- ZIndex
- Value describing the Z “coordinate” of a draw.