Struct ggez::Context [−][src]
pub struct Context { pub conf: Conf, pub sdl_context: Sdl, pub filesystem: Filesystem, pub event_context: EventSubsystem, pub timer_context: TimeContext, pub audio_context: AudioContext, pub gamepad_context: GamepadContext, pub mouse_context: MouseContext, pub default_font: Font, // some fields omitted }
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 is not thread-
safe and only one Context
can exist at a time. Trying to create
another one will fail.
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
.
Fields
conf: Conf
The Conf object the Context was created with
sdl_context: Sdl
SDL context
filesystem: Filesystem
Filesystem state
event_context: EventSubsystem
Event context
timer_context: TimeContext
Timer state
audio_context: AudioContext
Audio context
gamepad_context: GamepadContext
Gamepad context
mouse_context: MouseContext
Mouse context
default_font: Font
Default font
Methods
impl Context
[src]
impl Context
pub fn load_from_conf(
game_id: &'static str,
author: &'static str,
default_config: Conf
) -> GameResult<Context>
[src]
pub fn load_from_conf(
game_id: &'static str,
author: &'static str,
default_config: Conf
) -> GameResult<Context>
Tries to create a new Context by loading a config
file from its default path, using the given Conf
object as a default if none is found.
The game_id
and author
are game-specific strings that
are used to locate the default storage locations for the
platform it looks in, as documented in the filesystem
module. You can also always debug-print the
Context::filesystem
field to see what paths it is
searching.
pub fn print_resource_stats(&mut self)
[src]
pub fn print_resource_stats(&mut self)
Prints out information on the resources subsystem.
pub fn quit(&mut self) -> GameResult<()>
[src]
pub fn quit(&mut self) -> GameResult<()>
Triggers a Quit event.
pub fn process_event(&mut self, event: &Event)
[src]
pub fn process_event(&mut self, event: &Event)
Feeds an Event
into the Context
so it can update any internal
state it needs to, such as detecting window resizes. If you are
rolling your own event loop, you should call this on the events
you receive before processing them yourself.