souleng
Game engine providing full Python scripting support
Loading...
Searching...
No Matches
TextureComponent.hpp
1#pragma once
2#include <SDL3/SDL.h>
3#include <memory>
4#include <string>
5
6#include "Component.hpp"
7
9struct TextureComponent : public Component {
11
14 void CreateTexture(std::string filepath);
15
18 // @param x,y The top left corner of the region of the texture to render
19 // @param w,h The size of the region of the texture to render
20 void SelectSourceRect(float x, float y, float w, float h);
21
23 void ClearSourceRect();
24
26
28 static ComponentType GetType();
29
31 void Input() override;
32
34 void Update(float dt) override;
35
37 void Render() override;
38
39protected:
40 std::shared_ptr<SDL_Texture> mTexture;
41 SDL_FRect *mSrcRect;
42};
Definition Component.hpp:17
Component to render an image to the screen.
Definition TextureComponent.hpp:9
void CreateTexture(std::string filepath)
Definition TextureComponent.cpp:13
void ClearSourceRect()
Selects the entire texture to render to the screen.
Definition TextureComponent.cpp:28
void SelectSourceRect(float x, float y, float w, float h)
Definition TextureComponent.cpp:18
void Render() override
Definition TextureComponent.cpp:38
static ComponentType GetType()
Returns the type of this component to make querying GetComponent easier.
Definition TextureComponent.cpp:32
void Update(float dt) override
Definition TextureComponent.cpp:36
void Input() override
Called once per frame to handle any new input.
Definition TextureComponent.cpp:34