2014-05-04 02:18:28 +04:00
|
|
|
/*
|
2015-01-02 02:04:46 +03:00
|
|
|
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
2014-05-04 02:18:28 +04:00
|
|
|
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BGFX_UTILS_H_HEADER_GUARD
|
|
|
|
#define BGFX_UTILS_H_HEADER_GUARD
|
|
|
|
|
2015-09-19 06:16:24 +03:00
|
|
|
#include <bgfx/bgfx.h>
|
2014-05-04 02:18:28 +04:00
|
|
|
|
2015-01-23 08:01:09 +03:00
|
|
|
void* load(const char* _filePath, uint32_t* _size = NULL);
|
2015-06-02 03:45:40 +03:00
|
|
|
void unload(void* _ptr);
|
2014-05-11 07:51:44 +04:00
|
|
|
bgfx::ShaderHandle loadShader(const char* _name);
|
2014-05-04 02:18:28 +04:00
|
|
|
bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName);
|
|
|
|
bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, bgfx::TextureInfo* _info = NULL);
|
|
|
|
void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl, const uint16_t* _indices, uint32_t _numIndices);
|
|
|
|
|
2015-01-08 09:36:36 +03:00
|
|
|
struct MeshState
|
|
|
|
{
|
|
|
|
struct Texture
|
|
|
|
{
|
|
|
|
uint32_t m_flags;
|
|
|
|
bgfx::UniformHandle m_sampler;
|
|
|
|
bgfx::TextureHandle m_texture;
|
|
|
|
uint8_t m_stage;
|
|
|
|
};
|
|
|
|
|
|
|
|
Texture m_textures[4];
|
|
|
|
uint64_t m_state;
|
|
|
|
bgfx::ProgramHandle m_program;
|
|
|
|
uint8_t m_numTextures;
|
|
|
|
uint8_t m_viewId;
|
|
|
|
};
|
|
|
|
|
2014-05-04 02:18:28 +04:00
|
|
|
struct Mesh;
|
2015-01-08 09:36:36 +03:00
|
|
|
|
2014-05-04 02:18:28 +04:00
|
|
|
Mesh* meshLoad(const char* _filePath);
|
|
|
|
void meshUnload(Mesh* _mesh);
|
2015-01-08 09:36:36 +03:00
|
|
|
|
|
|
|
MeshState* meshStateCreate();
|
|
|
|
void meshStateDestroy(MeshState* _meshState);
|
|
|
|
|
|
|
|
void meshSubmit(const Mesh* _mesh, uint8_t _id, bgfx::ProgramHandle _program, const float* _mtx, uint64_t _state = BGFX_STATE_MASK);
|
|
|
|
void meshSubmit(const Mesh* _mesh, const MeshState*const* _state, uint8_t _numPasses, const float* _mtx, uint16_t _numMatrices = 1);
|
2014-05-04 02:18:28 +04:00
|
|
|
|
|
|
|
#endif // BGFX_UTILS_H_HEADER_GUARD
|