Struct ggez::Context[][src]

pub struct Context {
    pub filesystem: Filesystem,
    pub timer_context: TimeContext,
    pub audio_context: Box<dyn AudioContext>,
    pub keyboard_context: KeyboardContext,
    pub mouse_context: MouseContext,
    pub gamepad_context: Box<dyn GamepadContext>,
    pub continuing: bool,
    // some fields omitted
Expand description

A Context is an object that holds on to global resources. It basically tracks hardware state such as the screen, audio system, timers, and so on. Generally this type can not be shared/sent between threads and only one Context can exist at a time. Trying to create a second one will fail. It is fine to drop a Context and create a new one, but this will also close and re-open your game’s window.

Most functions that interact with the hardware, for instance drawing things, playing sounds, or loading resources (which then need to be transformed into a format the hardware likes) will need to access the Context. It is an error to create some type that relies upon a Context, such as Image, and then drop the Context and try to draw the old Image with the new Context. Most types include checks to make this panic in debug mode, but it’s not perfect.

All fields in this struct are basically undocumented features, only here to make it easier to debug, or to let advanced users hook into the guts of ggez and make it do things it normally can’t. Most users shouldn’t need to touch these things directly, since implementation details may change without warning. The public and stable API is ggez’s module-level functions and types.


filesystem: Filesystem

Filesystem state

timer_context: TimeContext

Timer state

audio_context: Box<dyn AudioContext>

Audio context

keyboard_context: KeyboardContext

Keyboard context

mouse_context: MouseContext

Mouse context

gamepad_context: Box<dyn GamepadContext>

Gamepad context

continuing: bool

Controls whether or not the event loop should be running. Set this with ggez::event::quit().

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.