Module ggez::graphics [−][src]
The graphics
module performs the actual drawing of images, text, and other
objects with the Drawable
trait. It also handles basic loading of images
and text.
This module also manages graphics state, coordinate systems, etc. The default coordinate system has the origin in the upper-left corner of the screen, with Y increasing downwards.
Modules
pipe | |
spritebatch |
A |
Structs
BitmapFont |
A bitmap font where letter widths are infered |
CanvasGeneric |
A generic canvas independent of graphics backend. This type should probably
never be used directly; use |
Color |
A RGBA color in the |
DrawParam |
A struct containing all the necessary info for drawing a Drawable. |
EmptyConst |
A type for empty shader data for shaders that do not require any additional data to be sent to the GPU |
FontId |
Id for a font, the default |
GlBackendSpec |
A backend specification for OpenGL.
This is different from |
Globals |
Internal structure containing global shader state. |
ImageGeneric |
Generic in-GPU-memory image data available to be drawn on the screen. |
InstanceProperties |
Internal structure containing values that are different for each drawable object. |
Mesh |
2D polygon mesh. |
MeshBuilder |
A builder for creating |
Rect |
A simple 2D rectangle. |
ShaderGeneric |
A |
ShaderLock |
A lock for RAII shader regions. The shader automatically gets cleared once the lock goes out of scope, restoring the previous shader (if any). |
Text |
Drawable text created from a |
TextCached |
Drawable text. Can be either monolithic, or consist of differently-formatted fragments. |
TextFragment |
A piece of text with optional color, font and font scale information.
These options take precedence over any similar field/argument.
Can be implicitly constructed from |
Vertex |
Internal structure containing vertex data. |
Enums
BlendMode |
An enum for specifying default and custom blend modes |
DrawMode |
Specifies whether a shape should be drawn filled or as an outline. |
FilterMode |
Specifies what blending method to use when scaling up/down images. |
Font |
A font that defines the shape of characters drawn on the screen. Can be created from a .ttf file or from an image (bitmap fonts). |
HorizontalAlign |
Describes horizontal alignment preference for positioning & bounds. |
ImageFormat |
The supported formats for saving an image. |
VerticalAlign |
Describes vertical alignment preference for positioning & bounds. Currently a placeholder for future functionality. |
Constants
BLACK |
Black |
DEFAULT_FONT_SCALE |
Default scale, used as |
WHITE |
White |
Traits
BackendSpec |
A marker trait saying that something is a label for a particular backend, with associated gfx-rs types for that backend. |
Drawable |
All types that can be drawn on the screen implement the |
ShaderHandle |
A trait that is used to create trait objects to abstract away the
Structure |
Functions
apply_transformations |
Calculates the new total transformation (Model-View-Projection) matrix based on the matrices at the top of the transform and view matrix stacks and sends it to the graphics card. |
circle |
Draw a circle. |
clear |
Clear the screen to the background color. |
clear_shader |
Clears the the current shader for the Context, restoring the default shader. |
draw |
Draws the given |
draw_ex |
Draws the given |
ellipse |
Draw an ellipse. |
get_background_color |
Returns the current background color. |
get_color |
Returns the current foreground color. |
get_default_filter |
Get the default filter mode for new images. |
get_depth_view |
Returns the gfx-rs depth target object for ggez's rendering context. |
get_device |
Returns the gfx-rs |
get_display_count |
Returns the number of connected displays. |
get_drawable_size |
Returns the size of the window's underlying drawable in pixels as (width, height).
This may return a different value than |
get_encoder |
Returns the gfx-rs |
get_factory |
Returns the gfx-rs |
get_fullscreen_modes |
Returns a |
get_gfx_objects |
Returns raw |
get_projection |
Gets a copy of the context's raw projection matrix |
get_renderer_info |
Returns a string that tells a little about the obtained rendering mode. It is supposed to be human-readable and will change; do not try to parse information out of it! |
get_screen_coordinates |
Returns a rectangle defining the coordinate system of the screen.
It will be |
get_screen_render_target |
Returns the gfx-rs color target object for ggez's rendering context. |
get_size |
Returns the size of the window in pixels as (width, height). |
get_transform |
Gets a copy of the context's current transform matrix |
get_window |
Returns a reference to the SDL window. Ideally you should not need to use this because ggez would provide all the functions you need without having to dip into SDL itself. But life isn't always ideal. |
get_window_mut |
Returns a mutable reference to the SDL window. |
is_fullscreen |
Queries the fullscreen state of the window subsystem. If true, then the game is running in fullscreen mode. |
line |
Draws a line of one or more connected segments. |
origin |
Sets the current model transform to the origin transform (no transformation) |
points |
Draws points (as rectangles) |
polygon |
Draws a closed polygon |
pop_transform |
Pops the transform matrix off the top of the transform
(model) matrix stack of the |
present |
Tells the graphics system to actually put everything on the screen.
Call this at the end of your |
push_transform |
Pushes a homogeneous transform matrix to the top of the transform
(model) matrix stack of the |
rectangle |
Draws a rectangle. |
screenshot |
Take a screenshot by outputting the current render surface (screen or selected canvas) to a PNG file. |
set_background_color |
Sets the background color. Default: blue. |
set_blend_mode |
Sets the blend mode of the currently active shader program |
set_canvas |
Set the canvas to render to. Specifying |
set_color |
Sets the foreground color, which will be used for drawing rectangles, lines, etc. Default: white. |
set_default_filter |
Sets the default filter mode used to scale images. |
set_fullscreen |
Toggles the fullscreen state of the window subsystem |
set_mode |
Sets the window mode, such as the size and other properties. |
set_projection |
Sets the raw projection matrix to the given homogeneous transformation matrix. |
set_resolution |
Sets the window resolution based on the specified width and height |
set_screen_coordinates |
Sets the bounds of the screen viewport. |
set_shader |
Set the current shader for the Context to render with |
set_transform |
Sets the current model transformation to the given homogeneous transformation matrix. |
transform |
Premultiplies the given transform with the current model transform. |
transform_projection |
Premultiplies the given transformation matrix with the current projection matrix |
use_shader |
Use a shader until the returned lock goes out of scope |
Type Definitions
Canvas |
A canvas that can be rendered to instead of the screen (sometimes referred
to as "render target" or "render to texture"). Set the canvas with the
|
Image |
In-GPU-memory image data available to be drawn on the screen, using the OpenGL backend. |
Layout |
Aliased type from |
Matrix4 |
A 4 dimensional matrix representing an arbitrary 3d transformation |
Point2 |
A 2 dimensional point representing a location |
Scale |
Aliased type to allow lib usage without declaring underlying rusttype lib |
Shader |
A |
ShaderId |
An ID used by the |
Vector2 |
A 2 dimensional vector representing an offset of a location |
WrapMode |
Specifies how to wrap textures. |