|
Scarab
A thin, game-agnostic 2D engine host built on the sunlight tile-map engine
|
Owns the process's one renderer and creates it on demand. More...
#include <rendererprovider.h>


Public Types | |
| typedef std ::function< void(SunLight ::Renderer ::TileMapRenderer &)> | CreatedHook |
Public Member Functions | |
| RendererProvider (const SunLight ::Renderer ::RendererConfig &defaults, const stHeadlessSettings &headless) | |
| Constructor. | |
| virtual | ~RendererProvider (void) |
| Destructor. Destroys the renderer, if one was ever created (its window is normally already closed by then - main() Stop()s it). | |
| void | SetCreatedHook (CreatedHook hook) |
| Set the function called with every renderer right after it is created and before its window opens - where the engine host registers itself as the tile-map listener and the Lua bridge attaches its collision listener. | |
| bool | Create (const SunLight ::Renderer ::RendererConfig &config, Origin origin, const std ::string &strTrigger, std ::string *pError) |
| Create the process's renderer and open its window. | |
| void | EnsureCreated (const char *szTrigger) |
| Create the default renderer if none exists yet - called when the entry script has finished, so a game that never asked for a window-needing primitive still gets its one renderer to run on. | |
| SunLight::Renderer::TileMapRenderer * | GetRenderer (void) |
| The renderer, or nullptr if none exists yet (never creates one). | |
| const stHeadlessSettings & | GetHeadlessSettings (void) const |
| What the command line asked of –headless. | |
| SunLight::TileMap::ITileMap * | GetTileMap (const char *szTrigger) |
| SunLight::DrawSurface::IDrawSurface * | GetDrawSurface (const char *szTrigger) |
| SunLight::DrawSurface::IDrawSurface * | PeekDrawSurface (void) |
| bool | CreateRenderer (const SunLight ::Renderer ::RendererConfig &config, std ::string *pError) |
| Explicitly create the renderer (renderer_create). The error for "a renderer
already exists" says which of the two ways it got there, and - when it was the default, created implicitly - names the primitive that needed a window first, since that call, not this one, is what to move below renderer_create. | |
| Origin | GetOrigin (void) |
| bool | IsHeadless (void) |
| SunLight::Renderer::RendererConfig | GetDefaultConfig (void) |
| SunLight::Renderer::RendererConfig | GetEffectiveConfig (void) |
| void | NoteWindowTitle (const std ::string &strTitle) |
| Keep the effective configuration's title current: app_set_name changes the live window title, and sunlight has no getter for it to read back. | |
Owns the process's one renderer and creates it on demand.
The renderer is created either explicitly (Create, from renderer_create) or implicitly with the default configuration the first time a primitive needs a window (GetTileMap/GetDrawSurface) or when the entry script finishes without needing one (EnsureCreated). Either way it is Start()ed immediately, so its window is open by the time Create returns - load-time code like set_font keeps working.
| typedef std :: function<void( SunLight :: Renderer :: TileMapRenderer& )> Scarab::Host::RendererProvider::CreatedHook |
| Scarab::Host::RendererProvider::RendererProvider | ( | const SunLight ::Renderer ::RendererConfig & | defaults, |
| const stHeadlessSettings & | headless | ||
| ) |
Constructor.
| defaults | The configuration used when a renderer has to be created implicitly (today's hardcoded values, see main.cpp); |
| headless | What the command line asked of –headless; |
|
virtual |
Destructor. Destroys the renderer, if one was ever created (its window is normally already closed by then - main() Stop()s it).
| bool Scarab::Host::RendererProvider::Create | ( | const SunLight ::Renderer ::RendererConfig & | config, |
| Origin | origin, | ||
| const std ::string & | strTrigger, | ||
| std ::string * | pError | ||
| ) |
Create the process's renderer and open its window.
Applies –headless on top of the requested configuration: the null backend is forced (asking for another one is an error), and the command line's –fast/–max-frames win over whatever the configuration says. Only one renderer exists per process run.
| config | The requested configuration; |
| origin | How this creation came about; |
| strTrigger | For an implicit creation, the primitive that needed a window; |
| pError | Receives the reason on failure (may be null); |
| bool Scarab::Host::RendererProvider::CreateRenderer | ( | const SunLight ::Renderer ::RendererConfig & | config, |
| std ::string * | pError | ||
| ) |
Explicitly create the renderer (renderer_create). The error for "a renderer already exists" says which of the two ways it got there, and - when it was the default, created implicitly - names the primitive that needed a window first, since that call, not this one, is what to move below renderer_create.
| void Scarab::Host::RendererProvider::EnsureCreated | ( | const char * | szTrigger | ) |
Create the default renderer if none exists yet - called when the entry script has finished, so a game that never asked for a window-needing primitive still gets its one renderer to run on.
| SunLight::Renderer::RendererConfig Scarab::Host::RendererProvider::GetDefaultConfig | ( | void | ) |
| SunLight::DrawSurface::IDrawSurface * Scarab::Host::RendererProvider::GetDrawSurface | ( | const char * | szTrigger | ) |
| SunLight::Renderer::RendererConfig Scarab::Host::RendererProvider::GetEffectiveConfig | ( | void | ) |
| const stHeadlessSettings & Scarab::Host::RendererProvider::GetHeadlessSettings | ( | void | ) | const |
What the command line asked of –headless.
| RendererProvider::Origin Scarab::Host::RendererProvider::GetOrigin | ( | void | ) |
| SunLight::Renderer::TileMapRenderer * Scarab::Host::RendererProvider::GetRenderer | ( | void | ) |
The renderer, or nullptr if none exists yet (never creates one).
| SunLight::TileMap::ITileMap * Scarab::Host::RendererProvider::GetTileMap | ( | const char * | szTrigger | ) |
| bool Scarab::Host::RendererProvider::IsHeadless | ( | void | ) |
| void Scarab::Host::RendererProvider::NoteWindowTitle | ( | const std ::string & | strTitle | ) |
Keep the effective configuration's title current: app_set_name changes the live window title, and sunlight has no getter for it to read back.
| SunLight::DrawSurface::IDrawSurface * Scarab::Host::RendererProvider::PeekDrawSurface | ( | void | ) |
| void Scarab::Host::RendererProvider::SetCreatedHook | ( | CreatedHook | hook | ) |
Set the function called with every renderer right after it is created and before its window opens - where the engine host registers itself as the tile-map listener and the Lua bridge attaches its collision listener.