FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
The SDL implementation of the Image
base class.
More...
#include <sdlimage.h>
Public Member Functions | |
SDLImage (IResourceLoader *loader=0) | |
SDLImage (const std::string &name, IResourceLoader *loader=0) | |
SDLImage (SDL_Surface *surface) | |
SDLImage (const std::string &name, SDL_Surface *surface) | |
SDLImage (const uint8_t *data, uint32_t width, uint32_t height) | |
SDLImage (const std::string &name, const uint8_t *data, uint32_t width, uint32_t height) | |
virtual | ~SDLImage () |
virtual void | invalidate () |
Invalidates the Image causing it to be reset or re-loaded. More... | |
virtual void | setSurface (SDL_Surface *surface) |
This frees the current suface and replaces it with the surface passed in the parameter (which can be NULL). More... | |
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 rectangle rect. More... | |
virtual size_t | getSize () |
virtual void | useSharedImage (const ImagePtr &shared, const Rect ®ion) |
After this call all image data will be taken from the given image and its subregion. More... | |
virtual void | forceLoadInternal () |
Forces to load the image into internal memory of GPU. More... | |
virtual void | load () |
virtual void | free () |
SDL_Texture * | getTexture () |
void | setTexture (SDL_Texture *texture) |
![]() | |
Image (IResourceLoader *loader=0) | |
Constructor. More... | |
Image (const std::string &name, IResourceLoader *loader=0) | |
Image (SDL_Surface *surface) | |
Constructor. More... | |
Image (const std::string &name, SDL_Surface *surface) | |
Image (const uint8_t *data, uint32_t width, uint32_t height) | |
Constructor. More... | |
Image (const std::string &name, const uint8_t *data, uint32_t width, uint32_t height) | |
virtual | ~Image () |
Destructor. More... | |
virtual void | render (const Rect &rect, const ImagePtr &overlay, uint8_t alpha=255, uint8_t const *rgb=0) |
virtual void | renderZ (const Rect &rect, float vertexZ, uint8_t alpha=255, uint8_t const *rgb=0) |
virtual void | renderZ (const Rect &rect, float vertexZ, const ImagePtr &overlay, uint8_t alpha=255, uint8_t const *rgb=0) |
virtual void | renderZ (const Rect &rect, float vertexZ, uint8_t alpha=255, bool forceNewBatch=false, uint8_t const *rgb=0) |
SDL_Surface * | detachSurface () |
Removes underlying SDL_Surface from the image (if exists) and returns this. More... | |
SDL_Surface * | getSurface () |
const SDL_Surface * | getSurface () const |
void | saveImage (const std::string &filename) |
Saves the image using given filename. More... | |
uint32_t | getWidth () const |
uint32_t | getHeight () const |
Rect | getArea () const |
void | setXShift (int32_t xshift) |
int32_t | getXShift () const |
void | setYShift (int32_t yshift) |
int32_t | getYShift () const |
void | getPixelRGBA (int32_t x, int32_t y, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a) |
bool | isSharedImage () const |
Returns true if this image shares data with another one. More... | |
const Rect & | getSubImageRect () const |
Returns area of the image it occupies in the shared image. More... | |
virtual void | copySubimage (uint32_t xoffset, uint32_t yoffset, const ImagePtr &img) |
Copies given image into this one with respect to given offsets. More... | |
![]() | |
IResource (const std::string &name, IResourceLoader *loader=0) | |
virtual | ~IResource () |
virtual const std::string & | getName () |
ResourceHandle | getHandle () |
virtual ResourceState | getState () |
virtual void | setState (const ResourceState &state) |
Private Member Functions | |
void | resetSdlimage () |
void | validateShared () |
Private Attributes | |
SDL_Color | m_colorkey |
SDL_Texture * | m_texture |
ImagePtr | m_atlas_img |
std::string | m_atlas_name |
Additional Inherited Members | |
![]() | |
enum | ResourceState { RES_INVALID = 0, RES_NOT_LOADED, RES_LOADED } |
![]() | |
static void | saveAsPng (const std::string &filename, const SDL_Surface &surface) |
Saves the SDL_Surface to png format. More... | |
static bool | putPixel (SDL_Surface *surface, int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
![]() | |
void | reset (SDL_Surface *surface) |
Resets the image to default values (including the x and y shift values), frees the current surface and sets the surface to the passed SDL_Surface (which can be NULL). More... | |
![]() | |
SDL_Surface * | m_surface |
int32_t | m_xshift |
int32_t | m_yshift |
bool | m_shared |
Rect | m_subimagerect |
![]() | |
std::string | m_name |
IResourceLoader * | m_loader |
ResourceState | m_state |
The SDL implementation of the Image
base class.
Definition at line 40 of file sdlimage.h.
FIFE::SDLImage::SDLImage | ( | IResourceLoader * | loader = 0 | ) |
Definition at line 47 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | const std::string & | name, |
IResourceLoader * | loader = 0 |
||
) |
Definition at line 52 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | SDL_Surface * | surface | ) |
Definition at line 57 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | const std::string & | name, |
SDL_Surface * | surface | ||
) |
Definition at line 62 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | const uint8_t * | data, |
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 67 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | const std::string & | name, |
const uint8_t * | data, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 72 of file sdlimage.cpp.
References resetSdlimage().
|
virtual |
Definition at line 82 of file sdlimage.cpp.
References invalidate().
|
virtual |
Forces to load the image into internal memory of GPU.
Implements FIFE::Image.
Definition at line 185 of file sdlimage.cpp.
References validateShared().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 214 of file sdlimage.cpp.
References FIFE::IResource::m_state, FIFE::Image::m_xshift, FIFE::Image::m_yshift, FIFE::IResource::RES_NOT_LOADED, and setSurface().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 151 of file sdlimage.cpp.
References FIFE::Image::m_shared, and FIFE::Image::m_surface.
SDL_Texture * FIFE::SDLImage::getTexture | ( | ) |
Definition at line 224 of file sdlimage.cpp.
References m_texture.
Referenced by FIFE::RenderBackendSDL::attachRenderTarget(), and useSharedImage().
|
virtual |
Invalidates the Image causing it to be reset or re-loaded.
Implements FIFE::Image.
Definition at line 86 of file sdlimage.cpp.
References FIFE::Image::m_shared, and m_texture.
Referenced by setSurface(), and ~SDLImage().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 200 of file sdlimage.cpp.
References FIFE::ImageManager::create(), FIFE::ImageManager::exists(), FIFE::DynamicSingleton< ImageManager >::instance(), FIFE::Image::load(), m_atlas_img, m_atlas_name, FIFE::Image::m_subimagerect, and useSharedImage().
Referenced by render(), and validateShared().
|
virtual |
Renders itself to the current render target (main screen or attached destination image) at the rectangle rect.
Convenience function
rect | The position and clipping where to draw this image to. |
alpha | The alpha value, with which to draw self. |
rgb | The color value of overlay if any. |
Implements FIFE::Image.
Definition at line 99 of file sdlimage.cpp.
References FIFE::RectType< T >::bottom(), FIFE::Image::getArea(), FIFE::RenderBackend::getRenderTargetSurface(), FIFE::Image::getSubImageRect(), FIFE::RectType< T >::h, FIFE::DynamicSingleton< RenderBackend >::instance(), load(), FIFE::Image::m_shared, FIFE::Image::m_surface, m_texture, FIFE::RectType< T >::right(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
|
private |
Definition at line 77 of file sdlimage.cpp.
References FIFE::RenderBackend::getColorKey(), FIFE::DynamicSingleton< RenderBackend >::instance(), m_colorkey, and m_texture.
Referenced by SDLImage(), and setSurface().
|
virtual |
This frees the current suface and replaces it with the surface passed in the parameter (which can be NULL).
surface | the SDL_Surface to use for this image |
Implements FIFE::Image.
Definition at line 93 of file sdlimage.cpp.
References invalidate(), FIFE::Image::reset(), and resetSdlimage().
Referenced by free(), and useSharedImage().
void FIFE::SDLImage::setTexture | ( | SDL_Texture * | texture | ) |
Definition at line 228 of file sdlimage.cpp.
References FIFE::Image::m_shared, and m_texture.
Referenced by FIFE::RenderBackendSDL::attachRenderTarget(), and useSharedImage().
After this call all image data will be taken from the given image and its subregion.
Implements FIFE::Image.
Definition at line 160 of file sdlimage.cpp.
References FIFE::SharedPtr< T >::get(), FIFE::IResource::getName(), FIFE::IResource::getState(), FIFE::Image::getSurface(), getTexture(), FIFE::DynamicSingleton< RenderBackend >::instance(), FIFE::Image::load(), m_atlas_img, m_atlas_name, FIFE::Image::m_shared, FIFE::Image::m_subimagerect, m_texture, FIFE::IResource::RES_LOADED, FIFE::IResource::setState(), setSurface(), and setTexture().
Referenced by load().
|
private |
Definition at line 189 of file sdlimage.cpp.
References FIFE::IResource::getState(), load(), m_atlas_img, m_atlas_name, and FIFE::IResource::RES_NOT_LOADED.
Referenced by forceLoadInternal().
|
private |
Definition at line 72 of file sdlimage.h.
Referenced by load(), useSharedImage(), and validateShared().
|
private |
Definition at line 74 of file sdlimage.h.
Referenced by load(), useSharedImage(), and validateShared().
|
private |
Definition at line 67 of file sdlimage.h.
Referenced by resetSdlimage().
|
private |
Definition at line 69 of file sdlimage.h.
Referenced by getTexture(), invalidate(), render(), resetSdlimage(), setTexture(), and useSharedImage().