6#ifndef BGFX_UTILS_H_HEADER_GUARD
7#define BGFX_UTILS_H_HEADER_GUARD
11#include <bimg/encode.h>
12#include <bimg/decode.h>
15#include <bx/pixelformat.h>
18#include <tinystl/allocator.h>
19#include <tinystl/vector.h>
20namespace stl = tinystl;
22bool saveToFile(bgfx::ViewId viewId,
const char* _filePath, bgfx::FrameBufferHandle fbo, uint32_t width, uint32_t height);
24void*
load(
const char* _filePath, uint32_t* _size = NULL);
30bgfx::ShaderHandle
loadShader(
const char* _name);
33bgfx::ProgramHandle
loadProgram(
const char* _vsName,
const char* _fsName);
37 uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
39 bgfx::TextureInfo* _info = NULL,
40 bimg::Orientation::Enum* _orientation = NULL);
43bimg::ImageContainer*
imageLoad(
const void* data, uint32_t
size, bgfx::TextureFormat::Enum _dstFormat = bgfx::TextureFormat::Count);
44bimg::ImageContainer*
imageLoad(
const char* _filePath, bgfx::TextureFormat::Enum _dstFormat = bgfx::TextureFormat::Count);
45bool imageSave(
const char* saveAs, bimg::ImageContainer* image);
49 uint16_t _numVertices,
50 bgfx::VertexLayout _layout,
51 const uint16_t* _indices,
52 uint32_t _numIndices);
63 return _numVertices == bgfx::getAvailTransientVertexBuffer(_numVertices, _layout) &&
64 (0 == _numIndices || _numIndices == bgfx::getAvailTransientIndexBuffer(_numIndices));
68inline uint32_t
encodeNormalRgba8(
float _x,
float _y = 0.0f,
float _z = 0.0f,
float _w = 0.0f)
77 bx::packRgba8(&dst, src);
uint32_t encodeNormalRgba8(float _x, float _y=0.0f, float _z=0.0f, float _w=0.0f)
bimg::ImageContainer * imageLoad(const void *data, uint32_t size, bgfx::TextureFormat::Enum _dstFormat=bgfx::TextureFormat::Count)
void calcTangents(void *_vertices, uint16_t _numVertices, bgfx::VertexLayout _layout, const uint16_t *_indices, uint32_t _numIndices)
bool imageSave(const char *saveAs, bimg::ImageContainer *image)
bgfx::TextureHandle loadTexture(const char *_name, uint64_t _flags=BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE, uint8_t _skip=0, bgfx::TextureInfo *_info=NULL, bimg::Orientation::Enum *_orientation=NULL)
void * load(const char *_filePath, uint32_t *_size=NULL)
bgfx::ProgramHandle loadProgram(const char *_vsName, const char *_fsName)
bool saveToFile(bgfx::ViewId viewId, const char *_filePath, bgfx::FrameBufferHandle fbo, uint32_t width, uint32_t height)
bgfx::ShaderHandle loadShader(const char *_name)
bool checkAvailTransientBuffers(uint32_t _numVertices, const bgfx::VertexLayout &_layout, uint32_t _numIndices)