Cleanup.
This commit is contained in:
parent
5818e34e21
commit
dc2bb19519
@ -23,7 +23,7 @@ namespace stl = tinystl;
|
||||
|
||||
#include <bimg/decode.h>
|
||||
|
||||
void* load(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const char* _filePath, uint32_t* _size)
|
||||
void* load(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const bx::FilePath& _filePath, uint32_t* _size)
|
||||
{
|
||||
if (bx::open(_reader, _filePath) )
|
||||
{
|
||||
@ -50,7 +50,7 @@ void* load(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const char* _fi
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* load(const char* _filePath, uint32_t* _size)
|
||||
void* load(const bx::FilePath& _filePath, uint32_t* _size)
|
||||
{
|
||||
return load(entry::getFileReader(), entry::getAllocator(), _filePath, _size);
|
||||
}
|
||||
@ -60,7 +60,7 @@ void unload(void* _ptr)
|
||||
bx::free(entry::getAllocator(), _ptr);
|
||||
}
|
||||
|
||||
static const bgfx::Memory* loadMem(bx::FileReaderI* _reader, const char* _filePath)
|
||||
static const bgfx::Memory* loadMem(bx::FileReaderI* _reader, const bx::FilePath& _filePath)
|
||||
{
|
||||
if (bx::open(_reader, _filePath) )
|
||||
{
|
||||
@ -76,7 +76,7 @@ static const bgfx::Memory* loadMem(bx::FileReaderI* _reader, const char* _filePa
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void* loadMem(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const char* _filePath, uint32_t* _size)
|
||||
static void* loadMem(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const bx::FilePath& _filePath, uint32_t* _size)
|
||||
{
|
||||
if (bx::open(_reader, _filePath) )
|
||||
{
|
||||
@ -96,50 +96,50 @@ static void* loadMem(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const char* _name)
|
||||
static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const bx::StringView& _name)
|
||||
{
|
||||
char filePath[512];
|
||||
|
||||
const char* shaderPath = "???";
|
||||
bx::FilePath filePath("shaders/");
|
||||
|
||||
switch (bgfx::getRendererType() )
|
||||
{
|
||||
case bgfx::RendererType::Noop:
|
||||
case bgfx::RendererType::Direct3D11:
|
||||
case bgfx::RendererType::Direct3D12: shaderPath = "shaders/dx11/"; break;
|
||||
case bgfx::RendererType::Direct3D12: filePath.join("dx11"); break;
|
||||
case bgfx::RendererType::Agc:
|
||||
case bgfx::RendererType::Gnm: shaderPath = "shaders/pssl/"; break;
|
||||
case bgfx::RendererType::Metal: shaderPath = "shaders/metal/"; break;
|
||||
case bgfx::RendererType::Nvn: shaderPath = "shaders/nvn/"; break;
|
||||
case bgfx::RendererType::OpenGL: shaderPath = "shaders/glsl/"; break;
|
||||
case bgfx::RendererType::OpenGLES: shaderPath = "shaders/essl/"; break;
|
||||
case bgfx::RendererType::Vulkan: shaderPath = "shaders/spirv/"; break;
|
||||
case bgfx::RendererType::Gnm: filePath.join("pssl"); break;
|
||||
case bgfx::RendererType::Metal: filePath.join("metal"); break;
|
||||
case bgfx::RendererType::Nvn: filePath.join("nvn"); break;
|
||||
case bgfx::RendererType::OpenGL: filePath.join("glsl"); break;
|
||||
case bgfx::RendererType::OpenGLES: filePath.join("essl"); break;
|
||||
case bgfx::RendererType::Vulkan: filePath.join("spirv"); break;
|
||||
|
||||
case bgfx::RendererType::Count:
|
||||
BX_ASSERT(false, "You should not be here!");
|
||||
break;
|
||||
}
|
||||
|
||||
bx::strCopy(filePath, BX_COUNTOF(filePath), shaderPath);
|
||||
bx::strCat(filePath, BX_COUNTOF(filePath), _name);
|
||||
bx::strCat(filePath, BX_COUNTOF(filePath), ".bin");
|
||||
char fileName[512];
|
||||
bx::strCopy(fileName, BX_COUNTOF(fileName), _name);
|
||||
bx::strCat(fileName, BX_COUNTOF(fileName), ".bin");
|
||||
|
||||
bgfx::ShaderHandle handle = bgfx::createShader(loadMem(_reader, filePath) );
|
||||
bgfx::setName(handle, _name);
|
||||
filePath.join(fileName);
|
||||
|
||||
bgfx::ShaderHandle handle = bgfx::createShader(loadMem(_reader, filePath.getCPtr() ) );
|
||||
bgfx::setName(handle, _name.getPtr(), _name.getLength() );
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
bgfx::ShaderHandle loadShader(const char* _name)
|
||||
bgfx::ShaderHandle loadShader(const bx::StringView& _name)
|
||||
{
|
||||
return loadShader(entry::getFileReader(), _name);
|
||||
}
|
||||
|
||||
bgfx::ProgramHandle loadProgram(bx::FileReaderI* _reader, const char* _vsName, const char* _fsName)
|
||||
bgfx::ProgramHandle loadProgram(bx::FileReaderI* _reader, const bx::StringView& _vsName, const bx::StringView& _fsName)
|
||||
{
|
||||
bgfx::ShaderHandle vsh = loadShader(_reader, _vsName);
|
||||
bgfx::ShaderHandle fsh = BGFX_INVALID_HANDLE;
|
||||
if (NULL != _fsName)
|
||||
if (!_fsName.isEmpty() )
|
||||
{
|
||||
fsh = loadShader(_reader, _fsName);
|
||||
}
|
||||
@ -147,7 +147,7 @@ bgfx::ProgramHandle loadProgram(bx::FileReaderI* _reader, const char* _vsName, c
|
||||
return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */);
|
||||
}
|
||||
|
||||
bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName)
|
||||
bgfx::ProgramHandle loadProgram(const bx::StringView& _vsName, const bx::StringView& _fsName)
|
||||
{
|
||||
return loadProgram(entry::getFileReader(), _vsName, _fsName);
|
||||
}
|
||||
@ -159,7 +159,7 @@ static void imageReleaseCb(void* _ptr, void* _userData)
|
||||
bimg::imageFree(imageContainer);
|
||||
}
|
||||
|
||||
bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath, uint64_t _flags, uint8_t _skip, bgfx::TextureInfo* _info, bimg::Orientation::Enum* _orientation)
|
||||
bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const bx::FilePath& _filePath, uint64_t _flags, uint8_t _skip, bgfx::TextureInfo* _info, bimg::Orientation::Enum* _orientation)
|
||||
{
|
||||
BX_UNUSED(_skip);
|
||||
bgfx::TextureHandle handle = BGFX_INVALID_HANDLE;
|
||||
@ -223,7 +223,8 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath,
|
||||
|
||||
if (bgfx::isValid(handle) )
|
||||
{
|
||||
bgfx::setName(handle, _filePath);
|
||||
const bx::StringView name(_filePath);
|
||||
bgfx::setName(handle, name.getPtr(), name.getLength() );
|
||||
}
|
||||
|
||||
if (NULL != _info)
|
||||
@ -245,12 +246,12 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath,
|
||||
return handle;
|
||||
}
|
||||
|
||||
bgfx::TextureHandle loadTexture(const char* _name, uint64_t _flags, uint8_t _skip, bgfx::TextureInfo* _info, bimg::Orientation::Enum* _orientation)
|
||||
bgfx::TextureHandle loadTexture(const bx::FilePath& _filePath, uint64_t _flags, uint8_t _skip, bgfx::TextureInfo* _info, bimg::Orientation::Enum* _orientation)
|
||||
{
|
||||
return loadTexture(entry::getFileReader(), _name, _flags, _skip, _info, _orientation);
|
||||
return loadTexture(entry::getFileReader(), _filePath, _flags, _skip, _info, _orientation);
|
||||
}
|
||||
|
||||
bimg::ImageContainer* imageLoad(const char* _filePath, bgfx::TextureFormat::Enum _dstFormat)
|
||||
bimg::ImageContainer* imageLoad(const bx::FilePath& _filePath, bgfx::TextureFormat::Enum _dstFormat)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
void* data = loadMem(entry::getFileReader(), entry::getAllocator(), _filePath, &size);
|
||||
@ -660,7 +661,7 @@ Mesh* meshLoad(bx::ReaderSeekerI* _reader, bool _ramcopy)
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Mesh* meshLoad(const char* _filePath, bool _ramcopy)
|
||||
Mesh* meshLoad(const bx::FilePath& _filePath, bool _ramcopy)
|
||||
{
|
||||
bx::FileReaderI* reader = entry::getFileReader();
|
||||
if (bx::open(reader, _filePath) )
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <bx/bounds.h>
|
||||
#include <bx/pixelformat.h>
|
||||
#include <bx/string.h>
|
||||
#include <bx/filepath.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bimg/bimg.h>
|
||||
|
||||
@ -18,22 +18,22 @@ namespace stl = tinystl;
|
||||
|
||||
|
||||
///
|
||||
void* load(const char* _filePath, uint32_t* _size = NULL);
|
||||
void* load(const bx::FilePath& _filePath, uint32_t* _size = NULL);
|
||||
|
||||
///
|
||||
void unload(void* _ptr);
|
||||
|
||||
///
|
||||
bgfx::ShaderHandle loadShader(const char* _name);
|
||||
bgfx::ShaderHandle loadShader(const bx::StringView& _name);
|
||||
|
||||
///
|
||||
bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName);
|
||||
bgfx::ProgramHandle loadProgram(const bx::StringView& _vsName, const bx::StringView& _fsName);
|
||||
|
||||
///
|
||||
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);
|
||||
bgfx::TextureHandle loadTexture(const bx::FilePath& _filePath, uint64_t _flags = BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE, uint8_t _skip = 0, bgfx::TextureInfo* _info = NULL, bimg::Orientation::Enum* _orientation = NULL);
|
||||
|
||||
///
|
||||
bimg::ImageContainer* imageLoad(const char* _filePath, bgfx::TextureFormat::Enum _dstFormat);
|
||||
bimg::ImageContainer* imageLoad(const bx::FilePath& _filePath, bgfx::TextureFormat::Enum _dstFormat);
|
||||
|
||||
///
|
||||
void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexLayout _layout, const uint16_t* _indices, uint32_t _numIndices);
|
||||
@ -129,7 +129,7 @@ struct Mesh
|
||||
};
|
||||
|
||||
///
|
||||
Mesh* meshLoad(const char* _filePath, bool _ramcopy = false);
|
||||
Mesh* meshLoad(const bx::FilePath& _filePath, bool _ramcopy = false);
|
||||
|
||||
///
|
||||
void meshUnload(Mesh* _mesh);
|
||||
|
Loading…
Reference in New Issue
Block a user