It’s your App¶
gdt::application¶
- template <typename PLATFORM, template< typename > typename GRAPHICS, typename AUDIO, typename PHYSICS, typename NETWORKING, template< typename, typename, typename, typename > typename CONTEXT>
-
class
gdt::
application
¶ The entry point to your game is a single gdt::application based object. GDT lets you specify your game’s graphics, platform, physics and other services through this template, for example:
using my_game = gdt::application< gdt::platform::sdl::backend_for_opengl, gdt::graphics::opengl::backend, gdt::no_audio, gdt::no_physics, gdt::no_networking, gdt::context >;
Once your application type is specified, you can instantiate an object (for example, by using
std::make_unique
) and use the gdt::application::run method to start it.You will also be able (and encouraged) to use the many other templates GDT has through your speficied application template.
For example, here’s how you subclass a scene:
class intro : public my_game::scene { ... }
For the full list of provided types, see the specification below or read through the rest of the docs for more examples.
- Template Parameters
PLATFORM
: an implementation of gdt::blueprints::platform::backendGRAPHICS
: an implementation of gdt::blueprints::graphics::backendAUDIO
: an implementation of gdt::blueprints::audio::backendPHYSICS
: an implementation of gdt::blueprints::network::backendNETWORKING
: an implementation of the still missing networking backendCONTEXT
: either gdt::context or a user subclass of it
Public Types
- template<>
-
using
platform
= PLATFORM¶ The specified implemetation of gdt::blueprints::platform::backend.
- template<>
-
using
graphics
= GRAPHICS<platform>¶ The specified implemetation of gdt::blueprints::graphics::backend.
- template<>
-
using
asset
= gdt::asset<ACTUAL_ASSET>¶ A gdt::asset CRTP template you can use to subclass your own assets. You will normally have additional traits set for your assets.
- template<>
-
using
drawable
= gdt::drawable<GRAPHICS<platform>, ACTUAL_ASSET>¶ A gdt::drawable CRTP template you subclass to create your own drawable assets:
class zombie : public my_game::asset<zombie>, public my_game::drawable<zombie> { public: zombie(const my_game::context & ctx): my_game::drawable<zombie>(ctx, "res/zombie.smd") {} };
Drawable assets can be used as arguments in pipeline
draw
calls:_pipeline.use(ctx) .draw(_zombie);
- template<>
-
using
animatable
= gdt::animatable<ACTUAL_ASSET>¶ A gdt::animatable CRTP template you can subclass to set up skeletal animation support for an asset:
class zombie : public my_game::asset<zombie>, public my_game::drawable<zombie>, public my_game::animatable<zombie> { public: zombie(const my_game::context & ctx): my_game::drawable<zombie>(ctx, "res/zombie.smd"), my_game::animatable<zombie>(gdt::read_skeleton("res/zombie.smd")) {} };
You can then play animation objects through the gdt::animatable::play and have the model animated using one of the pipelies supporting skeletal animations (for example, gdt::rigged_pipeline).
- template<>
-
using
texture
= typename GRAPHICS::texture¶ Image-based texture type you can feed into pipeline materials.
- template<>
-
using
font
= gdt::font<graphics>¶ SDF image-based font type you can initialize gdt::text objects with.
- template<>
-
using
text
= gdt::text<graphics>¶ Text type you can use with gdt::application::text_pipeline
- template<>
-
using
pipeline_proxy
= gdt::pipeline_proxy<graphics, PIPELINE>¶ A partly specified gdt::pipeline_proxy template, used to ensure proper pipeline usage.
- Template Parameters
PIPELINE
: pipeline type to wrap with the proxy. You will pass the actual object in the constructor of the proxy.
- template<>
-
using
pipeline
= gdt::pipeline<graphics, PIPELINE>¶ A partly specified pipeline CRTP template for you to subclass from when you want to create your own vertex and fragment shaders pipeline.
class my_pipeline: public my_game::pipeline<my_pipeline> { ... };
- Template Parameters
PIPELINE
: your pipeline class, subclassing from this template.
- template<>
-
using
forward_pipeline
= gdt::forward_pipeline<graphics>¶ Forward rendering shaders pipeline.
- template<>
-
using
rigged_pipeline
= gdt::rigged_pipeline<graphics>¶ Forward rendering shaders pipeline with skeletal animation support.
- template<>
-
using
g_buffer
= gdt::g_buffer<graphics>¶ GBuffer for use with deferred rendering pipelines.
- template<>
-
using
geom_pipeline
= gdt::geom_pipeline<graphics>¶ Geometry pipeline for deferred renderering.
- template<>
-
using
rigged_geom_pipeline
= gdt::rigged_geom_pipeline<graphics>¶ Geometry pipeline for deferred renderering - with skeleton animation support.
- template<>
-
using
light_pipeline
= gdt::light_pipeline<graphics>¶ Lighting pipeline (second phase) for deferred renderering
- template<>
-
using
material
= gdt::material<graphics>¶ A standard, ready-to-use gdt::material (with diffuse, specular and normal textures).
- template<>
-
using
render_pass
= gdt::render_pass<graphics>¶ A specified and ready to use render pass.
- template<>
-
using
renderer
= gdt::renderer<graphics, RENDERER>¶ A partly specified CRTP renderer template for you to subclass from.
- template<>
-
using
physics
= PHYSICS¶ TODO: document this
- template<>
-
using
box_proxy
= gdt::box_proxy<physics, E>¶ A specified bounding box collision proxy template.
- template<>
-
using
sphere_proxy
= gdt::sphere_proxy<physics, E>¶ A specified bounding sphere collision proxy template.
- template<>
-
using
rigid_body_driver
= gdt::rigid_body_driver<physics, E>¶ Rigid body driver you can use with one of the collision proxies.
- template<>
-
using
fps_driver
= gdt::fps_driver<physics, DRIVABLE>¶ An FPS physics-based driver you can use with your camera.
- template<>
-
using
audio
= AUDIO¶ A specified implementation of gdt::blueprints::audio::backend.
- template<>
-
using
sound
= typename audio::sound¶ A specified implementation of gdt::blueprints::audio::sound.
- template<>
-
using
context
= CONTEXT<platform, graphics, audio, physics>¶ A specified, ready-to-use context type, potentially user-subclassed.
- template<>
-
using
scene
= gdt::scene<context>¶ A specified gdt::scene template ready for you to subclass your scenes from
Public Functions
- template <typename FIRST_SCENE>
-
int
run
()¶ Use run to start your application. Make sure you provide a scene class as your template argument so GDT will create your initial scene object.
For example:
int main() { try { return std::make_unique<my_app>()->run<my_app::empty_scene>(); } catch (const std::exception & e) { LOG_ERROR << e.what(); return 1; } }
- Template Parameters
FIRST_SCENE
: the first gdt::scene subclass your game will initialize and run
Usage¶
To create a basic OpenGL game using SDL as the platform backend:
#include "gdt.h"
#include "bricks/opengl/opengl.hh"
#include "bricks/sdl/sdl.hh"
using my_game = gdt::application<
gdt::platform::sdl::backend_for_opengl,
gdt::graphics::opengl::backend,
gdt::no_audio,
gdt::no_physics,
gdt::no_networking,
gdt::context
>;
int main()
{
std::make_unique<my_app>()->run<my_app::empty_scene>();
}