Unofficial OpenGL Software Development Kit  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members | Public Member Functions
glimg::ImageCreator Class Reference

#include <ImageCreator.h>

A factory object for creating ImageSet objects.

Creating a valid ImageSet is a complicated task. To ensure the validity and veracity of data for ImageSet objects, the task of creating them is managed by this factory object.

This object can be copy constructed (but not copy-assigned), which will copy all of the pixel data uploaded thus far.

The ImageFormat given to this class's constructor serves double-duty. It will be the ImageFormat that the resulting ImageSet gets, but it also describes the expected arrangement of any pixel data given to the object. This includes the alignment part of the ImageFormat.

Since ImageCreator is designed to be used with OpenGL, it can flip any incoming pixel data written to it. If you send image data in top-left coordinates, it will flip the pixels to bottom-left. This includes compressed textures.

Public Member Functions

 ImageCreator (ImageFormat format, Dimensions dimensions, int mipmapCount, int arrayCount, int faceCount)
 Creates an ImageCreator factory for making ImageSet objects. More...
 
void SetImageData (const void *pixelData, bool isTopLeft, int mipmapLevel, int arrayIx=0, int faceIx=0)
 Sets the data for a single image. More...
 
void SetFullMipmapLevel (const void *pixelData, bool isTopLeft, int mipmapLevel)
 Sets the data for an entire mipmap layer. More...
 
ImageSetCreateImage ()
 Creates an ImageSet from the stored data. After the completion of this function, this ImageCreator object is now dead. More...
 

Constructor & Destructor Documentation

glimg::ImageCreator::ImageCreator ( ImageFormat  format,
Dimensions  dimensions,
int  mipmapCount,
int  arrayCount,
int  faceCount 
)

Creates an ImageCreator factory for making ImageSet objects.

This constructor will initialize all pixel data to 0. All memory allocation is done by the constructor; this ensures that there will be data for images that were asked for even if the user does not specify them.

Parameters
formatThe ImageFormat for the ImageSet to be created.
dimensionsThe dimensionality of the base layer of the image.
mipmapCountThe number of mipmaps in the image.
arrayCountThe number of arrays of the image.
faceCountThe number of faces of the image. Must be either 1 or 6.
Exceptions
BadFaceCountExceptionIf faceCount is not 1 or 6.
CubemapsMustBe2DExceptionIf faceCount is 6 and dimensions.numDimensions != 2.
No3DTextureArrayExceptionIf arrayCount > 1 and dimensions.numDimensions == 3.
NoImagesSpecifiedExceptionIf mipmapCount or arrayCount is <= 0, thus specifying no images.

Member Function Documentation

ImageSet* glimg::ImageCreator::CreateImage ( )

Creates an ImageSet from the stored data. After the completion of this function, this ImageCreator object is now dead.

Do not use the ImageCreator object after calling this. Deleting it is fine, but the data has been transferred to the ImageSet, and no longer resides in the ImageCreator. Any attempt to use this object afterwards will result in a ImageSetAlreadyCreatedException exception.

This object is a copyable object (so long as you use copy construction, not copy assignment), so if you want to make multiple ImageSet objects from the same ImageCreator, just copy construct the object before creating it. The copy will replicate the data.

void glimg::ImageCreator::SetFullMipmapLevel ( const void *  pixelData,
bool  isTopLeft,
int  mipmapLevel 
)

Sets the data for an entire mipmap layer.

Each mipmap layer contains a number of array images and faces. This function will specify all of this data in one shot. Each array of the image data contains faceCount faces. These cubemap faces are ordered as defined by the ARB_texture_cube_map_array extension.

If faceCount was 1, then there will only be one face instead of the 6. If arrayCount was 1 then there will only be one set of faces. And if they were both 1, then there is only one image per mipmap level.

Parameters
pixelDataThe pixel data for the mipmap. It is expected to be formatted exactly as specified by the ImageFormat given to this ImageCreator at creation time. It must contain all of the pixel data in the order as above.
isTopLeftTrue if the orientation of the given image data is top-left. False if it is bottom-left.
mipmapLevelThe mipmap layer to set to.
Exceptions
ImageSetAlreadyCreatedExceptionIf CreateImage has already been called for this ImageCreator.
MipmapLayerOutOfBoundsExceptionIf mipmapLevel is outside of the mipmapCount range specified in the constructor.
void glimg::ImageCreator::SetImageData ( const void *  pixelData,
bool  isTopLeft,
int  mipmapLevel,
int  arrayIx = 0,
int  faceIx = 0 
)

Sets the data for a single image.

The pixel data from the given buffer will be copied into the given image in the ImageCreator.

Parameters
pixelDataThe pixel data for the mipmap. It is expected to be formatted exactly as specified by the ImageFormat given to this ImageCreator at creation time.
isTopLeftTrue if the orientation of the given image data is top-left. False if it is bottom-left.
mipmapLevelThe mipmap layer of the image to set.
arrayIxThe array index of the image to set.
faceIxThe face index of the image to set.
Exceptions
ImageSetAlreadyCreatedExceptionIf CreateImage has already been called for this ImageCreator.
MipmapLayerOutOfBoundsExceptionIf mipmapLevel is outside of the mipmapCount range specified in the constructor.
ArrayOutOfBoundsExceptionIf arrayIx is outside of the arrayCount range specified in the constructor.
FaceIndexOutOfBoundsExceptionIf faceIx is outside of the faceCount range specified in the constructor.

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