FIFE
|
Implements an Image using experimental OpenGL. More...
#include <gleimage.h>
Public Member Functions | |
GLeImage (IResourceLoader *loader=0) | |
GLeImage (const std::string &name, IResourceLoader *loader=0) | |
GLeImage (SDL_Surface *surface) | |
GLeImage (const std::string &name, SDL_Surface *surface) | |
GLeImage (const uint8_t *data, uint32_t width, uint32_t height) | |
GLeImage (const std::string &name, const uint8_t *data, uint32_t width, uint32_t height) | |
virtual | ~GLeImage () |
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 | renderZ (const Rect &rect, float vertexZ, uint8_t alpha=255, bool forceNewBatch=false, 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) |
![]() | |
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... | |
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 GLeImage variables. More... | |
void | generateGLTexture () |
Generates the GL Texture for use when rendering. More... | |
void | generateGLSharedTexture (const GLeImage *shared, const Rect ®ion) |
void | validateShared () |
bool | renderCheck (const Rect &rect, uint8_t alpha) |
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 |
GLeImage * | 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 experimental OpenGL.
This class contains a texture handle bound to the data given to the constructor; it draws a textured Quad to the screen.
Definition at line 53 of file gleimage.h.
FIFE::GLeImage::GLeImage | ( | IResourceLoader * | loader = 0 | ) |
Definition at line 39 of file gleimage.cpp.
References resetGlimage().
FIFE::GLeImage::GLeImage | ( | const std::string & | name, |
IResourceLoader * | loader = 0 |
||
) |
Definition at line 47 of file gleimage.cpp.
References resetGlimage().
FIFE::GLeImage::GLeImage | ( | SDL_Surface * | surface | ) |
Definition at line 55 of file gleimage.cpp.
References resetGlimage().
FIFE::GLeImage::GLeImage | ( | const std::string & | name, |
SDL_Surface * | surface | ||
) |
Definition at line 63 of file gleimage.cpp.
References resetGlimage().
FIFE::GLeImage::GLeImage | ( | const uint8_t * | data, |
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 71 of file gleimage.cpp.
References FIFE::Image::m_surface, and resetGlimage().
FIFE::GLeImage::GLeImage | ( | const std::string & | name, |
const uint8_t * | data, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 80 of file gleimage.cpp.
References FIFE::Image::m_surface, and resetGlimage().
|
virtual |
Definition at line 89 of file gleimage.cpp.
References cleanup().
|
private |
Frees allocated memory and calls resetGlImage.
Definition at line 111 of file gleimage.cpp.
References m_compressed, FIFE::Image::m_shared, m_tex_coords, and m_texId.
Referenced by resetGlimage(), and ~GLeImage().
|
virtual |
Copies given image into this one with respect to given offsets.
Reimplemented from FIFE::Image.
Definition at line 389 of file gleimage.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 364 of file gleimage.cpp.
References generateGLTexture(), FIFE::Image::m_shared, m_texId, and validateShared().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 425 of file gleimage.cpp.
References FIFE::IResource::m_state, FIFE::IResource::RES_NOT_LOADED, and setSurface().
|
private |
Definition at line 330 of file gleimage.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 161 of file gleimage.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(), renderCheck(), and validateShared().
const GLfloat * FIFE::GLeImage::getTexCoords | ( | ) | const |
Definition at line 434 of file gleimage.cpp.
References m_tex_coords.
GLuint FIFE::GLeImage::getTexId | ( | ) | const |
Definition at line 430 of file gleimage.cpp.
References m_texId.
Referenced by FIFE::RenderBackendOpenGLe::attachRenderTarget().
|
virtual |
Invalidates the Image causing it to be reset or re-loaded.
Implements FIFE::Image.
Definition at line 93 of file gleimage.cpp.
References resetGlimage().
|
inline |
Definition at line 75 of file gleimage.h.
References m_compressed.
Referenced by FIFE::RenderBackendOpenGLe::attachRenderTarget().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 399 of file gleimage.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 147 of file gleimage.cpp.
References FIFE::RenderBackend::addImageToArray(), FIFE::DynamicSingleton< RenderBackend >::instance(), m_tex_coords, m_texId, and renderCheck().
|
inlineprivate |
Definition at line 124 of file gleimage.cpp.
References FIFE::RectType< T >::bottom(), generateGLTexture(), FIFE::RenderBackend::getRenderTargetSurface(), FIFE::DynamicSingleton< RenderBackend >::instance(), FIFE::Image::m_shared, FIFE::Image::m_surface, m_texId, FIFE::RectType< T >::right(), validateShared(), FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
Referenced by render(), and renderZ().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 154 of file gleimage.cpp.
References FIFE::DynamicSingleton< RenderBackend >::instance(), m_tex_coords, m_texId, and renderCheck().
|
private |
Resets GLeImage variables.
Definition at line 102 of file gleimage.cpp.
References cleanup(), FIFE::RenderBackend::getColorKey(), FIFE::DynamicSingleton< RenderBackend >::instance(), m_chunk_size_h, m_chunk_size_w, and m_colorkey.
Referenced by GLeImage(), invalidate(), and setSurface().
|
inline |
Definition at line 76 of file gleimage.h.
References m_compressed.
Referenced by FIFE::RenderBackendOpenGLe::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 97 of file gleimage.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 345 of file gleimage.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 372 of file gleimage.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 renderCheck().
|
private |
Definition at line 124 of file gleimage.h.
Referenced by load(), and useSharedImage().
|
private |
Definition at line 126 of file gleimage.h.
Referenced by load(), and useSharedImage().
|
private |
Definition at line 118 of file gleimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 117 of file gleimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 120 of file gleimage.h.
Referenced by generateGLTexture(), and resetGlimage().
|
private |
Definition at line 82 of file gleimage.h.
Referenced by cleanup(), generateGLTexture(), isCompressed(), load(), setCompressed(), useSharedImage(), and validateShared().
|
private |
Definition at line 122 of file gleimage.h.
Referenced by load(), useSharedImage(), and validateShared().
|
private |
Definition at line 79 of file gleimage.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 99 of file gleimage.h.
Referenced by cleanup(), copySubimage(), forceLoadInternal(), generateGLTexture(), getTexId(), load(), render(), renderCheck(), renderZ(), useSharedImage(), and validateShared().