Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force SDL/GL/Logger init outside of SDLGame #18

Open
SgtCoDFish opened this issue Jul 30, 2018 · 0 comments
Open

Force SDL/GL/Logger init outside of SDLGame #18

SgtCoDFish opened this issue Jul 30, 2018 · 0 comments
Labels
breaking-change For features which change the user-facing API enhancement

Comments

@SgtCoDFish
Copy link
Owner

Currently SDLGame handles the "magic" of initialising SDL (and the various SDL submodules), creating a window, creating a GL context and initialising the APG logger. This has two effects:

  • Nothing with APG can realistically be done before these things are initialised.
  • This forces a recursive "unique_ptr" bloat across the whole codebase, which makes initialisation much more complicated, adds overhead and exposes us to various nullptr bugs which wouldn't happen if the classes we were creating were just members.

By moving SDLGame's constructor logic out into a separate class which owns the SDL/GL context, we add an extra initialisation step before getting a working screen, but the gains outweigh the losses.

It might be possible to avoid a breaking API change by creating an entirely new game class, perhaps using CRTP... but it might be cleaner, given that APG is not widely used, to just break SDLGame.

@SgtCoDFish SgtCoDFish added enhancement breaking-change For features which change the user-facing API labels Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change For features which change the user-facing API enhancement
Projects
None yet
Development

No branches or pull requests

1 participant