Sfoglia il codice sorgente

Use screen width/height variables in unprojection

Sanjay Madhav 8 anni fa
parent
commit
35c677f1c0
3 ha cambiato i file con 6 aggiunte e 6 eliminazioni
  1. 2 2
      Chapter09/Renderer.cpp
  2. 2 2
      Chapter10/Renderer.cpp
  3. 2 2
      Chapter11/Renderer.cpp

+ 2 - 2
Chapter09/Renderer.cpp

@@ -316,8 +316,8 @@ Vector3 Renderer::Unproject(const Vector3& screenPoint) const
 {
 	// Convert screenPoint to device coordinates (between -1 and +1)
 	Vector3 deviceCoord = screenPoint;
-	deviceCoord.x /= (1024.0f) * 0.5f;
-	deviceCoord.y /= (768.0f) * 0.5f;
+	deviceCoord.x /= (mScreenWidth) * 0.5f;
+	deviceCoord.y /= (mScreenHeight) * 0.5f;
 
 	// Transform vector by unprojection matrix
 	Matrix4 unprojection = mView * mProjection;

+ 2 - 2
Chapter10/Renderer.cpp

@@ -316,8 +316,8 @@ Vector3 Renderer::Unproject(const Vector3& screenPoint) const
 {
 	// Convert screenPoint to device coordinates (between -1 and +1)
 	Vector3 deviceCoord = screenPoint;
-	deviceCoord.x /= (1024.0f) * 0.5f;
-	deviceCoord.y /= (768.0f) * 0.5f;
+	deviceCoord.x /= (mScreenWidth) * 0.5f;
+	deviceCoord.y /= (mScreenHeight) * 0.5f;
 
 	// Transform vector by unprojection matrix
 	Matrix4 unprojection = mView * mProjection;

+ 2 - 2
Chapter11/Renderer.cpp

@@ -324,8 +324,8 @@ Vector3 Renderer::Unproject(const Vector3& screenPoint) const
 {
 	// Convert screenPoint to device coordinates (between -1 and +1)
 	Vector3 deviceCoord = screenPoint;
-	deviceCoord.x /= (1024.0f) * 0.5f;
-	deviceCoord.y /= (768.0f) * 0.5f;
+	deviceCoord.x /= (mScreenWidth) * 0.5f;
+	deviceCoord.y /= (mScreenHeight) * 0.5f;
 
 	// Transform vector by unprojection matrix
 	Matrix4 unprojection = mView * mProjection;