SDL2lazy
SlTexture.h
Go to the documentation of this file.
1 // part of SDL2lazy
2 // author: Ulrike Hager
3 
8 #ifndef SLTEXTURE_H
9 #define SLTEXTURE_H
10 
11 #include <cstdint>
12 #include <memory>
13 #include <string>
14 
15 #include <SDL2/SDL.h>
16 #include <SDL2/SDL_image.h>
17 
18 
19 
20 class SlSprite;
21 class SlFont;
22 
27 class SlTexture
28 {
29 
30  public:
35  SlTexture(const std::string& name);
38  ~SlTexture();
41  SlTexture(const SlTexture&) = delete;
44  SlTexture &operator=(const SlTexture&) = delete;
45 
50  bool alphaModIsSet = false;
55  bool colorModIsSet = false;
59  SlTexture* createFromRectangle(SDL_Renderer* renderer, int width, int height, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha );
63  SlTexture* createFromSpriteOnTexture(SDL_Renderer *renderer, SlTexture* backgroundTexture, const std::shared_ptr<SlSprite> foregroundSprite);
67  SlTexture* createFromText(SDL_Renderer *renderer, const std::shared_ptr<SlFont> font, const std::string& message, int width);
73  SlTexture* createFromTile(SDL_Renderer *renderer, const std::shared_ptr<SlSprite> tile, int width, int height);
76  void dimensions(int& width, int& height);
80  SlTexture* loadFromFile(SDL_Renderer* renderer, const std::string& fileName);
84  std::string name() const {return name_;}
87  SDL_Texture* texture() {return texture_;}
88 
89  protected:
90  SlTexture();
93  std::string name_ = "unnamedTexture";
96  SDL_Texture *texture_;
97 };
98 
99 #endif // SLTEXTURE_H
SlTexture * createFromSpriteOnTexture(SDL_Renderer *renderer, SlTexture *backgroundTexture, const std::shared_ptr< SlSprite > foregroundSprite)
Definition: SlTexture.cc:72
SDL_Texture * texture()
Definition: SlTexture.h:87
SDL_Texture * texture_
Definition: SlTexture.h:96
SlTexture * createFromText(SDL_Renderer *renderer, const std::shared_ptr< SlFont > font, const std::string &message, int width)
Definition: SlTexture.cc:97
std::string name() const
Definition: SlTexture.h:84
Definition: SlSprite.h:59
bool colorModIsSet
Definition: SlTexture.h:55
SlTexture * createFromRectangle(SDL_Renderer *renderer, int width, int height, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
Definition: SlTexture.cc:49
~SlTexture()
Definition: SlTexture.cc:37
SlTexture * loadFromFile(SDL_Renderer *renderer, const std::string &fileName)
Definition: SlTexture.cc:167
bool alphaModIsSet
Definition: SlTexture.h:50
SlTexture * createFromTile(SDL_Renderer *renderer, const std::shared_ptr< SlSprite > tile, int width, int height)
Definition: SlTexture.cc:114
void dimensions(int &width, int &height)
Definition: SlTexture.cc:155
Definition: SlTexture.h:27
std::string name_
Definition: SlTexture.h:93
Definition: SlFont.h:20
SlTexture & operator=(const SlTexture &)=delete