NvImage Class Reference
GL-based image loading, representation and handling Support loading of images from DDS files and data, including cube maps, arrays mipmap levels, formats, etc. More...
#include <NvImage.h>
Classes | |
struct | FormatInfo |
Public Member Functions | |
int32_t | getWidth () const |
The image width in pixels. | |
int32_t | getHeight () const |
The image height in pixels. | |
int32_t | getDepth () const |
The image depth in pixels. | |
int32_t | getMipLevels () const |
The number of miplevels. | |
int32_t | getFaces () const |
The number of cubemap faces. | |
int32_t | getLayers () const |
The number of layers in a texture array. | |
uint32_t | getFormat () const |
The GL format of the image. | |
uint32_t | getInternalFormat () const |
The GL internal format of the image. | |
uint32_t | getType () const |
The GL type of the pixel data. | |
int32_t | getImageSize (int32_t level=0) const |
The size (in bytes) of a selected mipmap level of the image. | |
bool | isCompressed () const |
Whether or not the image is compressed. | |
bool | isCubeMap () const |
Whether or not the image is a cubemap. | |
bool | hasAlpha () const |
Whether or not the image's pixel format has an explicit alpha channel. | |
bool | isArray () const |
Whether or not the image is an array texture. | |
bool | isVolume () const |
Whether or not the image is a volume (3D) image. | |
bool | loadImageFromFileData (const uint8_t *fileData, size_t size, const char *fileExt) |
Loads an image from file-formatted data. | |
bool | convertCrossToCubemap () |
Convert a flat "cross" image to a cubemap Convert a suitable image from a cubemap cross to a cubemap. | |
bool | setImage (int32_t width, int32_t height, uint32_t format, uint32_t type, const void *data) |
const void * | getLevel (int32_t level) const |
void * | getLevel (int32_t level) |
const void * | getLevel (int32_t level, uint32_t face) const |
void * | getLevel (int32_t level, uint32_t face) |
const void * | getLayerLevel (int32_t level, int32_t slice) const |
void * | getLayerLevel (int32_t level, int32_t slice) |
Static Public Member Functions | |
static void | UpperLeftOrigin (bool ul) |
Sets the image origin to top or bottom. | |
static uint32_t | UploadTexture (NvImage *image) |
Create a new GL texture and upload the given image to it. | |
static uint32_t | UploadTextureFromDDSFile (const char *filename) |
Create a new GL texture directly from DDS file Uses NvAssetLoaderRead for opening the file. | |
static uint32_t | UploadTextureFromDDSData (const char *ddsData, int32_t length) |
Create a new GL texture directly from DDS file-formatted data. | |
static NvImage * | CreateFromDDSFile (const char *filename) |
Create a new NvImage (no texture) directly from DDS file Uses NvAssetLoaderRead for opening the file. | |
static void | setAPIVersion (const NvGfxAPIVersion &api) |
Set the API version to be targetted for image loading. | |
static const NvGfxAPIVersion & | getAPIVersion () |
Gets the current API-level for targetting the loading of images. | |
Friends | |
bool | TranslateDX10Format (const void *ptr, NvImage &i, int32_t &bytesPerElement, bool &btcCompressed) |
Detailed Description
GL-based image loading, representation and handling Support loading of images from DDS files and data, including cube maps, arrays mipmap levels, formats, etc.The class does NOT encapsulate a GL texture object, only the client side pixel data that could be used to create such a texture
Member Function Documentation
bool NvImage::convertCrossToCubemap | ( | ) |
Convert a flat "cross" image to a cubemap Convert a suitable image from a cubemap cross to a cubemap.
- Returns:
- true on success or false for unsuitable source images
static NvImage* NvImage::CreateFromDDSFile | ( | const char * | filename | ) | [static] |
Create a new NvImage (no texture) directly from DDS file Uses NvAssetLoaderRead for opening the file.
See the documentation for that package to understand the correct paths
- Parameters:
-
[in] filename the image filename (and path) to load
- Returns:
- a pointer to the NvImage representing the file or null on failure
static const NvGfxAPIVersion& NvImage::getAPIVersion | ( | ) | [inline, static] |
Gets the current API-level for targetting the loading of images.
- Returns:
- the current API level
int32_t NvImage::getDepth | ( | ) | const [inline] |
The image depth in pixels.
This is the third dimension of a 3D/volume image, NOT the color-depth
- Returns:
- the depth of the image (0 for images with no depth)
int32_t NvImage::getFaces | ( | ) | const [inline] |
The number of cubemap faces.
- Returns:
- the number of cubemap faces available for the image (0 for non-cubemap images)
uint32_t NvImage::getFormat | ( | ) | const [inline] |
The GL format of the image.
- Returns:
- the format of the image data (GL_RGB, GL_BGR, etc)
int32_t NvImage::getHeight | ( | ) | const [inline] |
The image height in pixels.
- Returns:
- the height of the image in pixels
int32_t NvImage::getImageSize | ( | int32_t | level = 0 |
) | const |
The size (in bytes) of a selected mipmap level of the image.
- Returns:
- the Size in bytes of a level of the image
- Parameters:
-
[in] level the mipmap level whose size if to be returned
uint32_t NvImage::getInternalFormat | ( | ) | const [inline] |
The GL internal format of the image.
- Returns:
- the suggested internal format for the data
void* NvImage::getLayerLevel | ( | int32_t | level, | |
int32_t | slice | |||
) |
Get a pointer to the pixel data for a given mipmap level and array slice.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] slice the layer index [0, getLayers)
- Returns:
- a pointer to the data
const void* NvImage::getLayerLevel | ( | int32_t | level, | |
int32_t | slice | |||
) | const |
Get a pointer to the pixel data for a given mipmap level and array slice.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] slice the layer index [0, getLayers)
- Returns:
- a pointer to the data
int32_t NvImage::getLayers | ( | ) | const [inline] |
The number of layers in a texture array.
- Returns:
- the number of layers for use in texture arrays
void* NvImage::getLevel | ( | int32_t | level, | |
uint32_t | face | |||
) |
Get a pointer to the pixel data for a given mipmap level and cubemap face.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] face the cubemap face (GL_TEXTURE_CUBE_MAP_*_*)
- Returns:
- a pointer to the data
const void* NvImage::getLevel | ( | int32_t | level, | |
uint32_t | face | |||
) | const |
Get a pointer to the pixel data for a given mipmap level and cubemap face.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] face the cubemap face (GL_TEXTURE_CUBE_MAP_*_*)
- Returns:
- a pointer to the data
void* NvImage::getLevel | ( | int32_t | level | ) |
Get a pointer to the pixel data for a given mipmap level.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels)
- Returns:
- a pointer to the data
const void* NvImage::getLevel | ( | int32_t | level | ) | const |
Get a pointer to the pixel data for a given mipmap level.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels)
- Returns:
- a pointer to the data
int32_t NvImage::getMipLevels | ( | ) | const [inline] |
The number of miplevels.
- Returns:
- the number of mipmap levels available for the image
uint32_t NvImage::getType | ( | ) | const [inline] |
The GL type of the pixel data.
- Returns:
- the type of the image data
int32_t NvImage::getWidth | ( | ) | const [inline] |
The image width in pixels.
- Returns:
- the width of the image in pixels
bool NvImage::hasAlpha | ( | ) | const |
Whether or not the image's pixel format has an explicit alpha channel.
- Returns:
- boolean whether the image has explicit alpha channel
bool NvImage::isArray | ( | ) | const [inline] |
Whether or not the image is an array texture.
- Returns:
- boolean whether the image represents a texture array
bool NvImage::isCompressed | ( | ) | const |
Whether or not the image is compressed.
- Returns:
- boolean whether the data is a crompressed format
bool NvImage::isCubeMap | ( | ) | const [inline] |
Whether or not the image is a cubemap.
- Returns:
- boolean whether the image represents a cubemap
bool NvImage::isVolume | ( | ) | const [inline] |
Whether or not the image is a volume (3D) image.
- Returns:
- boolean whether the image represents a volume
bool NvImage::loadImageFromFileData | ( | const uint8_t * | fileData, | |
size_t | size, | |||
const char * | fileExt | |||
) |
Loads an image from file-formatted data.
Initialize an image from file-formatted memory; only DDS files are supported
- Parameters:
-
[in] fileData the block of memory representing the entire image file [in] size the size of the data block in bytes [in] fileExt the file extension string; must be "dds"
- Returns:
- true on success, false on failure
static void NvImage::setAPIVersion | ( | const NvGfxAPIVersion & | api | ) | [inline, static] |
Set the API version to be targetted for image loading.
Images may be loaded differently for OpenGL ES and OpenGL. This function sends a hint to the loader which allows it to target the desired API level.
- Parameters:
-
[in] api the desired target API. Default is GL4 (highest-end features)
static uint32_t NvImage::UploadTexture | ( | NvImage * | image | ) | [static] |
Create a new GL texture and upload the given image to it.
- Parameters:
-
[in] image the image to load
- Returns:
- the GL texture ID on success, 0 on failure
static uint32_t NvImage::UploadTextureFromDDSData | ( | const char * | ddsData, | |
int32_t | length | |||
) | [static] |
Create a new GL texture directly from DDS file-formatted data.
- Parameters:
-
[in] ddsData the pointer to the DDS file data [in] length the size in bytes of the file block
- Returns:
- the GL texture ID on success, 0 on failure
static uint32_t NvImage::UploadTextureFromDDSFile | ( | const char * | filename | ) | [static] |
Create a new GL texture directly from DDS file Uses NvAssetLoaderRead for opening the file.
See the documentation for that package to understand the correct paths
- Parameters:
-
[in] filename the image filename (and path) to load
- Returns:
- the GL texture ID on success, 0 on failure
static void NvImage::UpperLeftOrigin | ( | bool | ul | ) | [static] |
Sets the image origin to top or bottom.
Sets the origin to be assumed when loading image data from file or data block By default, the image library places the origin of images at the lower-left corner, to make it map exactly to OpenGL screen coords. This flips the image, and it might make it incompatible with the texture coordinate conventions of an imported model.
- Parameters:
-
[in] ul true if the origin is in the upper left (D3D/DDS) or bottom-left (GL)
The documentation for this class was generated from the following file: