|
FIFE
|
Implements an Image using OpenGL. More...
#include <glimage.h>
Inheritance diagram for FIFE::GLImage:
Collaboration diagram for FIFE::GLImage: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 | 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 | 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) |
Public Member Functions inherited from FIFE::Image | |
| 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... | |
Public Member Functions inherited from FIFE::IResource | |
| 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 | |
Public Types inherited from FIFE::IResource | |
| enum | ResourceState { RES_INVALID = 0, RES_NOT_LOADED, RES_LOADED } |
Static Public Member Functions inherited from FIFE::Image | |
| 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) |
Protected Member Functions inherited from FIFE::Image | |
| 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... | |
Protected Attributes inherited from FIFE::Image | |
| SDL_Surface * | m_surface |
| int32_t | m_xshift |
| int32_t | m_yshift |
| bool | m_shared |
| Rect | m_subimagerect |
Protected Attributes inherited from FIFE::IResource | |
| 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().
Here is the caller graph for this function:
|
virtual |
Copies given image into this one with respect to given offsets.
Reimplemented from FIFE::Image.
Definition at line 537 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 510 of file glimage.cpp.
References generateGLTexture(), FIFE::Image::m_shared, m_texId, and validateShared().
Referenced by render(), FIFE::RenderBackendOpenGL::renderGuiGeometry(), and renderZ().
Here is the caller graph for this function:
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 573 of file glimage.cpp.
References FIFE::IResource::m_state, FIFE::IResource::RES_NOT_LOADED, and setSurface().
Definition at line 468 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::TEXTURE_FILTER_NONE, FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
Referenced by load(), useSharedImage(), and validateShared().
Here is the caller graph for this function:
|
private |
Generates the GL Texture for use when rendering.
Definition at line 230 of file glimage.cpp.
References FIFE::RenderBackend::getRenderTargetSurface(), FIFE::DynamicSingleton< RenderBackend >::instance(), FIFE::RenderBackend::isColorKeyEnabled(), FIFE::RenderBackend::isMipmappingEnabled(), FIFE::RenderBackend::isMonochromeEnabled(), 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, FIFE::TEXTURE_FILTER_ANISOTROPIC, FIFE::TEXTURE_FILTER_BILINEAR, FIFE::TEXTURE_FILTER_NONE, FIFE::TEXTURE_FILTER_TRILINEAR, and validateShared().
Referenced by forceLoadInternal(), render(), renderZ(), and validateShared().
Here is the caller graph for this function:| const GLfloat * FIFE::GLImage::getTexCoords | ( | ) | const |
Definition at line 582 of file glimage.cpp.
References m_tex_coords.
Referenced by render(), and renderZ().
Here is the caller graph for this function:| GLuint FIFE::GLImage::getTexId | ( | ) | const |
Definition at line 578 of file glimage.cpp.
References m_texId.
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget(), render(), FIFE::RenderBackendOpenGL::renderGuiGeometry(), and renderZ().
Here is the caller graph for this function:
|
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 79 of file glimage.h.
References m_compressed.
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget().
Here is the caller graph for this function:
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 547 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, FIFE::IResource::RES_LOADED, and validateShared().
Referenced by generateGLTexture(), and validateShared().
Here is the caller graph for this function:
|
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.
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 149 of file glimage.cpp.
References FIFE::RectType< T >::bottom(), forceLoadInternal(), generateGLTexture(), FIFE::SharedPtr< T >::get(), FIFE::RenderBackend::getRenderTargetSurface(), getTexCoords(), getTexId(), 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.
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 177 of file glimage.cpp.
References 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.
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 202 of file glimage.cpp.
References FIFE::RectType< T >::bottom(), forceLoadInternal(), generateGLTexture(), FIFE::SharedPtr< T >::get(), FIFE::RenderBackend::getRenderTargetSurface(), getTexCoords(), getTexId(), 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().
Here is the caller graph for this function:
|
inline |
Definition at line 80 of file glimage.h.
References m_compressed.
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget().
Here is the caller graph for this function:
|
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().
Here is the caller graph for this function:After this call all image data will be taken from the given image and its subregion.
Implements FIFE::Image.
Definition at line 491 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 518 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(), load(), render(), and renderZ().
Here is the caller graph for this function:
|
private |
Definition at line 126 of file glimage.h.
Referenced by load(), and useSharedImage().
|
private |
Definition at line 128 of file glimage.h.
Referenced by load(), and useSharedImage().
|
private |
Definition at line 120 of file glimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 119 of file glimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 122 of file glimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 86 of file glimage.h.
Referenced by cleanup(), generateGLTexture(), isCompressed(), load(), setCompressed(), useSharedImage(), and validateShared().
|
private |
Definition at line 124 of file glimage.h.
Referenced by load(), useSharedImage(), and validateShared().
|
private |
Definition at line 83 of file glimage.h.
Referenced by cleanup(), generateGLSharedTexture(), generateGLTexture(), getTexCoords(), render(), and renderZ().
|
private |
Holds texture ids that are used to access textures in GL rendering context.
Definition at line 103 of file glimage.h.
Referenced by cleanup(), copySubimage(), forceLoadInternal(), generateGLTexture(), getTexId(), load(), render(), renderZ(), useSharedImage(), and validateShared().