bgfx_utils.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #ifndef BGFX_UTILS_H_HEADER_GUARD
  6. #define BGFX_UTILS_H_HEADER_GUARD
  7. #include <bgfx.h>
  8. void* load(const char* _filePath, uint32_t* _size = NULL);
  9. bgfx::ShaderHandle loadShader(const char* _name);
  10. bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName);
  11. bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, bgfx::TextureInfo* _info = NULL);
  12. void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl, const uint16_t* _indices, uint32_t _numIndices);
  13. struct MeshState
  14. {
  15. struct Texture
  16. {
  17. uint32_t m_flags;
  18. bgfx::UniformHandle m_sampler;
  19. bgfx::TextureHandle m_texture;
  20. uint8_t m_stage;
  21. };
  22. Texture m_textures[4];
  23. uint64_t m_state;
  24. bgfx::ProgramHandle m_program;
  25. uint8_t m_numTextures;
  26. uint8_t m_viewId;
  27. };
  28. struct Mesh;
  29. Mesh* meshLoad(const char* _filePath);
  30. void meshUnload(Mesh* _mesh);
  31. MeshState* meshStateCreate();
  32. void meshStateDestroy(MeshState* _meshState);
  33. void meshSubmit(const Mesh* _mesh, uint8_t _id, bgfx::ProgramHandle _program, const float* _mtx, uint64_t _state = BGFX_STATE_MASK);
  34. void meshSubmit(const Mesh* _mesh, const MeshState*const* _state, uint8_t _numPasses, const float* _mtx, uint16_t _numMatrices = 1);
  35. #endif // BGFX_UTILS_H_HEADER_GUARD