openMSX
SDLImage.hh
Go to the documentation of this file.
1 #ifndef SDLIMAGE_HH
2 #define SDLIMAGE_HH
3 
4 #include "BaseImage.hh"
5 #include "SDLSurfacePtr.hh"
6 #include <string>
7 
8 namespace openmsx {
9 
10 class SDLImage final : public BaseImage
11 {
12 public:
13  SDLImage(OutputSurface& output, const std::string& filename);
14  SDLImage(OutputSurface& output, SDLSurfacePtr image);
15  SDLImage(OutputSurface& output, const std::string& filename, float scaleFactor);
16  SDLImage(OutputSurface& output, const std::string& filename, gl::ivec2 size);
17  SDLImage(OutputSurface& output, gl::ivec2 size, unsigned rgba);
18  SDLImage(OutputSurface& output, gl::ivec2 size, const unsigned* rgba,
19  unsigned borderSize, unsigned borderRGBA);
20 
21  void draw(OutputSurface& output, gl::ivec2 pos,
22  uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) override;
23 
24 private:
25  SDLTexturePtr toTexture(OutputSurface& output, SDL_Surface& surface);
26  SDLTexturePtr loadImage(OutputSurface& output, const std::string& filename);
27  void initSolid(OutputSurface& output, gl::ivec2 size, unsigned rgba,
28  unsigned borderSize, unsigned borderRGBA);
29  void initGradient(OutputSurface& output, gl::ivec2 size, const unsigned* rgba,
30  unsigned borderSize, unsigned borderRGBA);
31 
32  SDLTexturePtr texture; // can be nullptr
33  const bool flipX, flipY; // 'size' is always positive, there are true
34  // when the original size was negative
35 };
36 
37 } // namespace openmsx
38 
39 #endif
SDLImage(OutputSurface &output, const std::string &filename)
Definition: SDLImage.cc:198
A frame buffer where pixels can be written to.
Wrapper around a SDL_Surface.
constexpr const char *const filename
void draw(OutputSurface &output, gl::ivec2 pos, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) override
Definition: SDLImage.cc:363
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
int g
std::unique_ptr< SDL_Texture, SDLDestroyTexture > SDLTexturePtr
gl::ivec2 size
Definition: BaseImage.hh:31