FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FIFE::GLeImage Class Reference

Implements an Image using experimental OpenGL. More...

#include <gleimage.h>

+ Inheritance diagram for FIFE::GLeImage:
+ Collaboration diagram for FIFE::GLeImage:

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 &region)
 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...
 
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 RectgetArea () 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 RectgetSubImageRect () 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 GLeImage variables. More...
 
void generateGLTexture ()
 Generates the GL Texture for use when rendering. More...
 
void generateGLSharedTexture (const GLeImage *shared, const Rect &region)
 
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
 
GLeImagem_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
 
IResourceLoaderm_loader
 
ResourceState m_state
 

Detailed Description

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.

See Also
Image
Note
Width and height are not limited to powers of two; non-power of two images will be converted internally if they are not supported by the hardware (GLEE_ARB_texture_non_power_of_two).

Definition at line 53 of file gleimage.h.

Constructor & Destructor Documentation

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().

FIFE::GLeImage::~GLeImage ( )
virtual

Definition at line 89 of file gleimage.cpp.

References cleanup().

Member Function Documentation

void FIFE::GLeImage::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().

+ Here is the caller graph for this function:

void FIFE::GLeImage::copySubimage ( uint32_t  xoffset,
uint32_t  yoffset,
const ImagePtr img 
)
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.

void FIFE::GLeImage::forceLoadInternal ( )
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().

void FIFE::GLeImage::free ( )
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().

void FIFE::GLeImage::generateGLSharedTexture ( const GLeImage shared,
const Rect region 
)
private
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().

+ Here is the caller graph for this function:

void FIFE::GLeImage::invalidate ( )
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().

bool FIFE::GLeImage::isCompressed ( ) const
inline

Definition at line 75 of file gleimage.h.

References m_compressed.

Referenced by FIFE::RenderBackendOpenGLe::attachRenderTarget().

+ Here is the caller graph for this function:

void FIFE::GLeImage::render ( const Rect rect,
uint8_t  alpha = 255,
uint8_t const *  rgb = 0 
)
virtual

Renders itself to the current render target (main screen or attached destination image) at the rectangle rect.

Convenience function

Parameters
rectThe position and clipping where to draw this image to.
alphaThe alpha value, with which to draw self.
rgbThe 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().

bool FIFE::GLeImage::renderCheck ( const Rect rect,
uint8_t  alpha 
)
inlineprivate
void FIFE::GLeImage::renderZ ( const Rect rect,
float  vertexZ,
uint8_t  alpha = 255,
bool  forceNewBatch = false,
uint8_t const *  rgb = 0 
)
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().

void FIFE::GLeImage::resetGlimage ( )
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().

+ Here is the caller graph for this function:

void FIFE::GLeImage::setCompressed ( bool  compressed)
inline

Definition at line 76 of file gleimage.h.

References m_compressed.

Referenced by FIFE::RenderBackendOpenGLe::attachRenderTarget().

+ Here is the caller graph for this function:

void FIFE::GLeImage::setSurface ( SDL_Surface *  surface)
virtual

This frees the current suface and replaces it with the surface passed in the parameter (which can be NULL).

See Also
Image::reset(SDL_Surface* surface)
Parameters
surfacethe 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().

+ Here is the caller graph for this function:

void FIFE::GLeImage::useSharedImage ( const ImagePtr shared,
const Rect region 
)
virtual
void FIFE::GLeImage::validateShared ( )
private

Member Data Documentation

ImagePtr FIFE::GLeImage::m_atlas_img
private

Definition at line 124 of file gleimage.h.

Referenced by load(), and useSharedImage().

std::string FIFE::GLeImage::m_atlas_name
private

Definition at line 126 of file gleimage.h.

Referenced by load(), and useSharedImage().

uint32_t FIFE::GLeImage::m_chunk_size_h
private

Definition at line 118 of file gleimage.h.

Referenced by generateGLTexture(), and resetGlimage().

uint32_t FIFE::GLeImage::m_chunk_size_w
private

Definition at line 117 of file gleimage.h.

Referenced by generateGLTexture(), and resetGlimage().

SDL_Color FIFE::GLeImage::m_colorkey
private

Definition at line 120 of file gleimage.h.

Referenced by generateGLTexture(), and resetGlimage().

bool FIFE::GLeImage::m_compressed
private
GLeImage* FIFE::GLeImage::m_shared_img
private

Definition at line 122 of file gleimage.h.

Referenced by load(), useSharedImage(), and validateShared().

GLfloat FIFE::GLeImage::m_tex_coords[4]
private
GLuint FIFE::GLeImage::m_texId
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().


The documentation for this class was generated from the following files: