GL Studio SCECpp Runtime Library
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
GlsImage Class Reference

#include <gls_image.h>

Classes

class  ImageList
 
struct  InitParameters
 
struct  InlineImage
 

Public Types

enum  ImageCodec { IMAGE_CODEC_RAW, IMAGE_CODEC_RLE }
 
enum  InputPixelFormat { INPUT_PIXEL_FORMAT_RGB, INPUT_PIXEL_FORMAT_RGBA, INPUT_PIXEL_FORMAT_ALPHA }
 

Public Member Functions

void BindTexture (GlsStateManager &gl) const
 
GlsBool IsEqual (const InlineImage &inlineImage) const
 

Static Public Member Functions

static void Initialize (const InitParameters &initParameters)
 
static GlsImageGetGlsImageFromInlineImage (const InlineImage &inlineImage, const GlsBool checkForDuplicate)
 

Protected Types

enum  {
  PIXEL_GL_RED_COMPONENT = 0u, PIXEL_GL_GREEN_COMPONENT, PIXEL_GL_BLUE_COMPONENT, PIXEL_GL_ALPHA_COMPONENT,
  NUM_BYTES_PER_PIXEL_GL
}
 

Protected Member Functions

 GlsImage (const InlineImage &inlineImage)
 
void DecodeImage (const InlineImage &inlineImage)
 
GlsUInt32 PixelSizeFromInputPixelFormat (const GlsImage::InputPixelFormat inputPixelFormat) const
 
virtual ~GlsImage ()
 

Protected Attributes

GLuint _textureHandle
 
const InputPixelFormat _inputPixelFormat
 
const GlsUInt32 _width
 
const GlsUInt32 _height
 
const GlsUInt32 _crcValue
 

Static Protected Attributes

static const GLuint INVALID_TEXTURE_HANDLE = 0u
 
static const GlsUInt32 NUM_BYTES_PER_INPUT_PIXEL_FORMAT_RGB = 3u
 
static const GlsUInt32 NUM_BYTES_PER_INPUT_PIXEL_FORMAT_RGBA = 4u
 
static const GlsUInt32 NUM_BYTES_PER_INPUT_PIXEL_FORMAT_ALPHA = 1u
 
static ImageList_imageList
 
static GlsUChar_scanlineImageData
 

Detailed Description

Encapsulates a 2D image

Invariant
INVALID_TEXTURE_HANDLE != _textureHandle, GlsImageInputPixelFormatIsValid( _inputPixelFormat ), _pixelSize > 0, ( _height > 0 ) && IsPowerOf2( _height ), ( _width > 0 ) && IsPowerOf2( _width ), _imageList != GLS_NULL ( ( _maxImageWidth > 0u ) && IsPowerOf2( _maxImageWidth ) ), GlsAssert( GLS_NULL != _scanlineImageData != GLS_NULL

Member Enumeration Documentation

anonymous enum
protected

corresponds to layout of a GL_RGBA8 pixel

Enumerator
PIXEL_GL_RED_COMPONENT 

GL_RGBA8 - red component

PIXEL_GL_GREEN_COMPONENT 

GL_RGBA8 - green component

PIXEL_GL_BLUE_COMPONENT 

GL_RGBA8 - blue component

PIXEL_GL_ALPHA_COMPONENT 

GL_RGBA8 - alpha component

NUM_BYTES_PER_PIXEL_GL 

number of bytes per pixel in GL texture data

enumeration of possible image compression codecs

Enumerator
IMAGE_CODEC_RAW 

Image data is not compressed

IMAGE_CODEC_RLE 

Image data is compressed with RLE ( Run Length Encoded )

enumeration of supported input pixel formats

Enumerator
INPUT_PIXEL_FORMAT_RGB 

red, green, blue

INPUT_PIXEL_FORMAT_RGBA 

red, green, blue, alpha

INPUT_PIXEL_FORMAT_ALPHA 

alpha

Constructor & Destructor Documentation

GlsImage::GlsImage ( const InlineImage inlineImage)
protected

Constructor - create an image from the given inline image

Parameters
inlineImageinline image in question
Precondition
inlineImage.IsValid(), the GlsImage subsystem has been initialized, inlineImage.width <= _maxImageWidth
Postcondition
image constructed
virtual GlsImage::~GlsImage ( )
protectedvirtual

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

void GlsImage::BindTexture ( GlsStateManager gl) const

Make this image the active GL texture.

Precondition
glIsTexture( _textureHandle ) == GL_TRUE
Postcondition
image is bound to GL
void GlsImage::DecodeImage ( const InlineImage inlineImage)
protected

decode the given inline image and upload to GL

Parameters
inlineImageinline image in question
Precondition
inlineImage.IsValid(), inlineImage.codec is either IMAGE_CODEC_RLE or IMAGE_CODEC_RAW, inlineImage.width <= _maxImageWidth, inlineImage.inputPixelFormat must be either INPUT_PIXEL_FORMAT_ALPHA, INPUT_PIXEL_FORMAT_RGB, or INPUT_PIXEL_FORMAT_RGBA empty texture of appropriate size is created and bound to GL, the GlsImage subsystem has been initialized
Postcondition
image is decoded and uploaded to GL
static GlsImage* GlsImage::GetGlsImageFromInlineImage ( const InlineImage inlineImage,
const GlsBool  checkForDuplicate 
)
static

Get an Image object with the given GlsInlineImage data. If checkForDuplicate is GLS_TRUE, this method checks to see if an image has already been constructed for the GlsInlineImage and if found, returns the previously constructed image.

Parameters
inlineImageGlsInlineImage in question
checkForDuplicateGLS_TRUE to check if this inline image is a duplicate of an existing image else GLS_FALSE
Returns
image corresponding to given inline image
Precondition
inlineImage.IsValid(), a GlsStateManager instance does not yet exist, the GlsImage subsytem has been initialized, inlineImage.width <= _maxImageWidth
Postcondition
new image constructed as needed
static void GlsImage::Initialize ( const InitParameters initParameters)
static

Initialize the GlsImage subsystem. This is a one time call that must be made before the image subsystem can be used.

Parameters
initParametersinitialization parameters for GlsImage subsystem
Precondition
GlsImage subsystem has not already been initialized, initParameters.IsValid()
Postcondition
GlsImage subsystem intermediate image buffers and image list are allocated
GlsBool GlsImage::IsEqual ( const InlineImage inlineImage) const

Determine if this image matches the given inline image

Parameters
inlineImageinline image in question
Returns
GLS_TRUE if matches inline image else GLS_FALSE
Precondition
inlineImage.IsValid()
Postcondition
none
GlsUInt32 GlsImage::PixelSizeFromInputPixelFormat ( const GlsImage::InputPixelFormat  inputPixelFormat) const
protected

Get the number of bytes required per pixel for the given format

Parameters
inputPixelFormatformat in question
Returns
number of bytes required per pixel for format
Precondition
GlsImageInputPixelFormatIsValid( inputPixelFormat )
Postcondition
none

Member Data Documentation

const GlsUInt32 GlsImage::_crcValue
protected

CRC value used to determine if two images are the same

const GlsUInt32 GlsImage::_height
protected

height of image in pixels. must be a power of 2

ImageList* GlsImage::_imageList
staticprotected

singleton image list

const InputPixelFormat GlsImage::_inputPixelFormat
protected

Input pixel format of image

GlsUChar* GlsImage::_scanlineImageData
staticprotected

intermediate image buffer for RGBA image data scanline, number of bytes = ( NUM_BYTES_PER_PIXEL_GL * _maxWidth

GLuint GlsImage::_textureHandle
protected

The texture handle of the image, else INVALID_TEXTURE_HANDLE

const GlsUInt32 GlsImage::_width
protected

width of image in pixels. must be a power of 2

const GLuint GlsImage::INVALID_TEXTURE_HANDLE = 0u
staticprotected

value indicating invalid texture handle

const GlsUInt32 GlsImage::NUM_BYTES_PER_INPUT_PIXEL_FORMAT_ALPHA = 1u
staticprotected

number of bytes per input pixel for INPUT_PIXEL_FORMAT_ALPHA

const GlsUInt32 GlsImage::NUM_BYTES_PER_INPUT_PIXEL_FORMAT_RGB = 3u
staticprotected

number of bytes per input pixel for INPUT_PIXEL_FORMAT_RGB

const GlsUInt32 GlsImage::NUM_BYTES_PER_INPUT_PIXEL_FORMAT_RGBA = 4u
staticprotected

number of bytes per input pixel for INPUT_PIXEL_FORMAT_RGBA