cpp-sdl2
C++ header-only SDL2 wrapper
sdl::Root Struct Reference

This class represent the "library entry point". More...

#include <sdl.hpp>

Public Member Functions

 Root (Uint32 flags=SDL_INIT_EVERYTHING)
 Construct a root object. More...
 
 ~Root ()
 Automatically quit SDL for you! More...
 

Detailed Description

This class represent the "library entry point".

Create and keep an instance of this object before creating any other sdl object (e.g. sdl::Window)

Create an sdl::Root object on the stack, and SDL is initialized. When your instance of Root goes out of scope, SDL will be deinitialized for you. This pattern (idiom) is called RAII. If you aren't familiar with it, I suggest reading https://en.cppreference.com/w/cpp/language/raii

Definition at line 82 of file sdl.hpp.

Constructor & Destructor Documentation

◆ Root()

sdl::Root::Root ( Uint32  flags = SDL_INIT_EVERYTHING)
inline

Construct a root object.

This object initialize SDL for you. SDL is de-initialized when object quit scope

Parameters
flagsThe intialization flags that you want to pass to SDL_Init. Default value is SDL_INIT_EVERYTHING

This constructor will throw an sdl::Exception if SDL_Init fails.

Definition at line 88 of file sdl.hpp.

◆ ~Root()

sdl::Root::~Root ( )
inline

Automatically quit SDL for you!

Definition at line 95 of file sdl.hpp.


The documentation for this struct was generated from the following file: