Unravel Engine C++ Reference
Loading...
Searching...
No Matches
bgfx_utils.cpp File Reference
#include "common.h"
#include <tinystl/allocator.h>
#include <tinystl/string.h>
#include <tinystl/vector.h>
#include "entry/entry.h"
#include <bgfx/bgfx.h>
#include <bx/commandline.h>
#include <bx/endian.h>
#include <bx/math.h>
#include <bx/readerwriter.h>
#include <bx/string.h>
#include "bgfx_utils.h"
#include <bimg/bimg.h>
#include <bimg/decode.h>
#include <bx/bx.h>
#include <bx/file.h>
#include <bx/sort.h>
#include <time.h>

Go to the source code of this file.

Namespaces

namespace  entry
 

Functions

void * load (bx::FileReaderI *_reader, bx::AllocatorI *_allocator, const bx::FilePath &_filePath, uint32_t *_size)
 
void * load (const bx::FilePath &_filePath, uint32_t *_size)
 
void unload (void *_ptr)
 
static const bgfx::Memory * loadMem (bx::FileReaderI *_reader, const char *_filePath)
 
static void * loadMem (bx::FileReaderI *_reader, bx::AllocatorI *_allocator, const bx::FilePath &_filePath, uint32_t *_size)
 
static bgfx::ShaderHandle loadShader (bx::FileReaderI *_reader, const bx::StringView &_name)
 
bgfx::ShaderHandle loadShader (const bx::StringView &_name)
 
bgfx::ShaderHandle loadShader (const bx::FilePath &_filePath)
 
bgfx::ProgramHandle loadProgram (bx::FileReaderI *_reader, const bx::StringView &_vsName, const bx::StringView &_fsName)
 
bgfx::ProgramHandle loadProgram (const bx::StringView &_vsName, const bx::StringView &_fsName)
 
static void imageReleaseCb (void *_ptr, void *_userData)
 
static bgfx::TextureHandle loadTextureFromContainer (bimg::ImageContainer *imageContainer, uint64_t _flags, bgfx::TextureInfo *_info, const TexturePreCreateFn &_preCreate=nullptr)
 
bool imageFlipTangentSpaceNormalY (bimg::ImageContainer *&_image)
 
bool imagePrepareNormalMapBakePng (bimg::ImageContainer *&_image)
 Prepare a flipped normal map for PNG bake export (RGBA8, opaque alpha when unused).
 
bgfx::TextureHandle loadTexture (const void *_data, uint32_t _size, uint64_t _flags, uint8_t _skip, bgfx::TextureInfo *_info, bimg::Orientation::Enum *_orientation, const char *_name, bx::Error *_err, const TexturePreCreateFn &_preCreate)
 
bgfx::TextureHandle loadTexture (bx::FileReaderI *_reader, const bx::FilePath &_filePath, uint64_t _flags, uint8_t _skip, bgfx::TextureInfo *_info, bimg::Orientation::Enum *_orientation, bx::Error *_err, const TexturePreCreateFn &_preCreate=nullptr)
 
bgfx::TextureHandle loadTexture (const bx::FilePath &_filePath, uint64_t _flags, uint8_t _skip, bgfx::TextureInfo *_info, bimg::Orientation::Enum *_orientation, bx::Error *_err, const TexturePreCreateFn &_preCreate)
 
bimg::ImageContainer * imageLoad (const void *data, uint32_t size, bgfx::TextureFormat::Enum _dstFormat)
 
bimg::ImageContainer * imageLoad (const bx::FilePath &_filePath, bgfx::TextureFormat::Enum _dstFormat)
 
bool imageParseInfo (const void *_data, uint32_t _size, bimg::ImageContainer &_info, bx::Error *_err)
 
bool imageParseInfo (const bx::FilePath &_filePath, bimg::ImageContainer &_info, bx::Error *_err)
 Parse image metadata without decoding pixel data.
 
void calcTangents (void *_vertices, uint16_t _numVertices, bgfx::VertexLayout _layout, const uint16_t *_indices, uint32_t _numIndices)
 
bool saveToFile (bgfx::ViewId viewId, const bx::FilePath &_filePath, bgfx::FrameBufferHandle fbo, uint32_t width, uint32_t height)
 
bool imageSave (const char *saveAs, bimg::ImageContainer *image)
 

Function Documentation

◆ calcTangents()

void calcTangents ( void * _vertices,
uint16_t _numVertices,
bgfx::VertexLayout _layout,
const uint16_t * _indices,
uint32_t _numIndices )

Definition at line 628 of file bgfx_utils.cpp.

◆ imageFlipTangentSpaceNormalY()

bool imageFlipTangentSpaceNormalY ( bimg::ImageContainer *& _image)

Flip tangent-space normal map Y (tangent-space +Y / green channel via bimg unpack/pack). Preserves the container format for uncompressed sources. Compressed inputs are decoded to RGBA8 and left as RGBA8 (no lossy re-encode back to BC).

Definition at line 439 of file bgfx_utils.cpp.

◆ imageLoad() [1/2]

bimg::ImageContainer * imageLoad ( const bx::FilePath & _filePath,
bgfx::TextureFormat::Enum _dstFormat )

Definition at line 588 of file bgfx_utils.cpp.

◆ imageLoad() [2/2]

bimg::ImageContainer * imageLoad ( const void * data,
uint32_t size,
bgfx::TextureFormat::Enum _dstFormat )

Definition at line 583 of file bgfx_utils.cpp.

◆ imageParseInfo() [1/2]

bool imageParseInfo ( const bx::FilePath & _filePath,
bimg::ImageContainer & _info,
bx::Error * _err )

Parse image metadata without decoding pixel data.

Definition at line 613 of file bgfx_utils.cpp.

◆ imageParseInfo() [2/2]

bool imageParseInfo ( const void * _data,
uint32_t _size,
bimg::ImageContainer & _info,
bx::Error * _err )

Definition at line 603 of file bgfx_utils.cpp.

◆ imagePrepareNormalMapBakePng()

bool imagePrepareNormalMapBakePng ( bimg::ImageContainer *& _image)

Prepare a flipped normal map for PNG bake export (RGBA8, opaque alpha when unused).

Definition at line 467 of file bgfx_utils.cpp.

◆ imageReleaseCb()

static void imageReleaseCb ( void * _ptr,
void * _userData )
static

Definition at line 217 of file bgfx_utils.cpp.

◆ imageSave()

bool imageSave ( const char * saveAs,
bimg::ImageContainer * image )

Definition at line 789 of file bgfx_utils.cpp.

◆ load() [1/2]

void * load ( bx::FileReaderI * _reader,
bx::AllocatorI * _allocator,
const bx::FilePath & _filePath,
uint32_t * _size )

Definition at line 76 of file bgfx_utils.cpp.

◆ load() [2/2]

void * load ( const bx::FilePath & _filePath,
uint32_t * _size )

Definition at line 103 of file bgfx_utils.cpp.

◆ loadMem() [1/2]

static void * loadMem ( bx::FileReaderI * _reader,
bx::AllocatorI * _allocator,
const bx::FilePath & _filePath,
uint32_t * _size )
static

Definition at line 130 of file bgfx_utils.cpp.

◆ loadMem() [2/2]

static const bgfx::Memory * loadMem ( bx::FileReaderI * _reader,
const char * _filePath )
static

Definition at line 114 of file bgfx_utils.cpp.

◆ loadProgram() [1/2]

bgfx::ProgramHandle loadProgram ( bx::FileReaderI * _reader,
const bx::StringView & _vsName,
const bx::StringView & _fsName )

Definition at line 199 of file bgfx_utils.cpp.

◆ loadProgram() [2/2]

bgfx::ProgramHandle loadProgram ( const bx::StringView & _vsName,
const bx::StringView & _fsName )

Definition at line 211 of file bgfx_utils.cpp.

◆ loadShader() [1/3]

static bgfx::ShaderHandle loadShader ( bx::FileReaderI * _reader,
const bx::StringView & _name )
static

Definition at line 150 of file bgfx_utils.cpp.

◆ loadShader() [2/3]

bgfx::ShaderHandle loadShader ( const bx::FilePath & _filePath)

Definition at line 191 of file bgfx_utils.cpp.

◆ loadShader() [3/3]

bgfx::ShaderHandle loadShader ( const bx::StringView & _name)

Definition at line 185 of file bgfx_utils.cpp.

◆ loadTexture() [1/3]

bgfx::TextureHandle loadTexture ( bx::FileReaderI * _reader,
const bx::FilePath & _filePath,
uint64_t _flags,
uint8_t _skip,
bgfx::TextureInfo * _info,
bimg::Orientation::Enum * _orientation,
bx::Error * _err,
const TexturePreCreateFn & _preCreate = nullptr )

Definition at line 536 of file bgfx_utils.cpp.

◆ loadTexture() [2/3]

bgfx::TextureHandle loadTexture ( const bx::FilePath & _filePath,
uint64_t _flags,
uint8_t _skip,
bgfx::TextureInfo * _info,
bimg::Orientation::Enum * _orientation,
bx::Error * _err,
const TexturePreCreateFn & _preCreate )

Definition at line 571 of file bgfx_utils.cpp.

◆ loadTexture() [3/3]

bgfx::TextureHandle loadTexture ( const void * _data,
uint32_t _size,
uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE,
uint8_t _skip = 0,
bgfx::TextureInfo * _info = NULL,
bimg::Orientation::Enum * _orientation = NULL,
const char * _name = NULL,
bx::Error * _err = NULL,
const TexturePreCreateFn & _preCreate = nullptr )

Load a texture from memory (DDS, KTX, PNG, etc.). _name is optional debug label. _preCreate is invoked after the image header has been parsed, right before the GPU texture is created.

Definition at line 491 of file bgfx_utils.cpp.

◆ loadTextureFromContainer()

static bgfx::TextureHandle loadTextureFromContainer ( bimg::ImageContainer * imageContainer,
uint64_t _flags,
bgfx::TextureInfo * _info,
const TexturePreCreateFn & _preCreate = nullptr )
static

Definition at line 224 of file bgfx_utils.cpp.

◆ saveToFile()

bool saveToFile ( bgfx::ViewId viewId,
const bx::FilePath & _filePath,
bgfx::FrameBufferHandle fbo,
uint32_t width,
uint32_t height )

Definition at line 729 of file bgfx_utils.cpp.

◆ unload()

void unload ( void * _ptr)

Definition at line 109 of file bgfx_utils.cpp.