FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
sdlimage.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_VIDEO_RENDERBACKENDS_SDL_SDLIMAGE_H
23 #define FIFE_VIDEO_RENDERBACKENDS_SDL_SDLIMAGE_H
24 
25 // Standard C++ library includes
26 
27 // 3rd party library includes
28 #include <SDL_video.h>
29 
30 // FIFE includes
31 // These includes are split up in two parts, separated by one empty line
32 // First block: files included from the FIFE root src directory
33 // Second block: files included from the same folder
34 #include "video/image.h"
35 
36 namespace FIFE {
37 
40  class SDLImage : public Image {
41  public:
42  SDLImage(IResourceLoader* loader = 0);
43  SDLImage(const std::string& name, IResourceLoader* loader = 0);
44  SDLImage(SDL_Surface* surface);
45  SDLImage(const std::string& name, SDL_Surface* surface);
46  SDLImage(const uint8_t* data, uint32_t width, uint32_t height);
47  SDLImage(const std::string& name, const uint8_t* data, uint32_t width, uint32_t height);
48 
49  virtual ~SDLImage();
50  virtual void invalidate();
51  virtual void setSurface(SDL_Surface* surface);
52  virtual void render(const Rect& rect, uint8_t alpha = 255, uint8_t const* rgb = 0);
53  virtual size_t getSize();
54  virtual void useSharedImage(const ImagePtr& shared, const Rect& region);
55  virtual void forceLoadInternal();
56  virtual void load();
57  virtual void free();
58 
59  SDL_Texture* getTexture();
60  void setTexture(SDL_Texture* texture);
61 
62  private:
63  void resetSdlimage();
64  void validateShared();
65 
66  // colorkey for the image
67  SDL_Color m_colorkey;
68  // texture of image
69  SDL_Texture* m_texture;
70 
71  // Holds Atlas ImagePtr if this is a shared image
73  // Holds Atlas Name if this is a shared image
74  std::string m_atlas_name;
75  };
76 
77 }
78 
79 #endif
void validateShared()
Definition: sdlimage.cpp:189
Base Class for Images.
Definition: image.h:48
SDL_Color m_colorkey
Definition: sdlimage.h:67
SDL_Texture * m_texture
Definition: sdlimage.h:69
The SDL implementation of the Image base class.
Definition: sdlimage.h:40
void setTexture(SDL_Texture *texture)
Definition: sdlimage.cpp:228
ImagePtr m_atlas_img
Definition: sdlimage.h:72
SDL_Texture * getTexture()
Definition: sdlimage.cpp:224
virtual size_t getSize()
Definition: sdlimage.cpp:151
unsigned char uint8_t
Definition: core.h:38
virtual void render(const Rect &rect, uint8_t alpha=255, uint8_t const *rgb=0)
Renders itself to the current render target (main screen or attached destination image) at the rectan...
Definition: sdlimage.cpp:99
virtual ~SDLImage()
Definition: sdlimage.cpp:82
void resetSdlimage()
Definition: sdlimage.cpp:77
virtual void invalidate()
Invalidates the Image causing it to be reset or re-loaded.
Definition: sdlimage.cpp:86
virtual void forceLoadInternal()
Forces to load the image into internal memory of GPU.
Definition: sdlimage.cpp:185
std::string m_atlas_name
Definition: sdlimage.h:74
virtual void setSurface(SDL_Surface *surface)
This frees the current suface and replaces it with the surface passed in the parameter (which can be ...
Definition: sdlimage.cpp:93
unsigned int uint32_t
Definition: core.h:40
virtual void load()
Definition: sdlimage.cpp:200
SDLImage(IResourceLoader *loader=0)
Definition: sdlimage.cpp:47
virtual void free()
Definition: sdlimage.cpp:214
virtual void useSharedImage(const ImagePtr &shared, const Rect &region)
After this call all image data will be taken from the given image and its subregion.
Definition: sdlimage.cpp:160