FIFE
|
Implements an Image using OpenGL. More...
#include <glimage.h>
Public Member Functions | |
GLImage (IResourceLoader *loader=0) | |
GLImage (const std::string &name, IResourceLoader *loader=0) | |
GLImage (SDL_Surface *surface) | |
GLImage (const std::string &name, SDL_Surface *surface) | |
GLImage (const uint8_t *data, uint32_t width, uint32_t height) | |
GLImage (const std::string &name, const uint8_t *data, uint32_t width, uint32_t height) | |
virtual | ~GLImage () |
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 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 | copySubimage (uint32_t xoffset, uint32_t yoffset, const ImagePtr &img) |
Copies given image into this one with respect to given offsets. More... | |
virtual void | load () |
virtual void | free () |
GLuint | getTexId () const |
const GLfloat * | getTexCoords () const |
bool | isCompressed () const |
void | setCompressed (bool compressed) |
![]() | |
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 | 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 |
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) |
virtual size_t | getSize () |
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... | |
![]() | |
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 | cleanup () |
Frees allocated memory and calls resetGlImage. More... | |
void | resetGlimage () |
Resets GLImage variables. More... | |
void | generateGLTexture () |
Generates the GL Texture for use when rendering. More... | |
void | generateGLSharedTexture (const GLImage *shared, const Rect ®ion) |
void | validateShared () |
Private Attributes | |
GLfloat | m_tex_coords [4] |
bool | m_compressed |
GLuint | m_texId |
Holds texture ids that are used to access textures in GL rendering context. More... | |
uint32_t | m_chunk_size_w |
uint32_t | m_chunk_size_h |
SDL_Color | m_colorkey |
GLImage * | m_shared_img |
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 |
Implements an Image using OpenGL.
This class contains a texture handle bound to the data given to the constructor; it draws a textured Quad to the screen.
FIFE::GLImage::GLImage | ( | IResourceLoader * | loader = 0 | ) |
Definition at line 40 of file glimage.cpp.
References resetGlimage().
FIFE::GLImage::GLImage | ( | const std::string & | name, |
IResourceLoader * | loader = 0 |
||
) |
Definition at line 48 of file glimage.cpp.
References resetGlimage().
FIFE::GLImage::GLImage | ( | SDL_Surface * | surface | ) |
Definition at line 56 of file glimage.cpp.
References resetGlimage().
FIFE::GLImage::GLImage | ( | const std::string & | name, |
SDL_Surface * | surface | ||
) |
Definition at line 64 of file glimage.cpp.
References resetGlimage().
FIFE::GLImage::GLImage | ( | const uint8_t * | data, |
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 72 of file glimage.cpp.
References FIFE::Image::m_surface, and resetGlimage().
FIFE::GLImage::GLImage | ( | const std::string & | name, |
const uint8_t * | data, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 81 of file glimage.cpp.
References FIFE::Image::m_surface, and resetGlimage().
|
virtual |
Definition at line 90 of file glimage.cpp.
References cleanup().
|
private |
Frees allocated memory and calls resetGlImage.
Definition at line 112 of file glimage.cpp.
References m_compressed, FIFE::Image::m_shared, m_tex_coords, and m_texId.
Referenced by resetGlimage(), and ~GLImage().
|
virtual |
Copies given image into this one with respect to given offsets.
Reimplemented from FIFE::Image.
Definition at line 376 of file glimage.cpp.
References FIFE::Image::copySubimage(), FIFE::Image::getHeight(), FIFE::Image::getSurface(), FIFE::Image::getWidth(), FIFE::DynamicSingleton< RenderBackend >::instance(), and m_texId.
|
virtual |
Forces to load the image into internal memory of GPU.
Implements FIFE::Image.
Definition at line 351 of file glimage.cpp.
References generateGLTexture(), FIFE::Image::m_shared, m_texId, and validateShared().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 412 of file glimage.cpp.
References FIFE::IResource::m_state, FIFE::IResource::RES_NOT_LOADED, and setSurface().
Definition at line 317 of file glimage.cpp.
References FIFE::Image::getHeight(), FIFE::Image::getWidth(), FIFE::RectType< T >::h, FIFE::DynamicSingleton< RenderBackend >::instance(), m_tex_coords, FIFE::nextPow2(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
Referenced by load(), useSharedImage(), and validateShared().
|
private |
Generates the GL Texture for use when rendering.
Definition at line 149 of file glimage.cpp.
References FIFE::RenderBackend::getRenderTargetSurface(), FIFE::DynamicSingleton< RenderBackend >::instance(), FIFE::RenderBackend::isColorKeyEnabled(), load(), m_chunk_size_h, m_chunk_size_w, m_colorkey, m_compressed, FIFE::Image::m_shared, FIFE::IResource::m_state, FIFE::Image::m_surface, m_tex_coords, m_texId, FIFE::nextPow2(), FIFE::IResource::RES_NOT_LOADED, and validateShared().
Referenced by forceLoadInternal(), render(), and validateShared().
const GLfloat * FIFE::GLImage::getTexCoords | ( | ) | const |
Definition at line 421 of file glimage.cpp.
References m_tex_coords.
GLuint FIFE::GLImage::getTexId | ( | ) | const |
Definition at line 417 of file glimage.cpp.
References m_texId.
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget().
|
virtual |
Invalidates the Image causing it to be reset or re-loaded.
Implements FIFE::Image.
Definition at line 94 of file glimage.cpp.
References resetGlimage().
|
inline |
Definition at line 74 of file glimage.h.
References m_compressed.
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 386 of file glimage.cpp.
References FIFE::ImageManager::create(), generateGLSharedTexture(), FIFE::SharedPtr< T >::get(), FIFE::DynamicSingleton< ImageManager >::instance(), FIFE::Image::load(), m_atlas_img, m_atlas_name, m_compressed, FIFE::Image::m_shared, m_shared_img, FIFE::IResource::m_state, FIFE::Image::m_subimagerect, FIFE::Image::m_surface, m_texId, and FIFE::IResource::RES_LOADED.
Referenced by generateGLTexture(), 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 125 of file glimage.cpp.
References FIFE::RenderBackend::addImageToArray(), FIFE::RectType< T >::bottom(), generateGLTexture(), FIFE::RenderBackend::getRenderTargetSurface(), FIFE::DynamicSingleton< RenderBackend >::instance(), FIFE::Image::m_shared, FIFE::Image::m_surface, m_tex_coords, m_texId, FIFE::RectType< T >::right(), validateShared(), FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
|
private |
Resets GLImage variables.
Definition at line 103 of file glimage.cpp.
References cleanup(), FIFE::RenderBackend::getColorKey(), FIFE::DynamicSingleton< RenderBackend >::instance(), m_chunk_size_h, m_chunk_size_w, and m_colorkey.
Referenced by GLImage(), invalidate(), and setSurface().
|
inline |
Definition at line 75 of file glimage.h.
References m_compressed.
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget().
|
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 98 of file glimage.cpp.
References FIFE::Image::reset(), and resetGlimage().
Referenced by free().
After this call all image data will be taken from the given image and its subregion.
Implements FIFE::Image.
Definition at line 332 of file glimage.cpp.
References generateGLSharedTexture(), FIFE::SharedPtr< T >::get(), FIFE::IResource::getName(), m_atlas_img, m_atlas_name, m_compressed, FIFE::Image::m_shared, m_shared_img, FIFE::Image::m_subimagerect, FIFE::Image::m_surface, m_texId, FIFE::IResource::RES_LOADED, and FIFE::IResource::setState().
|
private |
Definition at line 359 of file glimage.cpp.
References generateGLSharedTexture(), generateGLTexture(), FIFE::IResource::getState(), load(), m_compressed, m_shared_img, FIFE::Image::m_subimagerect, FIFE::Image::m_surface, m_texId, and FIFE::IResource::RES_NOT_LOADED.
Referenced by forceLoadInternal(), generateGLTexture(), and render().
|
private |
Definition at line 121 of file glimage.h.
Referenced by load(), and useSharedImage().
|
private |
Definition at line 123 of file glimage.h.
Referenced by load(), and useSharedImage().
|
private |
Definition at line 115 of file glimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 114 of file glimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 117 of file glimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 81 of file glimage.h.
Referenced by cleanup(), generateGLTexture(), isCompressed(), load(), setCompressed(), useSharedImage(), and validateShared().
|
private |
Definition at line 119 of file glimage.h.
Referenced by load(), useSharedImage(), and validateShared().
|
private |
Definition at line 78 of file glimage.h.
Referenced by cleanup(), generateGLSharedTexture(), generateGLTexture(), getTexCoords(), and render().
|
private |
Holds texture ids that are used to access textures in GL rendering context.
Definition at line 98 of file glimage.h.
Referenced by cleanup(), copySubimage(), forceLoadInternal(), generateGLTexture(), getTexId(), load(), render(), useSharedImage(), and validateShared().