Cleanup.
This commit is contained in:
parent
1d44a7a030
commit
8499319009
@ -32,57 +32,32 @@ struct PosNormalTangentTexcoordVertex
|
||||
|
||||
bgfx::VertexDecl PosNormalTangentTexcoordVertex::ms_decl;
|
||||
|
||||
uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t ui32;
|
||||
uint8_t arr[4];
|
||||
} un;
|
||||
|
||||
un.arr[0] = _x;
|
||||
un.arr[1] = _y;
|
||||
un.arr[2] = _z;
|
||||
un.arr[3] = _w;
|
||||
|
||||
return un.ui32;
|
||||
}
|
||||
|
||||
uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
|
||||
{
|
||||
const uint8_t xx = uint8_t(_x*127.0f + 128.0f);
|
||||
const uint8_t yy = uint8_t(_y*127.0f + 128.0f);
|
||||
const uint8_t zz = uint8_t(_z*127.0f + 128.0f);
|
||||
const uint8_t ww = uint8_t(_w*127.0f + 128.0f);
|
||||
return packUint32(xx, yy, zz, ww);
|
||||
}
|
||||
|
||||
static PosNormalTangentTexcoordVertex s_cubeVertices[24] =
|
||||
{
|
||||
{-1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{-1.0f, 1.0f, 1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
};
|
||||
|
||||
static const uint16_t s_cubeIndices[36] =
|
||||
|
@ -24,31 +24,6 @@
|
||||
|
||||
#define MAX_NUM_LIGHTS 5
|
||||
|
||||
uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t ui32;
|
||||
uint8_t arr[4];
|
||||
} un;
|
||||
|
||||
un.arr[0] = _x;
|
||||
un.arr[1] = _y;
|
||||
un.arr[2] = _z;
|
||||
un.arr[3] = _w;
|
||||
|
||||
return un.ui32;
|
||||
}
|
||||
|
||||
uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
|
||||
{
|
||||
const uint8_t xx = uint8_t(_x*127.0f + 128.0f);
|
||||
const uint8_t yy = uint8_t(_y*127.0f + 128.0f);
|
||||
const uint8_t zz = uint8_t(_z*127.0f + 128.0f);
|
||||
const uint8_t ww = uint8_t(_w*127.0f + 128.0f);
|
||||
return packUint32(xx, yy, zz, ww);
|
||||
}
|
||||
|
||||
struct PosNormalTexcoordVertex
|
||||
{
|
||||
float m_x;
|
||||
@ -76,46 +51,46 @@ bgfx::VertexDecl PosNormalTexcoordVertex::ms_decl;
|
||||
static const float s_texcoord = 5.0f;
|
||||
static PosNormalTexcoordVertex s_hplaneVertices[] =
|
||||
{
|
||||
{ -1.0f, 0.0f, 1.0f, packF4u(0.0f, 1.0f, 0.0f), s_texcoord, s_texcoord },
|
||||
{ 1.0f, 0.0f, 1.0f, packF4u(0.0f, 1.0f, 0.0f), s_texcoord, 0.0f },
|
||||
{ -1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f), 0.0f, s_texcoord },
|
||||
{ 1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 0.0f, 1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), s_texcoord, s_texcoord },
|
||||
{ 1.0f, 0.0f, 1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), s_texcoord, 0.0f },
|
||||
{ -1.0f, 0.0f, -1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), 0.0f, s_texcoord },
|
||||
{ 1.0f, 0.0f, -1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), 0.0f, 0.0f },
|
||||
};
|
||||
|
||||
static PosNormalTexcoordVertex s_vplaneVertices[] =
|
||||
{
|
||||
{ -1.0f, 1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
|
||||
};
|
||||
|
||||
static const PosNormalTexcoordVertex s_cubeVertices[] =
|
||||
{
|
||||
{ -1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 1.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 1.0f, 0.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 1.0f, 0.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 1.0f, 1.0f },
|
||||
{ -1.0f, 1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, -1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 1.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 1.0f, 0.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 1.0f, 0.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, -1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 1.0f, 1.0f },
|
||||
{ -1.0f, 1.0f, 1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0.0f, 1.0f },
|
||||
{ -1.0f, -1.0f, -1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0.0f, 0.0f },
|
||||
};
|
||||
|
||||
static const uint16_t s_cubeIndices[] =
|
||||
|
@ -33,31 +33,6 @@ namespace stl = tinystl;
|
||||
#define VIEWID_RANGE15_PASS2 3
|
||||
#define VIEWID_RANGE1_PASS3 20
|
||||
|
||||
uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t ui32;
|
||||
uint8_t arr[4];
|
||||
} un;
|
||||
|
||||
un.arr[0] = _x;
|
||||
un.arr[1] = _y;
|
||||
un.arr[2] = _z;
|
||||
un.arr[3] = _w;
|
||||
|
||||
return un.ui32;
|
||||
}
|
||||
|
||||
uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
|
||||
{
|
||||
const uint8_t xx = uint8_t(_x*127.0f + 128.0f);
|
||||
const uint8_t yy = uint8_t(_y*127.0f + 128.0f);
|
||||
const uint8_t zz = uint8_t(_z*127.0f + 128.0f);
|
||||
const uint8_t ww = uint8_t(_w*127.0f + 128.0f);
|
||||
return packUint32(xx, yy, zz, ww);
|
||||
}
|
||||
|
||||
struct PosNormalTexcoordVertex
|
||||
{
|
||||
float m_x;
|
||||
@ -85,18 +60,18 @@ bgfx::VertexDecl PosNormalTexcoordVertex::ms_decl;
|
||||
static const float s_texcoord = 50.0f;
|
||||
static PosNormalTexcoordVertex s_hplaneVertices[] =
|
||||
{
|
||||
{ -1.0f, 0.0f, 1.0f, packF4u(0.0f, 1.0f, 0.0f), s_texcoord, s_texcoord },
|
||||
{ 1.0f, 0.0f, 1.0f, packF4u(0.0f, 1.0f, 0.0f), s_texcoord, 0.0f },
|
||||
{ -1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f), 0.0f, s_texcoord },
|
||||
{ 1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 0.0f, 1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), s_texcoord, s_texcoord },
|
||||
{ 1.0f, 0.0f, 1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), s_texcoord, 0.0f },
|
||||
{ -1.0f, 0.0f, -1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), 0.0f, s_texcoord },
|
||||
{ 1.0f, 0.0f, -1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), 0.0f, 0.0f },
|
||||
};
|
||||
|
||||
static PosNormalTexcoordVertex s_vplaneVertices[] =
|
||||
{
|
||||
{ -1.0f, 1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
|
||||
};
|
||||
|
||||
static const uint16_t s_planeIndices[] =
|
||||
|
@ -19,31 +19,6 @@
|
||||
#define RENDER_SHADOW_PASS_ID 0
|
||||
#define RENDER_SCENE_PASS_ID 1
|
||||
|
||||
uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t ui32;
|
||||
uint8_t arr[4];
|
||||
} un;
|
||||
|
||||
un.arr[0] = _x;
|
||||
un.arr[1] = _y;
|
||||
un.arr[2] = _z;
|
||||
un.arr[3] = _w;
|
||||
|
||||
return un.ui32;
|
||||
}
|
||||
|
||||
uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
|
||||
{
|
||||
const uint8_t xx = uint8_t(_x*127.0f + 128.0f);
|
||||
const uint8_t yy = uint8_t(_y*127.0f + 128.0f);
|
||||
const uint8_t zz = uint8_t(_z*127.0f + 128.0f);
|
||||
const uint8_t ww = uint8_t(_w*127.0f + 128.0f);
|
||||
return packUint32(xx, yy, zz, ww);
|
||||
}
|
||||
|
||||
struct PosNormalVertex
|
||||
{
|
||||
float m_x;
|
||||
@ -54,10 +29,10 @@ struct PosNormalVertex
|
||||
|
||||
static PosNormalVertex s_hplaneVertices[] =
|
||||
{
|
||||
{ -1.0f, 0.0f, 1.0f, packF4u(0.0f, 1.0f, 0.0f) },
|
||||
{ 1.0f, 0.0f, 1.0f, packF4u(0.0f, 1.0f, 0.0f) },
|
||||
{ -1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f) },
|
||||
{ 1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f) },
|
||||
{ -1.0f, 0.0f, 1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f) },
|
||||
{ 1.0f, 0.0f, 1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f) },
|
||||
{ -1.0f, 0.0f, -1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f) },
|
||||
{ 1.0f, 0.0f, -1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f) },
|
||||
};
|
||||
|
||||
static const uint16_t s_planeIndices[] =
|
||||
|
@ -38,31 +38,6 @@
|
||||
#define RENDERVIEW_DRAWDEPTH_2_ID 18
|
||||
#define RENDERVIEW_DRAWDEPTH_3_ID 19
|
||||
|
||||
uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t ui32;
|
||||
uint8_t arr[4];
|
||||
} un;
|
||||
|
||||
un.arr[0] = _x;
|
||||
un.arr[1] = _y;
|
||||
un.arr[2] = _z;
|
||||
un.arr[3] = _w;
|
||||
|
||||
return un.ui32;
|
||||
}
|
||||
|
||||
uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
|
||||
{
|
||||
const uint8_t xx = uint8_t(_x*127.0f + 128.0f);
|
||||
const uint8_t yy = uint8_t(_y*127.0f + 128.0f);
|
||||
const uint8_t zz = uint8_t(_z*127.0f + 128.0f);
|
||||
const uint8_t ww = uint8_t(_w*127.0f + 128.0f);
|
||||
return packUint32(xx, yy, zz, ww);
|
||||
}
|
||||
|
||||
struct LightType
|
||||
{
|
||||
enum Enum
|
||||
@ -200,18 +175,18 @@ struct PosNormalTexcoordVertex
|
||||
static const float s_texcoord = 5.0f;
|
||||
static PosNormalTexcoordVertex s_hplaneVertices[] =
|
||||
{
|
||||
{ -1.0f, 0.0f, 1.0f, packF4u(0.0f, 1.0f, 0.0f), s_texcoord, s_texcoord },
|
||||
{ 1.0f, 0.0f, 1.0f, packF4u(0.0f, 1.0f, 0.0f), s_texcoord, 0.0f },
|
||||
{ -1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f), 0.0f, s_texcoord },
|
||||
{ 1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 0.0f, 1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), s_texcoord, s_texcoord },
|
||||
{ 1.0f, 0.0f, 1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), s_texcoord, 0.0f },
|
||||
{ -1.0f, 0.0f, -1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), 0.0f, s_texcoord },
|
||||
{ 1.0f, 0.0f, -1.0f, encodeNormalRgba8(0.0f, 1.0f, 0.0f), 0.0f, 0.0f },
|
||||
};
|
||||
|
||||
static PosNormalTexcoordVertex s_vplaneVertices[] =
|
||||
{
|
||||
{ -1.0f, 1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
|
||||
{ -1.0f, 1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
|
||||
{ -1.0f, -1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 0.0f, encodeNormalRgba8(0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
|
||||
};
|
||||
|
||||
static const uint16_t s_planeIndices[] =
|
||||
|
@ -86,57 +86,32 @@ struct DebugVertex
|
||||
|
||||
bgfx::VertexDecl DebugVertex::ms_decl;
|
||||
|
||||
uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t ui32;
|
||||
uint8_t arr[4];
|
||||
} un;
|
||||
|
||||
un.arr[0] = _x;
|
||||
un.arr[1] = _y;
|
||||
un.arr[2] = _z;
|
||||
un.arr[3] = _w;
|
||||
|
||||
return un.ui32;
|
||||
}
|
||||
|
||||
uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
|
||||
{
|
||||
const uint8_t xx = uint8_t(_x*127.0f + 128.0f);
|
||||
const uint8_t yy = uint8_t(_y*127.0f + 128.0f);
|
||||
const uint8_t zz = uint8_t(_z*127.0f + 128.0f);
|
||||
const uint8_t ww = uint8_t(_w*127.0f + 128.0f);
|
||||
return packUint32(xx, yy, zz, ww);
|
||||
}
|
||||
|
||||
static PosNormalTangentTexcoordVertex s_cubeVertices[24] =
|
||||
{
|
||||
{-1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{ 1.0f, -1.0f, -1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, encodeNormalRgba8( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{-1.0f, 1.0f, 1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, encodeNormalRgba8(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
};
|
||||
|
||||
static const uint16_t s_cubeIndices[36] =
|
||||
|
@ -6,6 +6,7 @@
|
||||
#ifndef BGFX_UTILS_H_HEADER_GUARD
|
||||
#define BGFX_UTILS_H_HEADER_GUARD
|
||||
|
||||
#include <bx/pixelformat.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include "image.h"
|
||||
|
||||
@ -44,6 +45,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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user