diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-11 15:46:17 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-11 15:46:17 +0100 |
commit | 045c263f5bc432ff0758dd0928e4a0f5e5eed85d (patch) | |
tree | 7eec84c0267b14475608baae3c919d11779c63a6 /src/crepe/facade/SDLContext.h | |
parent | e980f88c08e05d3c3d0ae7ff7422ec9e686ecfa4 (diff) |
updated the code so that get_events() calculates pixel units to game units
Diffstat (limited to 'src/crepe/facade/SDLContext.h')
-rw-r--r-- | src/crepe/facade/SDLContext.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index b847c72..6d50ab0 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -4,7 +4,6 @@ #include <SDL2/SDL_keycode.h> #include <SDL2/SDL_rect.h> #include <SDL2/SDL_render.h> -#include <SDL2/SDL_ttf.h> #include <SDL2/SDL_video.h> #include <cmath> #include <functional> @@ -33,7 +32,7 @@ class InputSystem; class SDLContext { public: //! data that the camera component cannot hold - struct CameraValues { + struct CameraAuxiliaryData { //! zoomed in viewport in game_units vec2 zoomed_viewport; @@ -63,7 +62,6 @@ public: //! rendering data needed to render on screen struct RenderContext { const Sprite & sprite; - const CameraValues & cam; const vec2 & pos; const double & angle; const double & scale; @@ -189,9 +187,6 @@ private: */ ivec2 get_size(const Texture & ctx); - std::unique_ptr<TTF_Font, std::function<void(TTF_Font *)>> - font_from_path(const std::string & path); - private: //! Will use draw,clear_screen, present_screen, camera. friend class RenderSystem; @@ -202,8 +197,6 @@ private: */ void draw(const RenderContext & ctx); - void draw_text(const - //! Clears the screen, preparing for a new frame. void clear_screen(); @@ -211,16 +204,19 @@ private: void present_screen(); /** - * \brief sets the background of the camera (will be adjusted in future PR) - * \param camera Reference to the Camera object. + * \brief calculates camera view settings. such as black_bars, zoomed_viewport, scaling and + * adjusting window size. + * + * \note only supports windowed mode. + * \param camera Reference to the current Camera object in the scene. + * \param new_pos new camera position from transform and offset */ - CameraValues & set_camera(const Camera & camera); + void update_camera_view(const Camera & camera, const vec2 & new_pos); private: //! the data needed to construct a sdl dst rectangle struct DestinationRectangleData { const Sprite & sprite; - const CameraValues & cam; const vec2 & pos; const double & img_scale; }; @@ -261,7 +257,12 @@ private: //! black bars rectangle to draw SDL_FRect black_bars[2] = {}; - CameraValues camera_val; + /** + * \cam_aux_data extra data that the component cannot hold. + * + * - this is defined in this class because get_events() needs this information aswell + */ + CameraAuxiliaryData cam_aux_data; }; } // namespace crepe |