Complimentary class library for SDL2 written in C+++14. WIP... Some functions are still not mapped and there are plans to wrap other parts of the SDL2 library.
The aim of the library is to provide a simple set of classes to allow easier use of SDL2 functionality.
Each of the main components, with the exception of the System component, provide RAII types for handling SDL2 resources. Moreover, each class bundles together the SDL2 functions that manipulate those resources. Lastly, each type is capable of conversion to the SDL2 resource type that it wraps so as to allow for interoperation between other SDL2 functions that are currently not wrapped.
The library includes facilities to start up and shutdown SDL2. These functions are aptly named: doodle::init
and doodle::close
.
Initialization is in steps for each SDL2 subsystem. In the event of an error, the output of that error is printed to the standard error stream.
Upon initialization, the following image types are supported:
- PNG
- JPG
- TIF
Upon initialization, the following audio file types are supported:
- MP3
- OGG
- FLAC
- MOD
Additionally, the library only initializes 8 sound channels for 8 simultaneous sounds playing.
The SDL2 types: Mix_Chunk
and Mix_Music
are wrapped in classes doodle::Sound
and doodle::Music
respectively. Sounds are created using the doodle::load_sound
function. Music instances are created using the doodle::load_music
function.
The SDL2 types: SDL_Renderer
and SDL_Window
are wrapped in classes doodle::Renderer
and doodle::Window
respectively. Renderers are created using the doodle::create_renderer
function. Windows are created using the doodle::create_window
function.
The SDL2 types: SDL_Texture
and TTF_Font
are wrapped in classes doodle::Texture
and doodle::Font
respectively.
There are four functions that allow for creating textures:
doodle::load_image
. Used for loading textures from image files.doodle::load_solid_text
. Used for loading standard rendered text.doodle::load_shaded_text
. Used for loading rendered text with a shadow.doodle::load_blended_text
. Used for loading rendered text that is blended with its background color.
Fonts are created using the doodle::load_font
function.
This component contains the following classes:
doodle::Clock
. Used for calculating time/calculating delta time.doodle::FrameCounter
. Used primarily for counting min/avg/max frame ratedoodle::InputHandler
. Used for maintaining the state of the keyboard/mouse.
This component also contains the following enumerations used for input event processing:
doodle::Keyboard
. 282 distinct keys used in SDL2.doodle::Mouse
. 3 buttons that map to the left, middle, and right respectively.
This component is a utility for making management of a large number of assets such as audio/textures/fonts easier.
The doodle::AssetManager
can be used to name different assets that can later be referred to in different parts of a program.