summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/bgfx_utils.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/common/bgfx_utils.h')
-rw-r--r--3rdparty/bgfx/examples/common/bgfx_utils.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/3rdparty/bgfx/examples/common/bgfx_utils.h b/3rdparty/bgfx/examples/common/bgfx_utils.h
index f948d1bfac2..5fba167bc85 100644
--- a/3rdparty/bgfx/examples/common/bgfx_utils.h
+++ b/3rdparty/bgfx/examples/common/bgfx_utils.h
@@ -6,8 +6,9 @@
#ifndef BGFX_UTILS_H_HEADER_GUARD
#define BGFX_UTILS_H_HEADER_GUARD
+#include <bx/pixelformat.h>
#include <bgfx/bgfx.h>
-#include "image.h"
+#include <bimg/bimg.h>
///
void* load(const char* _filePath, uint32_t* _size = NULL);
@@ -22,10 +23,10 @@ bgfx::ShaderHandle loadShader(const char* _name);
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);
+bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, bgfx::TextureInfo* _info = NULL, bimg::Orientation::Enum* _orientation = NULL);
///
-bgfx::ImageContainer* imageLoad(const char* _filePath, bgfx::TextureFormat::Enum _dstFormat);
+bimg::ImageContainer* imageLoad(const char* _filePath, bgfx::TextureFormat::Enum _dstFormat);
///
void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl, const uint16_t* _indices, uint32_t _numIndices);
@@ -45,6 +46,21 @@ inline bool checkAvailTransientBuffers(uint32_t _numVertices, const bgfx::Vertex
}
///
+inline uint32_t encodeNormalRgba8(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
+{
+ const float src[] =
+ {
+ _x * 0.5f + 0.5f,
+ _y * 0.5f + 0.5f,
+ _z * 0.5f + 0.5f,
+ _w * 0.5f + 0.5f,
+ };
+ uint32_t dst;
+ bx::packRgba8(&dst, src);
+ return dst;
+}
+
+///
struct MeshState
{
struct Texture
@@ -59,7 +75,7 @@ struct MeshState
uint64_t m_state;
bgfx::ProgramHandle m_program;
uint8_t m_numTextures;
- uint8_t m_viewId;
+ bgfx::ViewId m_viewId;
};
struct Mesh;
@@ -77,7 +93,7 @@ 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, bgfx::ViewId _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);
@@ -85,7 +101,7 @@ void meshSubmit(const Mesh* _mesh, const MeshState*const* _state, uint8_t _numPa
///
struct Args
{
- Args(int _argc, char** _argv);
+ Args(int _argc, const char* const* _argv);
bgfx::RendererType::Enum m_type;
uint16_t m_pciId;