aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLContext.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-28 13:01:07 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-28 13:01:14 +0100
commit63bce3dd21c82e2b4e45c07934d5a26684cdaa93 (patch)
treea46da0cb575fa21add7b07f2784c7889e4bc2771 /src/crepe/facade/SDLContext.h
parent2a2a3391ff0b449602825c3182af33c2ff52abc0 (diff)
parent85aa57e33d493502b05984ce44db6c68f627a6f2 (diff)
merge `master`
Diffstat (limited to 'src/crepe/facade/SDLContext.h')
-rw-r--r--src/crepe/facade/SDLContext.h45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index 20e30b3..6030a6e 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -9,9 +9,8 @@
#include <memory>
#include <string>
+#include "../api/Camera.h"
#include "../api/Sprite.h"
-#include "../api/Transform.h"
-#include "api/Camera.h"
#include "types.h"
@@ -29,6 +28,15 @@ typedef SDL_Keycode CREPE_KEYCODES;
* event handling, and rendering to the screen. It is never used directly by the user
*/
class SDLContext {
+public:
+ struct RenderContext {
+ const Sprite & sprite;
+ const Camera & cam;
+ const vec2 & cam_pos;
+ const vec2 & pos;
+ const double & angle;
+ const double & scale;
+ };
public:
/**
@@ -100,14 +108,14 @@ private:
* \param texture Reference to the Texture object.
* \return Width of the texture as an integer.
*/
- int get_width(const Texture &) const;
+ int get_width(const Texture & texture) const;
/**
* \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;
+ int get_height(const Texture & texture) const;
private:
//! Will use draw,clear_screen, present_screen, camera.
@@ -115,14 +123,9 @@ private:
/**
* \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.
+ * \param RenderCtx Reference to rendering data to draw
*/
- void draw(const Sprite & sprite, const Transform & transform, const Camera & camera);
-
- void draw_particle(const Sprite & sprite, const vec2 & pos, const double & angle,
- const double & scale, const Camera & camera);
+ void draw(const RenderContext & ctx);
//! Clears the screen, preparing for a new frame.
void clear_screen();
@@ -144,18 +147,19 @@ private:
* \return sdl rectangle to draw a src image
*/
SDL_Rect get_src_rect(const Sprite & sprite) const;
+
/**
- * \brief calculates the sqaure size of the image for an destination
+ * \brief calculates the sqaure size of the image for destination
*
- * \param sprite Reference to the sprite to calculate the rectangle
- * \param pos the pos in pixel positions
- * \param scale the multiplier to increase of decrease for the specified sprite
- * \param cam Reference to the current camera in the scene to calculate the position based
- * on the camera
+ * \param sprite Reference to the sprite to calculate rectangle
+ * \param pos the pos in world units
+ * \param cam the camera of the current scene
+ * \param cam_pos the current postion of the camera
+ * \param img_scale the image multiplier for increasing img size
* \return sdl rectangle to draw a dst image to draw on the screen
*/
- SDL_Rect get_dst_rect(const Sprite & sprite, const vec2 & pos, const double & scale,
- const Camera & cam) const;
+ SDL_Rect get_dst_rect(const Sprite & sprite, const vec2 & pos, const Camera & cam,
+ const vec2 & cam_pos, const double & img_scale) const;
private:
//! sdl Window
@@ -163,9 +167,6 @@ private:
//! renderer for the crepe engine
std::unique_ptr<SDL_Renderer, std::function<void(SDL_Renderer *)>> game_renderer;
-
- //! viewport for the camera window
- SDL_Rect viewport = {0, 0, 640, 480};
};
} // namespace crepe