Put it in context

gdt::context

template <typename PLATFORM, typename GRAPHICS, typename AUDIO, typename PHYSICS>
struct gdt::context

When you start your application or game, GDT will create your main backend objects as part of you application instance. These objects are later required to create different game assets. Instead of having a set of singletons, GDT uses dependency injection and asks you to provide a special packaged object called gdt::context to many different constructors.

You can subclass the generic context to create your own customized context with additional state (for example, a scripting engine of your choice):

template <typename PLATFORM, typename GRAPHICS, typename AUDIO, typename PHYSICS>
struct my_context : gdt::context<PLATFORM, GRAPHICS, AUDIO, PHYSICS> {
    // additional state goes here
};

You will have to specify either your subclassed context type or the default one when you create your application type:

using my_game = gdt::application< ... , my_context>;

In any case, always use the context type provided by your specified application type:

using my_game = gdt::application<..., my_context>;

void any_method_accepting_context(const my_game::context & ctx) {
    ....
}

Inherits from gdt::platform_context< PLATFORM >, gdt::graphics_context< GRAPHICS >, gdt::audio_context< AUDIO >, gdt::physics_context< PHYSICS >, gdt::core_context

gdt::context components

struct gdt::core_context

gdt::context is also composed from this core_context. The core context provides the frame elapsed time, useful in many time-based game state updates.

You can directly access elapsed through your game’s specified context type.

Subclassed by gdt::context< PLATFORM, GRAPHICS, AUDIO, PHYSICS >

template <typename PLATFORM>
struct gdt::platform_context

The platform_context is a component of the default gdt::context template. You will normally not be using this template in your game code.

Subclassed by gdt::context< PLATFORM, GRAPHICS, AUDIO, PHYSICS >

template <typename GRAPHICS>
struct gdt::graphics_context

The graphics_context is a component of the default gdt::context template. You will normally not be using this template in your game code.

Subclassed by gdt::context< PLATFORM, GRAPHICS, AUDIO, PHYSICS >

template <typename AUDIO>
struct gdt::audio_context

The audio_context is a component of the default gdt::context template. You will normally not be using this template in your game code.

Subclassed by gdt::context< PLATFORM, GRAPHICS, AUDIO, PHYSICS >

template <typename PHYSICS>
struct gdt::physics_context

The physics_context is a component of the default gdt::context template. You will normally not be using this template in your game code.

Subclassed by gdt::context< PLATFORM, GRAPHICS, AUDIO, PHYSICS >