Ver Fonte

Fixing projection matrix in examples.

Branimir Karadžić há 8 anos atrás
pai
commit
d96225a1f0

+ 1 - 1
examples/07-callback/callback.cpp

@@ -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);

+ 1 - 1
examples/08-update/update.cpp

@@ -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);

+ 1 - 1
examples/09-hdr/hdr.cpp

@@ -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);

+ 2 - 2
examples/10-font/font.cpp

@@ -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) );
 		}

+ 1 - 1
examples/11-fontsdf/fontsdf.cpp

@@ -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;

+ 1 - 1
examples/12-lod/lod.cpp

@@ -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.

+ 1 - 1
examples/15-shadowmaps-simple/shadowmaps_simple.cpp

@@ -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;

+ 1 - 1
examples/16-shadowmaps/shadowmaps.cpp

@@ -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;

+ 1 - 1
examples/18-ibl/ibl.cpp

@@ -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.

+ 1 - 1
examples/22-windows/windows.cpp

@@ -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);

+ 1 - 1
examples/23-vectordisplay/main.cpp

@@ -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);
 

+ 1 - 1
examples/24-nbody/nbody.cpp

@@ -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.

+ 1 - 1
examples/26-occlusion/occlusion.cpp

@@ -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);

+ 1 - 1
examples/27-terrain/terrain.cpp

@@ -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);

+ 1 - 1
examples/28-wireframe/wireframe.cpp

@@ -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;

+ 2 - 2
examples/29-debugdraw/debugdraw.cpp

@@ -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);

+ 2 - 2
examples/30-picking/picking.cpp

@@ -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);

+ 1 - 1
examples/31-rsm/reflectiveshadowmap.cpp

@@ -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);

+ 1 - 1
examples/32-particles/particles.cpp

@@ -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);

+ 1 - 1
examples/common/imgui/imgui.cpp

@@ -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;