mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Fixing projection matrix in examples.
This commit is contained in:
@@ -403,7 +403,7 @@ int _main_(int _argc, char** _argv)
|
||||
float view[16];
|
||||
float proj[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
@@ -452,7 +452,7 @@ public:
|
||||
float view[16];
|
||||
float proj[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
@@ -437,7 +437,7 @@ class ExampleHDR : public entry::AppI
|
||||
|
||||
float view[16];
|
||||
bx::mtxLookAt(view, temp, at);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
// Set view and projection matrix for view hdrMesh.
|
||||
bgfx::setViewTransform(hdrMesh, view, proj);
|
||||
|
||||
@@ -215,7 +215,7 @@ int _main_(int _argc, char** _argv)
|
||||
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
|
||||
{
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
static float time = 0.0f;
|
||||
time += 0.05f;
|
||||
@@ -234,7 +234,7 @@ int _main_(int _argc, char** _argv)
|
||||
else
|
||||
{
|
||||
float ortho[16];
|
||||
bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f);
|
||||
bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
bgfx::setViewTransform(0, view, ortho);
|
||||
bgfx::setViewRect(0, 0, 0, uint16_t(width), uint16_t(height) );
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ int _main_(int _argc, char** _argv)
|
||||
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
|
||||
{
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
static float time = 0.0f;
|
||||
time += 0.05f;
|
||||
|
||||
@@ -188,7 +188,7 @@ class ExampleLod : public entry::AppI
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
|
||||
@@ -200,7 +200,7 @@ int _main_(int _argc, char** _argv)
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
|
||||
const float aspect = float(int32_t(width) ) / float(int32_t(height) );
|
||||
bx::mtxProj(proj, 60.0f, aspect, 0.1f, 1000.0f, flipV);
|
||||
bx::mtxProj(proj, 60.0f, aspect, 0.1f, 1000.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
// Time acumulators.
|
||||
float timeAccumulatorLight = 0.0f;
|
||||
|
||||
@@ -1958,7 +1958,7 @@ int _main_(int _argc, char** _argv)
|
||||
const float camFar = 2000.0f;
|
||||
const float projHeight = 1.0f/bx::ftan(bx::toRad(camFovy)*0.5f);
|
||||
const float projWidth = projHeight * camAspect;
|
||||
bx::mtxProj(viewState.m_proj, camFovy, camAspect, camNear, camFar);
|
||||
bx::mtxProj(viewState.m_proj, camFovy, camAspect, camNear, camFar, bgfx::getCaps()->homogeneousDepth);
|
||||
cameraGetViewMtx(viewState.m_view);
|
||||
|
||||
float timeAccumulatorLight = 0.0f;
|
||||
|
||||
@@ -728,7 +728,7 @@ int _main_(int _argc, char** _argv)
|
||||
|
||||
// View Transform 1.
|
||||
camera.mtxLookAt(view);
|
||||
bx::mtxProj(proj, 45.0f, float(width)/float(height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 45.0f, float(width)/float(height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
bgfx::setViewTransform(1, view, proj);
|
||||
|
||||
// View rect.
|
||||
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
|
||||
@@ -77,7 +77,7 @@ int _main_(int _argc, char** _argv)
|
||||
float view[16];
|
||||
float proj[16];
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
bx::mtxProj(proj, 60.0f, float(width) / float(height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(width) / float(height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ int _main_(int _argc, char** _argv)
|
||||
else
|
||||
{
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f);
|
||||
bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
|
||||
@@ -190,7 +190,7 @@ class ExampleOcclusion : public entry::AppI
|
||||
else
|
||||
{
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f);
|
||||
bx::mtxProj(proj, 90.0f, float(width)/float(height), 0.1f, 10000.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
|
||||
@@ -458,7 +458,7 @@ class ExampleTerrain : public entry::AppI
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
|
||||
cameraGetViewMtx(m_viewMtx);
|
||||
bx::mtxProj(m_projMtx, 60.0f, float(m_width) / float(m_height), 0.1f, 2000.0f);
|
||||
bx::mtxProj(m_projMtx, 60.0f, float(m_width) / float(m_height), 0.1f, 2000.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
bgfx::setViewTransform(0, m_viewMtx, m_projMtx);
|
||||
bgfx::setTransform(m_terrain.m_transform);
|
||||
|
||||
@@ -497,7 +497,7 @@ class ExampleWireframe : public entry::AppI
|
||||
m_camera.update(deltaTimeSec);
|
||||
bx::memCopy(m_uniforms.m_camPos, m_camera.m_pos.curr, 3*sizeof(float));
|
||||
m_camera.mtxLookAt(view);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
m_uniforms.m_drawEdges = (DrawMode::WireframeShaded == m_drawMode) ? 1.0f : 0.0f;
|
||||
|
||||
@@ -118,7 +118,7 @@ class DebugDrawApp : public entry::AppI
|
||||
}
|
||||
else
|
||||
{
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
@@ -129,7 +129,7 @@ class DebugDrawApp : public entry::AppI
|
||||
float mvp[16];
|
||||
float eye[] = { 5.0f, 10.0f, 5.0f };
|
||||
bx::mtxLookAt(view, eye, zero);
|
||||
bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f);
|
||||
bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
bx::mtxMul(mvp, view, proj);
|
||||
|
||||
ddBegin(0);
|
||||
|
||||
@@ -207,7 +207,7 @@ class ExamplePicking : public entry::AppI
|
||||
bx::mtxLookAt(view, eye, at);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(m_width) / float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width) / float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
// Set up view rect and transform for the shaded pass
|
||||
bgfx::setViewRect(RENDER_PASS_SHADING, 0, 0, uint16_t(m_width), uint16_t(m_height) );
|
||||
@@ -238,7 +238,7 @@ class ExamplePicking : public entry::AppI
|
||||
|
||||
// Tight FOV is best for picking
|
||||
float pickProj[16];
|
||||
bx::mtxProj(pickProj, m_fov, 1, 0.1f, 100.0f);
|
||||
bx::mtxProj(pickProj, m_fov, 1, 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
// View rect and transforms for picking pass
|
||||
bgfx::setViewRect(RENDER_PASS_ID, 0, 0, ID_DIM, ID_DIM);
|
||||
|
||||
@@ -454,7 +454,7 @@ public:
|
||||
cameraGetViewMtx(view);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
bgfx::setViewRect(RENDER_PASS_GBUFFER, 0, 0, uint16_t(m_width), uint16_t(m_height));
|
||||
bgfx::setViewTransform(RENDER_PASS_GBUFFER, view, proj);
|
||||
|
||||
@@ -329,7 +329,7 @@ class Particles : public entry::AppI
|
||||
}
|
||||
else
|
||||
{
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
|
||||
@@ -812,7 +812,7 @@ struct Imgui
|
||||
m_surfaceWidth = _surfaceWidth / 2;
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth);
|
||||
|
||||
static float time = 0.0f;
|
||||
time += 0.05f;
|
||||
|
||||
Reference in New Issue
Block a user