Skip to content

Commit 35c677f

Browse files
committed
Use screen width/height variables in unprojection
1 parent 64e627b commit 35c677f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Chapter09/Renderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ Vector3 Renderer::Unproject(const Vector3& screenPoint) const
316316
{
317317
// Convert screenPoint to device coordinates (between -1 and +1)
318318
Vector3 deviceCoord = screenPoint;
319-
deviceCoord.x /= (1024.0f) * 0.5f;
320-
deviceCoord.y /= (768.0f) * 0.5f;
319+
deviceCoord.x /= (mScreenWidth) * 0.5f;
320+
deviceCoord.y /= (mScreenHeight) * 0.5f;
321321

322322
// Transform vector by unprojection matrix
323323
Matrix4 unprojection = mView * mProjection;

Chapter10/Renderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ Vector3 Renderer::Unproject(const Vector3& screenPoint) const
316316
{
317317
// Convert screenPoint to device coordinates (between -1 and +1)
318318
Vector3 deviceCoord = screenPoint;
319-
deviceCoord.x /= (1024.0f) * 0.5f;
320-
deviceCoord.y /= (768.0f) * 0.5f;
319+
deviceCoord.x /= (mScreenWidth) * 0.5f;
320+
deviceCoord.y /= (mScreenHeight) * 0.5f;
321321

322322
// Transform vector by unprojection matrix
323323
Matrix4 unprojection = mView * mProjection;

Chapter11/Renderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ Vector3 Renderer::Unproject(const Vector3& screenPoint) const
324324
{
325325
// Convert screenPoint to device coordinates (between -1 and +1)
326326
Vector3 deviceCoord = screenPoint;
327-
deviceCoord.x /= (1024.0f) * 0.5f;
328-
deviceCoord.y /= (768.0f) * 0.5f;
327+
deviceCoord.x /= (mScreenWidth) * 0.5f;
328+
deviceCoord.y /= (mScreenHeight) * 0.5f;
329329

330330
// Transform vector by unprojection matrix
331331
Matrix4 unprojection = mView * mProjection;

0 commit comments

Comments
 (0)