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
SDLSurfacePtr
Wrapper around a SDL_Surface.
Definition: SDLSurfacePtr.hh:33
BaseImage.hh
openmsx::SDLImage
Definition: SDLImage.hh:10
gl::vecN
Definition: gl_vec.hh:35
openmsx::BaseImage::size
gl::ivec2 size
Definition: BaseImage.hh:31
SDLSurfacePtr.hh
openmsx::filename
constexpr const char *const filename
Definition: FirmwareSwitch.cc:10
openmsx::SDLImage::draw
void draw(OutputSurface &output, gl::ivec2 pos, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) override
Definition: SDLImage.cc:364
g
int g
Definition: ScopedAssign_test.cc:20
SDLTexturePtr
std::unique_ptr< SDL_Texture, SDLDestroyTexture > SDLTexturePtr
Definition: SDLSurfacePtr.hh:141
openmsx::BaseImage
Definition: BaseImage.hh:11
openmsx::OutputSurface
A frame buffer where pixels can be written to.
Definition: OutputSurface.hh:19
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::SDLImage::SDLImage
SDLImage(OutputSurface &output, const std::string &filename)
Definition: SDLImage.cc:199