OGRE-Next: Ogre::PixelFormatGpuUtils Class Reference

| OGRE-Next 3.0.0 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
Ogre::PixelFormatGpuUtils Class Reference
Core » Image

The pixel format used for images, textures, and render surfaces. More...

`#include <OgrePixelFormatGpuUtils.h>`

## Public Types
enum | PixelFormatFlags { PFF_FLOAT = 1u << 0u , PFF_HALF = 1u << 1u , PFF_FLOAT_RARE = 1u << 2u , PFF_INTEGER = 1u << 3u , PFF_NORMALIZED = 1u << 4u , PFF_SIGNED = 1u << 5u , PFF_DEPTH = 1u << 6u , PFF_STENCIL = 1u << 7u , PFF_SRGB = 1u << 8u , PFF_COMPRESSED = 1u << 9u , PFF_PALLETE = 1u << 10u }
enum | PixelFormatLayout { PFL_OTHER = 0 , PFL_RGBA32 , PFL_RGB32 , PFL_RG32 , PFL_R32 , PFL_RGBA16 , PFL_RGB16 , PFL_RG16 , PFL_R16 , PFL_RGBA8 , PFL_BGRA8 , PFL_BGRX8 , PFL_RGB8 , PFL_BGR8 , PFL_RG8 , PFL_R8 , PFL_COUNT }
| Pixel components size and order, typeless. More...

## Static Public Member Functions
static void * | advancePointerToMip (void *basePtr, uint32 width, uint32 height, uint32 depth, uint32 numSlices, uint8 mipLevel, PixelFormatGpu format)
| Takes an image allocated for GPU usage (i.e.
static void | bulkPixelConversion (const TextureBox &src, PixelFormatGpu srcFormat, TextureBox &dst, PixelFormatGpu dstFormat, bool verticalFlip=false)
static size_t | calculateSizeBytes (uint32 width, uint32 height, uint32 depth, uint32 slices, PixelFormatGpu format, uint8 numMipmaps, uint32 rowAlignment=1u)
static void | convertForNormalMapping (TextureBox src, PixelFormatGpu srcFormat, TextureBox dst, PixelFormatGpu dstFormat)
static float | fromSRGB (float x)
static uint32 | getBytesPerPixel (PixelFormatGpu format)
static uint32 | getCompressedBlockHeight (PixelFormatGpu format, bool apiStrict=true)
| See getCompressedBlockWidth.
static size_t | getCompressedBlockSize (PixelFormatGpu format)
| Returns in bytes, the size of the compressed block.
static uint32 | getCompressedBlockWidth (PixelFormatGpu format, bool apiStrict=true)
| Returns the minimum width for block compressed schemes.
static PixelFormatGpu | getEquivalentLinear (PixelFormatGpu sRgbFormat)
static PixelFormatGpu | getEquivalentSRGB (PixelFormatGpu format)
static PixelFormatGpu | getFamily (PixelFormatGpu format)
static uint32 | getFlags (PixelFormatGpu format)
| See PixelFormatFlags.
static PixelFormatGpu | getFormatFromName (const char *name, uint32 exclusionFlags=0)
| Makes a O(N) search to return the PixelFormatGpu based on its string version.
static PixelFormatGpu | getFormatFromName (const String &name, uint32 exclusionFlags=0)
static uint8 | getMaxMipmapCount (uint32 maxResolution)
| Returns the maximum number of mipmaps given the resolution e.g.
static uint8 | getMaxMipmapCount (uint32 width, uint32 height)
static uint8 | getMaxMipmapCount (uint32 width, uint32 height, uint32 depth)
static uint32 | getNumberOfComponents (PixelFormatGpu format)
static PixelFormatLayout | getPixelLayout (PixelFormatGpu format)
static size_t | getSizeBytes (uint32 width, uint32 height, uint32 depth, uint32 slices, PixelFormatGpu format, uint32 rowAlignment=1u)
static bool | hasAlpha (PixelFormatGpu format)
static bool | hasSRGBEquivalent (PixelFormatGpu format)
static bool | isAccessible (PixelFormatGpu format)
static bool | isCompressed (PixelFormatGpu format)
static bool | isDepth (PixelFormatGpu format)
static bool | isFloat (PixelFormatGpu format)
static bool | isFloatRare (PixelFormatGpu format)
static bool | isHalf (PixelFormatGpu format)
static bool | isInteger (PixelFormatGpu format)
static bool | isNormalized (PixelFormatGpu format)
static bool | isPallete (PixelFormatGpu format)
static bool | isSigned (PixelFormatGpu format)
static bool | isSRgb (PixelFormatGpu format)
static bool | isStencil (PixelFormatGpu format)
static void | packColour (const ColourValue &rgbaPtr, PixelFormatGpu pf, void *dstPtr)
static void | packColour (const float *rgbaPtr, PixelFormatGpu pf, void *dstPtr)
static bool | supportsHwMipmaps (PixelFormatGpu format)
| For SW mipmaps, see Image2::supportsSwMipmaps.
static float | toSRGB (float x)
static const char * | toString (PixelFormatGpu format)
static void | unpackColour (ColourValue *rgbaPtr, PixelFormatGpu pf, const void *srcPtr)
static void | unpackColour (float *rgbaPtr, PixelFormatGpu pf, const void *srcPtr)

## Detailed Description

The pixel format used for images, textures, and render surfaces.

## Member Enumeration Documentation

## ◆ PixelFormatFlags

enum Ogre::PixelFormatGpuUtils::PixelFormatFlags

Enumerator
PFF_FLOAT | Pixel Format is an actual float (32-bit float).
PFF_HALF | Pixel Format is 16-bit float.
PFF_FLOAT_RARE | Pixel Format is float, but is neither 32-bit nor 16-bit (some weird one, could have shared exponent or not).
PFF_INTEGER | Pixel Format is (signed/unsigned) integer. May be normalized if PFF_NORMALIZED is present.
PFF_NORMALIZED | Pixel Format is either in range [-1; 1] or [0; 1].
PFF_SIGNED | Pixel Format can only be positive or negative. It's implicit for float/half formats. Lack of this flag means it's unsigned.
PFF_DEPTH | This is a depth format. Can be combined with PFF_FLOAT/PFF_HALF/PFF_INTEGER/PFF_NORMALIZED to get more info about the depth.
PFF_STENCIL | This format has stencil.
PFF_SRGB | Format is in sRGB space.
PFF_COMPRESSED | Format is compressed.
PFF_PALLETE | Format is palletized.

## ◆ PixelFormatLayout

enum Ogre::PixelFormatGpuUtils::PixelFormatLayout

Pixel components size and order, typeless.

Enumerator
PFL_OTHER |
PFL_RGBA32 |
PFL_RGB32 |
PFL_RG32 |
PFL_R32 |
PFL_RGBA16 |
PFL_RGB16 |
PFL_RG16 |
PFL_R16 |
PFL_RGBA8 |
PFL_BGRA8 |
PFL_BGRX8 |
PFL_RGB8 |
PFL_BGR8 |
PFL_RG8 |
PFL_R8 |
PFL_COUNT |

## Member Function Documentation

## ◆ advancePointerToMip()

void * Ogre::PixelFormatGpuUtils::advancePointerToMip | ( | void * | basePtr,
|  | uint32 | width,
|  | uint32 | height,
|  | uint32 | depth,
|  | uint32 | numSlices,
|  | uint8 | mipLevel,
|  | PixelFormatGpu | format )
| static

Takes an image allocated for GPU usage (i.e.

rowAlignment = 4u) from the beginning of its base mip level 0, and returns a pointer at the beginning of the specified mipLevel.

## ◆ bulkPixelConversion()

void Ogre::PixelFormatGpuUtils::bulkPixelConversion | ( | const TextureBox & | src,
|  | PixelFormatGpu | srcFormat,
|  | TextureBox & | dst,
|  | PixelFormatGpu | dstFormat,
|  | bool | verticalFlip = false )
| static

## ◆ calculateSizeBytes()

size_t Ogre::PixelFormatGpuUtils::calculateSizeBytes | ( | uint32 | width,
|  | uint32 | height,
|  | uint32 | depth,
|  | uint32 | slices,
|  | PixelFormatGpu | format,
|  | uint8 | numMipmaps,
|  | uint32 | rowAlignment = 1u )
| static

## ◆ convertForNormalMapping()

void Ogre::PixelFormatGpuUtils::convertForNormalMapping | ( | TextureBox | src,
|  | PixelFormatGpu | srcFormat,
|  | TextureBox | dst,
|  | PixelFormatGpu | dstFormat )
| static

## ◆ fromSRGB()

float Ogre::PixelFormatGpuUtils::fromSRGB | ( | float | x | ) |
| static

## ◆ getBytesPerPixel()

uint32 Ogre::PixelFormatGpuUtils::getBytesPerPixel | ( | PixelFormatGpu | format | ) |
| static

## ◆ getCompressedBlockHeight()

uint32 Ogre::PixelFormatGpuUtils::getCompressedBlockHeight | ( | PixelFormatGpu | format,
|  | bool | apiStrict = true )
| static

See getCompressedBlockWidth.

Referenced by Ogre::TextureBox::at(), Ogre::TextureBox::copyFrom(), and Ogre::TextureBox::isSubtextureRegion().

## ◆ getCompressedBlockSize()

size_t Ogre::PixelFormatGpuUtils::getCompressedBlockSize | ( | PixelFormatGpu | format | ) |
| static

Returns in bytes, the size of the compressed block.

Referenced by Ogre::TextureBox::at(), Ogre::TextureBox::copyFrom(), and Ogre::TextureBox::isSubtextureRegion().

## ◆ getCompressedBlockWidth()

uint32 Ogre::PixelFormatGpuUtils::getCompressedBlockWidth | ( | PixelFormatGpu | format,
|  | bool | apiStrict = true )
| static

Returns the minimum width for block compressed schemes.

ie. DXT1 compresses in blocks of 4x4 pixels. A texture with a width of 2 is just padded to 4. When building UV atlases composed of already compressed data being stitched together, the block size is very important to know as the resolution of the individual textures must be a multiple of this size.

Remarks
  If the format is not compressed, returns 1.

  The function can return a value of 0 (as happens with PVRTC & ETC1 compression); this is because although they may compress in blocks (i.e. PVRTC uses a 4x4 or 8x4 block), this information is useless as the compression scheme doesn't have isolated blocks (modifying a single pixel can change the binary data of the entire stream) making it useless for subimage sampling or creating UV atlas.

Parameters

  format | The format to query for. Can be compressed or not.
  apiStrict | When true, obeys the rules of most APIs (i.e. ETC1 can't update subregions according to GLES specs). When false, becomes more practical if manipulating by hand (i.e. ETC1's subregions can be updated just fine by bulkCompressedSubregion())

Returns
  The width of compression block, in pixels. Can be 0 (see remarks). If format is not compressed, returns 1.

Referenced by Ogre::TextureBox::at(), Ogre::TextureBox::copyFrom(), and Ogre::TextureBox::isSubtextureRegion().

## ◆ getEquivalentLinear()

PixelFormatGpu Ogre::PixelFormatGpuUtils::getEquivalentLinear | ( | PixelFormatGpu | sRgbFormat | ) |
| static

## ◆ getEquivalentSRGB()

PixelFormatGpu Ogre::PixelFormatGpuUtils::getEquivalentSRGB | ( | PixelFormatGpu | format | ) |
| static

## ◆ getFamily()

PixelFormatGpu Ogre::PixelFormatGpuUtils::getFamily | ( | PixelFormatGpu | format | ) |
| static

## ◆ getFlags()

uint32 Ogre::PixelFormatGpuUtils::getFlags | ( | PixelFormatGpu | format | ) |
| static

See PixelFormatFlags.

## ◆ getFormatFromName() [1/2]

PixelFormatGpu Ogre::PixelFormatGpuUtils::getFormatFromName | ( | const char * | name,
|  | uint32 | exclusionFlags = 0 )
| static

Makes a O(N) search to return the PixelFormatGpu based on its string version.

Opposite version of toString

Parameters

  name | Name of the pixel format. e.g. PFG_RGBA8_UNORM_SRGB
  exclusionFlags | Use PixelFormatFlags to exclude certain formats. For example if you don't want compressed and depth formats to be returned, pass PFF_COMPRESSED|PFF_DEPTH

Returns
  The format you're looking for, PFG_UNKNOWN if not found.

## ◆ getFormatFromName() [2/2]

PixelFormatGpu Ogre::PixelFormatGpuUtils::getFormatFromName | ( | const String & | name,
|  | uint32 | exclusionFlags = 0 )
| static

## ◆ getMaxMipmapCount() [1/3]

uint8 Ogre::PixelFormatGpuUtils::getMaxMipmapCount | ( | uint32 | maxResolution | ) |
| static

Returns the maximum number of mipmaps given the resolution e.g.

at 4x4 there's 3 mipmaps. At 1x1 there's 1 mipmaps.

Note
  Can return 0 if maxResolution = 0.

Returns
  Mip count.

## ◆ getMaxMipmapCount() [2/3]

uint8 Ogre::PixelFormatGpuUtils::getMaxMipmapCount | ( | uint32 | width,
|  | uint32 | height )
| static

## ◆ getMaxMipmapCount() [3/3]

uint8 Ogre::PixelFormatGpuUtils::getMaxMipmapCount | ( | uint32 | width,
|  | uint32 | height,
|  | uint32 | depth )
| static

## ◆ getNumberOfComponents()

uint32 Ogre::PixelFormatGpuUtils::getNumberOfComponents | ( | PixelFormatGpu | format | ) |
| static

## ◆ getPixelLayout()

PixelFormatLayout Ogre::PixelFormatGpuUtils::getPixelLayout | ( | PixelFormatGpu | format | ) |
| static

## ◆ getSizeBytes()

size_t Ogre::PixelFormatGpuUtils::getSizeBytes | ( | uint32 | width,
|  | uint32 | height,
|  | uint32 | depth,
|  | uint32 | slices,
|  | PixelFormatGpu | format,
|  | uint32 | rowAlignment = 1u )
| static

## ◆ hasAlpha()

bool Ogre::PixelFormatGpuUtils::hasAlpha | ( | PixelFormatGpu | format | ) |
| static

## ◆ hasSRGBEquivalent()

bool Ogre::PixelFormatGpuUtils::hasSRGBEquivalent | ( | PixelFormatGpu | format | ) |
| static

## ◆ isAccessible()

bool Ogre::PixelFormatGpuUtils::isAccessible | ( | PixelFormatGpu | format | ) |
| static

## ◆ isCompressed()

bool Ogre::PixelFormatGpuUtils::isCompressed | ( | PixelFormatGpu | format | ) |
| static

Referenced by Ogre::TextureBox::setCompressedPixelFormat().

## ◆ isDepth()

bool Ogre::PixelFormatGpuUtils::isDepth | ( | PixelFormatGpu | format | ) |
| static

## ◆ isFloat()

bool Ogre::PixelFormatGpuUtils::isFloat | ( | PixelFormatGpu | format | ) |
| static

## ◆ isFloatRare()

bool Ogre::PixelFormatGpuUtils::isFloatRare | ( | PixelFormatGpu | format | ) |
| static

## ◆ isHalf()

bool Ogre::PixelFormatGpuUtils::isHalf | ( | PixelFormatGpu | format | ) |
| static

## ◆ isInteger()

bool Ogre::PixelFormatGpuUtils::isInteger | ( | PixelFormatGpu | format | ) |
| static

## ◆ isNormalized()

bool Ogre::PixelFormatGpuUtils::isNormalized | ( | PixelFormatGpu | format | ) |
| static

## ◆ isPallete()

bool Ogre::PixelFormatGpuUtils::isPallete | ( | PixelFormatGpu | format | ) |
| static

## ◆ isSigned()

bool Ogre::PixelFormatGpuUtils::isSigned | ( | PixelFormatGpu | format | ) |
| static

## ◆ isSRgb()

bool Ogre::PixelFormatGpuUtils::isSRgb | ( | PixelFormatGpu | format | ) |
| static

## ◆ isStencil()

bool Ogre::PixelFormatGpuUtils::isStencil | ( | PixelFormatGpu | format | ) |
| static

## ◆ packColour() [1/2]

void Ogre::PixelFormatGpuUtils::packColour | ( | const ColourValue & | rgbaPtr,
|  | PixelFormatGpu | pf,
|  | void * | dstPtr )
| static

## ◆ packColour() [2/2]

void Ogre::PixelFormatGpuUtils::packColour | ( | const float * | rgbaPtr,
|  | PixelFormatGpu | pf,
|  | void * | dstPtr )
| static

## ◆ supportsHwMipmaps()

bool Ogre::PixelFormatGpuUtils::supportsHwMipmaps | ( | PixelFormatGpu | format | ) |
| static

For SW mipmaps, see Image2::supportsSwMipmaps.

## ◆ toSRGB()

float Ogre::PixelFormatGpuUtils::toSRGB | ( | float | x | ) |
| static

## ◆ toString()

const char * Ogre::PixelFormatGpuUtils::toString | ( | PixelFormatGpu | format | ) |
| static

## ◆ unpackColour() [1/2]

void Ogre::PixelFormatGpuUtils::unpackColour | ( | ColourValue * | rgbaPtr,
|  | PixelFormatGpu | pf,
|  | const void * | srcPtr )
| static

## ◆ unpackColour() [2/2]

void Ogre::PixelFormatGpuUtils::unpackColour | ( | float * | rgbaPtr,
|  | PixelFormatGpu | pf,
|  | const void * | srcPtr )
| static

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

- OgrePixelFormatGpuUtils.h