Moved fpumath to bx.

This commit is contained in:
Branimir Karadžić
2014-05-26 19:31:37 -07:00
parent 92190fcbbf
commit 02e549bfec
27 changed files with 274 additions and 846 deletions

View File

@@ -12,8 +12,8 @@
#include <bgfx.h>
#include <bx/timer.h>
#include <bx/readerwriter.h>
#include <bx/fpumath.h>
#include "entry/entry.h"
#include "fpumath.h"
#define RENDER_SHADOW_PASS_ID 0
#define RENDER_SHADOW_PASS_BIT (1<<RENDER_SHADOW_PASS_ID)
@@ -484,10 +484,10 @@ int _main_(int /*_argc*/, char** /*_argv*/)
const float eye[3] = { 0.0f, 30.0f, -60.0f };
const float at[3] = { 0.0f, 5.0f, 0.0f };
mtxLookAt(view, eye, at);
bx::mtxLookAt(view, eye, at);
const float aspect = float(int32_t(width) ) / float(int32_t(height) );
mtxProj(proj, 60.0f, aspect, 0.1f, 1000.0f);
bx::mtxProj(proj, 60.0f, aspect, 0.1f, 1000.0f);
// Time acumulators.
float timeAccumulatorLight = 0.0f;
@@ -526,28 +526,28 @@ int _main_(int /*_argc*/, char** /*_argv*/)
// Setup instance matrices.
float mtxFloor[16];
mtxSRT(mtxFloor
bx::mtxSRT(mtxFloor
, 30.0f, 30.0f, 30.0f
, 0.0f, 0.0f, 0.0f
, 0.0f, 0.0f, 0.0f
);
float mtxBunny[16];
mtxSRT(mtxBunny
bx::mtxSRT(mtxBunny
, 5.0f, 5.0f, 5.0f
, 0.0f, float(M_PI) - timeAccumulatorScene, 0.0f
, 15.0f, 5.0f, 0.0f
);
float mtxHollowcube[16];
mtxSRT(mtxHollowcube
bx::mtxSRT(mtxHollowcube
, 2.5f, 2.5f, 2.5f
, 0.0f, 1.56f - timeAccumulatorScene, 0.0f
, 0.0f, 10.0f, 0.0f
);
float mtxCube[16];
mtxSRT(mtxCube
bx::mtxSRT(mtxCube
, 2.5f, 2.5f, 2.5f
, 0.0f, 1.56f - timeAccumulatorScene, 0.0f
, -15.0f, 5.0f, 0.0f
@@ -564,10 +564,10 @@ int _main_(int /*_argc*/, char** /*_argv*/)
-lightPos[2],
};
const float at[3] = { 0.0f, 0.0f, 0.0f };
mtxLookAt(lightView, eye, at);
bx::mtxLookAt(lightView, eye, at);
const float area = 30.0f;
mtxOrtho(lightProj, -area, area, -area, area, -100.0f, 100.0f);
bx::mtxOrtho(lightProj, -area, area, -area, area, -100.0f, 100.0f);
bgfx::setViewRect(RENDER_SHADOW_PASS_ID, 0, 0, shadowMapSize, shadowMapSize);
bgfx::setViewFrameBuffer(RENDER_SHADOW_PASS_ID, s_shadowMapFB);
@@ -596,29 +596,29 @@ int _main_(int /*_argc*/, char** /*_argv*/)
};
float mtxTmp[16];
mtxMul(mtxTmp, lightProj, mtxCrop);
mtxMul(mtxShadow, lightView, mtxTmp);
bx::mtxMul(mtxTmp, lightProj, mtxCrop);
bx::mtxMul(mtxShadow, lightView, mtxTmp);
// Floor.
mtxMul(lightMtx, mtxFloor, mtxShadow);
bx::mtxMul(lightMtx, mtxFloor, mtxShadow);
bgfx::setUniform(u_lightMtx, lightMtx);
hplaneMesh.submit(RENDER_SCENE_PASS_ID, mtxFloor, progMesh);
hplaneMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxFloor, progShadow);
// Bunny.
mtxMul(lightMtx, mtxBunny, mtxShadow);
bx::mtxMul(lightMtx, mtxBunny, mtxShadow);
bgfx::setUniform(u_lightMtx, lightMtx);
bunnyMesh.submit(RENDER_SCENE_PASS_ID, mtxBunny, progMesh);
bunnyMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxBunny, progShadow);
// Hollow cube.
mtxMul(lightMtx, mtxHollowcube, mtxShadow);
bx::mtxMul(lightMtx, mtxHollowcube, mtxShadow);
bgfx::setUniform(u_lightMtx, lightMtx);
hollowcubeMesh.submit(RENDER_SCENE_PASS_ID, mtxHollowcube, progMesh);
hollowcubeMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxHollowcube, progShadow);
// Cube.
mtxMul(lightMtx, mtxCube, mtxShadow);
bx::mtxMul(lightMtx, mtxCube, mtxShadow);
bgfx::setUniform(u_lightMtx, lightMtx);
cubeMesh.submit(RENDER_SCENE_PASS_ID, mtxCube, progMesh);
cubeMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxCube, progShadow);
@@ -626,7 +626,6 @@ int _main_(int /*_argc*/, char** /*_argv*/)
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
}
bunnyMesh.unload();