12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #pragma once
- #ifndef SNAKE_SDL_HXX
- #define SNAKE_SDL_HXX
- #include <SDL.h>
- #include <cstdint>
- #include <source_location>
- #include <stdexcept>
- #include <string_view>
- #include <vector>
- #include "NonCopyable.hxx"
- class SDLError final : public std::runtime_error {
- public:
- explicit SDLError(
- std::string_view message,
- std::source_location location = std::source_location::current()
- );
- };
- class SDL final : private NonCopyable {
- public:
- explicit SDL(std::uint32_t flags = SDL_INIT_EVERYTHING);
- ~SDL() noexcept;
- static SDL& instance() noexcept;
- static SDL& require(std::uint32_t flags) noexcept;
- void add_controller(int which);
- void remove_controller(int which);
- std::vector<SDL_GameController *> const& get_controllers() const;
- private:
- static SDL* instance_;
- std::vector<SDL_GameController*> controllers_;
- };
- #endif
|