Argentum Online - Cliente
sdl_texture.h
1 #ifndef __SDL_TEXTURE_H
2 #define __SDL_TEXTURE_H
3 #include <cstdint>
4 #include <string>
5 
6 #include "SDL2/SDL.h"
7 #include "SDL2/SDL_image.h"
8 
13 class SDLTexture {
14  protected:
15  SDL_Renderer* renderer;
16  SDL_Texture* texture;
17  int width;
18  int height;
19 
20  public:
21  /* Usado para crear texturas sin color key. */
22 
28  SDLTexture(SDL_Renderer* renderer);
29 
30  SDLTexture(const std::string& filename, SDL_Renderer* renderer);
31 
44  SDLTexture(const std::string& filename, SDL_Renderer* renderer, uint8_t r,
45  uint8_t g, uint8_t b);
46 
47  /* No se permite construccion por copia. */
48  SDLTexture(const SDLTexture& other) = delete;
49  SDLTexture& operator=(const SDLTexture& other) = delete;
50 
51  /* Constructor por movimiento. */
52  SDLTexture(SDLTexture&& other);
53  SDLTexture& operator=(SDLTexture&& other);
54 
55  virtual ~SDLTexture();
56 
64  void render(SDL_Rect src, SDL_Rect dest) const;
65 
71  void render(SDL_Rect dest) const;
72 
73  int get_width() const;
74  int get_height() const;
75 
76  void set_color_mod(uint8_t r, uint8_t g, uint8_t b);
77 
78  void reset_color_mod();
79 
80  void set_alpha(uint8_t a);
81 
82  void reset_alpha();
83 };
84 
85 #endif
SDLTexture::SDLTexture
SDLTexture(SDL_Renderer *renderer)
Crea un objeto SDLTexture vacio.
Definition: sdl_texture.cpp:6
SDLTexture
Objeto de textura de SDL.
Definition: sdl_texture.h:13
SDLTexture::render
void render(SDL_Rect src, SDL_Rect dest) const
Renderiza la textura.
Definition: sdl_texture.cpp:81