Resources

Description

Core resource types and resource management functionality (loading, saving, etc.).

Classes

struct  MESH_DESC
 Descriptor object used for creation of a new Mesh object. More...
 
class  Mesh
 Primary class for holding geometry. More...
 
class  MeshProperties
 Properties of a Mesh. More...
 
class  VertexElemIter< T >
 Iterator that allows you to easily populate or read vertex elements in MeshData. More...
 
struct  BoneWeight
 Contains per-vertex bone weights and indexes used for skinning, for up to four bones. More...
 
class  MeshData
 Contains mesh vertex and index data used for initializing, updating and reading mesh data from Mesh. More...
 
class  MeshHeap
 Mesh heap allows you to quickly allocate and deallocate a large amounts of temporary meshes without the large overhead of normal Mesh creation. More...
 
class  PixelData
 A buffer describing a volume (3D), image (2D) or line (1D) of pixels in memory. More...
 
class  Resource
 Base class for all resources. More...
 
class  ResourceMetaData
 Class containing meta-information describing a resource. More...
 
class  Resources
 Manager for dealing with all engine resources. More...
 
class  ShaderInclude
 Raw text resource that serves as an include file for shaders. More...
 
struct  TEXTURE_DESC
 Descriptor structure used for initialization of a Texture. More...
 
class  TextureProperties
 Properties of a Texture. More...
 
class  Texture
 Abstract class representing a texture. More...
 
class  TransientMesh
 Represents a single mesh entry in the MeshHeap. More...
 
class  VertexDataDesc
 Contains information about layout of vertices in a buffer. More...
 

Typedefs

typedef ResourceHandle< Resource > HResource
 
typedef ResourceHandle< Texture > HTexture
 
typedef ResourceHandle< Mesh > HMesh
 
typedef ResourceHandle< Material > HMaterial
 
typedef ResourceHandle< ShaderInclude > HShaderInclude
 
typedef ResourceHandle< Font > HFont
 
typedef ResourceHandle< Shader > HShader
 
typedef ResourceHandle< Prefab > HPrefab
 
typedef ResourceHandle< StringTable > HStringTable
 
typedef ResourceHandle< PhysicsMaterial > HPhysicsMaterial
 
typedef ResourceHandle< PhysicsMesh > HPhysicsMesh
 
typedef ResourceHandle< AudioClip > HAudioClip
 
typedef ResourceHandle< AnimationClip > HAnimationClip
 
template<typename T >
using ResourceHandle = TResourceHandle< T, false >
 Represents a handle to a resource. More...
 
template<typename T >
using WeakResourceHandle = TResourceHandle< T, true >
 Represents a handle to a resource. More...
 
typedef Flags< ResourceLoadFlag > ResourceLoadFlags
 

Enumerations

enum  MeshUsage { MU_STATIC, MU_DYNAMIC, MU_CPUCACHED = 0x1000 }
 Planned usage for the mesh. More...
 
enum  PixelFormat {
  PF_UNKNOWN = 0, PF_R8 = 1, PF_R8G8 = 2, PF_R8G8B8 = 3,
  PF_B8G8R8 = 4, PF_B8G8R8A8 = 7, PF_R8G8B8A8 = 8, PF_BC1 = 13,
  PF_BC1a = 14, PF_BC2 = 15, PF_BC3 = 16, PF_BC4 = 17,
  PF_BC5 = 18, PF_BC6H = 19, PF_BC7 = 20, PF_FLOAT16_R = 21,
  PF_FLOAT16_RG = 22, PF_FLOAT16_RGB = 23, PF_FLOAT16_RGBA = 24, PF_FLOAT32_R = 25,
  PF_FLOAT32_RG = 26, PF_FLOAT32_RGB = 27, PF_FLOAT32_RGBA = 28, PF_D32_S8X24 = 29,
  PF_D24S8 = 30, PF_D32 = 31, PF_D16 = 32, PF_FLOAT_R11G11B10 = 33,
  PF_UNORM_R10G10B10A2 = 34, PF_COUNT = 35
}
 Pixel formats usable by images, textures and render surfaces. More...
 
enum  PixelFormatFlags {
  PFF_HASALPHA = 0x00000001, PFF_COMPRESSED = 0x00000002, PFF_FLOAT = 0x00000004, PFF_DEPTH = 0x00000008,
  PFF_NATIVEENDIAN = 0x00000010
}
 Flags defining some properties of pixel formats. More...
 
enum  PixelComponentType {
  PCT_BYTE = 0, PCT_SHORT = 1, PCT_FLOAT16 = 2, PCT_FLOAT32 = 3,
  PCT_PACKED_R11G11B10 = 4, PCT_PACKED_R10G10B10A2 = 5, PCT_COUNT = 4
}
 Types used for individual components of a pixel. More...
 
enum  TextureFilter { TF_NEAREST, TF_BILINEAR }
 Determines how are texture pixels filtered during sampling. More...
 
enum  CubemapFace {
  CF_PositiveX, CF_NegativeX, CF_PositiveY, CF_NegativeY,
  CF_PositiveZ, CF_NegativeZ
}
 A list of cubemap faces. More...
 
enum  ResourceLoadFlag {
  None = 0, LoadDependencies = 1 << 0, KeepInternalRef = 1 << 1, KeepSourceData = 1 << 2,
  Default = LoadDependencies | KeepInternalRef
}
 Flags that can be used to control resource loading. More...
 
enum  TextureUsage {
  TU_STATIC = GBU_STATIC, TU_DYNAMIC = GBU_DYNAMIC, TU_RENDERTARGET = 0x200, TU_DEPTHSTENCIL = 0x400,
  TU_LOADSTORE = 0x800, TU_CPUCACHED = 0x1000, TU_CPUREADABLE = 0x2000, TU_DEFAULT = TU_STATIC
}
 Flags that describe how is a texture used. More...
 
enum  TextureMipmap { MIP_UNLIMITED = 0x7FFFFFFF }
 Texture mipmap options. More...
 

Functions

template<class _Ty1 , class _Ty2 , bool Weak>
TResourceHandle< _Ty1, Weak > static_resource_cast (const TResourceHandle< _Ty2, Weak > &other)
 Casts one resource handle to another. More...
 
 BS_FLAGS_OPERATORS (ResourceLoadFlag)
 
BS_CORE_EXPORT Resources & gResources ()
 Provides easier access to Resources manager. More...
 

Typedef Documentation

using ResourceHandle = TResourceHandle<T, false>

Represents a handle to a resource.

Handles are similar to a smart pointers, but they have two advantages:

  • When loading a resource asynchronously you can be immediately returned the handle that you may use throughout the engine. The handle will be made valid as soon as the resource is loaded.
  • Handles can be serialized and deserialized, therefore saving/restoring references to their original resource.
using WeakResourceHandle = TResourceHandle<T, true>

Represents a handle to a resource.

Handles are similar to a smart pointers, but they have two advantages:

  • When loading a resource asynchronously you can be immediately returned the handle that you may use throughout the engine. The handle will be made valid as soon as the resource is loaded.
  • Handles can be serialized and deserialized, therefore saving/restoring references to their original resource.

Weak handles don't prevent the resource from being unloaded.

Enumeration Type Documentation

enum CubemapFace

A list of cubemap faces.

enum MeshUsage

Planned usage for the mesh.

These options usually affect performance and you should specify static if you don't plan on modifying the mesh often, otherwise specify dynamic.

Enumerator
MU_STATIC 

Specify for a mesh that is not often updated from the CPU.

MU_DYNAMIC 

Specify for a mesh that is often updated from the CPU.

MU_CPUCACHED 

All mesh data will also be cached in CPU memory, making it available for fast read access from the CPU.

enum PixelComponentType

Types used for individual components of a pixel.

Enumerator
PCT_BYTE 

Byte per component.

PCT_SHORT 

Short per component.

PCT_FLOAT16 

16 bit float per component

PCT_FLOAT32 

32 bit float per component

PCT_PACKED_R11G11B10 

11 bits for first two components, 10 for third component.

PCT_PACKED_R10G10B10A2 

10 bits for first three components, 2 bits for last component

PCT_COUNT 

Number of pixel types.

enum PixelFormat

Pixel formats usable by images, textures and render surfaces.

Enumerator
PF_UNKNOWN 

Unknown pixel format.

PF_R8 

8-bit pixel format, all bits red.

PF_R8G8 

2 byte pixel format, 1 byte red, 1 byte green.

PF_R8G8B8 

24-bit pixel format, 8 bits for red, green and blue.

PF_B8G8R8 

24-bit pixel format, 8 bits for blue, green and red.

PF_B8G8R8A8 

32-bit pixel format, 8 bits for blue, green, red and alpha.

PF_R8G8B8A8 

32-bit pixel format, 8 bits for red, green, blue and alpha.

PF_BC1 

DXT1/BC1 format containing opaque RGB or 1-bit alpha RGB.

4 bits per pixel.

PF_BC1a 

DXT3/BC2 format containing RGB with premultiplied alpha.

4 bits per pixel.

PF_BC2 

DXT3/BC2 format containing RGB with explicit alpha.

8 bits per pixel.

PF_BC3 

DXT5/BC2 format containing RGB with explicit alpha.

8 bits per pixel. Better alpha gradients than BC2.

PF_BC4 

One channel compressed format.

4 bits per pixel.

PF_BC5 

Two channel compressed format.

8 bits per pixel.

PF_BC6H 

Format storing RGB in half (16-bit) floating point format usable for HDR.

8 bits per pixel.

PF_BC7 

Format storing RGB with optional alpha channel.

Similar to BC1/BC2/BC3 formats but with higher quality and higher decompress overhead. 8 bits per pixel.

PF_FLOAT16_R 

16-bit pixel format, 16 bits (float) for red.

PF_FLOAT16_RG 

32-bit, 2-channel s10e5 floating point pixel format, 16-bit red, 16-bit green.

PF_FLOAT16_RGB 

48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue.

PF_FLOAT16_RGBA 

64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue, 16 bits (float) for alpha.

PF_FLOAT32_R 

32-bit pixel format, 32 bits (float) for red.

PF_FLOAT32_RG 

64-bit, 2-channel floating point pixel format, 32-bit red, 32-bit green.

PF_FLOAT32_RGB 

96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue.

PF_FLOAT32_RGBA 

128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 32 bits (float) for alpha.

PF_D32_S8X24 

Depth stencil format, 32bit depth, 8bit stencil + 24 unused.

PF_D24S8 

Depth stencil fomrat, 24bit depth + 8bit stencil.

PF_D32 

Depth format, 32bits.

PF_D16 

Depth format, 16bits.

PF_FLOAT_R11G11B10 

32-bit float format, 11 bits (float) for red, 11 bits (float) for green, 10 bits (float) for blue.

Framebuffer only format, not for CPU use.

PF_UNORM_R10G10B10A2 

32-bit unsigned normalized format, 10 bits (float) for red, 10 bits (float) for green, 10 bits (float) for blue, and two bits for alpha.

Framebuffer only format, not for CPU use.

PF_COUNT 

Number of pixel formats currently defined.

enum PixelFormatFlags

Flags defining some properties of pixel formats.

Enumerator
PFF_HASALPHA 

This format has an alpha channel.

PFF_COMPRESSED 

This format is compressed.

This invalidates the values in elemBytes, elemBits and the bit counts as these might not be fixed in a compressed format.

PFF_FLOAT 

This is a floating point format.

PFF_DEPTH 

This is a depth format (for depth textures).

PFF_NATIVEENDIAN 

Format is in native endian.

Generally true for the 16, 24 and 32 bits formats which can be represented as machine integers.

enum ResourceLoadFlag
strong

Flags that can be used to control resource loading.

Enumerator
None 

No flags.

LoadDependencies 

If enabled all resources referenced by the root resource will be loaded as well.

KeepInternalRef 

If enabled the resource system will keep an internal reference to the resource so it doesn't get destroyed when it goes out of scope.

You can call Resources::release() to release the internal reference. Each call to load will create a new internal reference and therefore must be followed by the same number of release calls. If dependencies are being loaded, they will not have internal references created regardless of this parameter.

KeepSourceData 

Determines if the loaded resource keeps original data loaded.

Sometime resources will process loaded data and discard the original (e.g. uncompressing audio on load). This flag can prevent the resource from discarding the original data. The original data might be required for saving the resource (via Resources::save), but will use up extra memory. Normally you want to keep this enabled if you plan on saving the resource to disk.

Default 

Default set of flags used for resource loading.

enum TextureFilter

Determines how are texture pixels filtered during sampling.

Enumerator
TF_NEAREST 

Pixel nearest to the sampled location is chosen.

TF_BILINEAR 

Four pixels nearest to the sampled location are interpolated to yield the sampled color.

enum TextureMipmap

Texture mipmap options.

Enumerator
MIP_UNLIMITED 

Create all mip maps down to 1x1.

enum TextureUsage

Flags that describe how is a texture used.

Enumerator
TU_STATIC 

A regular texture that is not often or ever updated from the CPU.

TU_DYNAMIC 

A regular texture that is often updated by the CPU.

TU_RENDERTARGET 

Texture that can be rendered to by the GPU.

TU_DEPTHSTENCIL 

Texture used as a depth/stencil buffer by the GPU.

TU_LOADSTORE 

Texture that allows load/store operations from the GPU program.

TU_CPUCACHED 

All mesh data will also be cached in CPU memory, making it available for fast read access from the CPU.

TU_CPUREADABLE 

Allows the CPU to directly read the texture data buffers from the GPU.

TU_DEFAULT 

Default (most common) texture usage.

Function Documentation

BS_CORE_EXPORT Resources& bs::gResources ( )

Provides easier access to Resources manager.

TResourceHandle<_Ty1, Weak> bs::static_resource_cast ( const TResourceHandle< _Ty2, Weak > &  other)

Casts one resource handle to another.