diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-08 20:21:36 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-08 20:21:36 +0100 |
commit | 506de66aaecc9b82415dde46058b848e46bc7258 (patch) | |
tree | a3f2427b0882d07f2d960b7214170533ad241830 /src/crepe/facade/SDLContext.h | |
parent | 7817c85e84560933a33ad86ec3f9ca3d48d327d5 (diff) |
nitpicks (merge #27)
Diffstat (limited to 'src/crepe/facade/SDLContext.h')
-rw-r--r-- | src/crepe/facade/SDLContext.h | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index 93166f2..e358c21 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -11,13 +11,15 @@ #include "../api/Transform.h" #include "api/Camera.h" -//FIXME: this needs to be removed +// FIXME: this needs to be removed const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; namespace crepe { -//TODO: Wouter will fix this. cause user cannot this at the moment +// TODO: SDL_Keycode is defined in a header not distributed with crepe, which +// means this typedef is unusable when crepe is packaged. Wouter will fix this +// later. typedef SDL_Keycode CREPE_KEYCODES; class Texture; @@ -34,9 +36,9 @@ class SDLContext { public: /** - * \brief Gets the singleton instance of SDLContext. - * \return Reference to the SDLContext instance. - */ + * \brief Gets the singleton instance of SDLContext. + * \return Reference to the SDLContext instance. + */ static SDLContext & get_instance(); SDLContext(const SDLContext &) = delete; @@ -48,9 +50,9 @@ private: //! will only use handle_events friend class LoopManager; /** - * \brief Handles SDL events such as window close and input. - * \param running Reference to a boolean flag that controls the main loop. - */ + * \brief Handles SDL events such as window close and input. + * \param running Reference to a boolean flag that controls the main loop. + */ void handle_events(bool & running); private: @@ -58,22 +60,22 @@ private: friend class AnimatorSystem; /** - * \brief Gets the current SDL ticks since the program started. - * \return Current ticks in milliseconds as a constant uint64_t. - */ - const uint64_t get_ticks() const; + * \brief Gets the current SDL ticks since the program started. + * \return Current ticks in milliseconds as a constant uint64_t. + */ + uint64_t get_ticks() const; private: /** - * \brief Constructs an SDLContext instance. - * Initializes SDL, creates a window and renderer. - */ + * \brief Constructs an SDLContext instance. + * Initializes SDL, creates a window and renderer. + */ SDLContext(); /** - * \brief Destroys the SDLContext instance. - * Cleans up SDL resources, including the window and renderer. - */ + * \brief Destroys the SDLContext instance. + * Cleans up SDL resources, including the window and renderer. + */ ~SDLContext(); private: @@ -84,23 +86,24 @@ private: friend class Animator; /** - * \brief Loads a texture from a file path. - * \param path Path to the image file. - * \return Pointer to the created SDL_Texture. - */ - std::unique_ptr<SDL_Texture, std::function<void(SDL_Texture *)>> texture_from_path(const std::string & path); + * \brief Loads a texture from a file path. + * \param path Path to the image file. + * \return Pointer to the created SDL_Texture. + */ + std::unique_ptr<SDL_Texture, std::function<void(SDL_Texture *)>> + texture_from_path(const std::string & path); /** - * \brief Gets the width of a texture. - * \param texture Reference to the Texture object. - * \return Width of the texture as an integer. - */ + * \brief Gets the width of a texture. + * \param texture Reference to the Texture object. + * \return Width of the texture as an integer. + */ int get_width(const Texture &) const; /** - * \brief Gets the height of a texture. - * \param texture Reference to the Texture object. - * \return Height of the texture as an integer. - */ + * \brief Gets the height of a texture. + * \param texture Reference to the Texture object. + * \return Height of the texture as an integer. + */ int get_height(const Texture &) const; private: @@ -108,37 +111,33 @@ private: friend class RenderSystem; /** - * \brief Draws a sprite to the screen using the specified transform and camera. - * \param sprite Reference to the Sprite to draw. - * \param transform Reference to the Transform for positioning. - * \param camera Reference to the Camera for view adjustments. - */ + * \brief Draws a sprite to the screen using the specified transform and camera. + * \param sprite Reference to the Sprite to draw. + * \param transform Reference to the Transform for positioning. + * \param camera Reference to the Camera for view adjustments. + */ void draw(const Sprite & sprite, const Transform & transform, const Camera & camera); - /** - * \brief Clears the screen, preparing for a new frame. - */ + //! Clears the screen, preparing for a new frame. void clear_screen(); - /** - * \brief Presents the rendered frame to the screen. - */ + //! Presents the rendered frame to the screen. void present_screen(); /** - * \brief Sets the current camera for rendering. - * \param camera Reference to the Camera object. - */ + * \brief Sets the current camera for rendering. + * \param camera Reference to the Camera object. + */ void camera(const Camera & camera); private: - //! sdl Window - std::unique_ptr<SDL_Window, std::function<void(SDL_Window*) >> game_window; + std::unique_ptr<SDL_Window, std::function<void(SDL_Window *)>> game_window; //! renderer for the crepe engine - std::unique_ptr<SDL_Renderer, std::function<void(SDL_Renderer*)>> game_renderer; + std::unique_ptr<SDL_Renderer, std::function<void(SDL_Renderer *)>> + game_renderer; //! viewport for the camera window SDL_Rect viewport = {0, 0, 640, 480}; |