Permalink
Browse files

SoftRasterizer: Fix bug where texture sampling coordinates were incor…

…rectly calculated when texture upscaling is used with GFX3D_TXTHack enabled.

Fixes issue #5. (Related to commit a8c8a86.)
  • Loading branch information...
1 parent 7a573e7 commit 36b192af00650546b9fc8c3b6b77729c8e77d6c4 @rogerman rogerman committed Dec 8, 2016
Showing with 6 additions and 4 deletions.
  1. +6 −4 desmume/src/rasterize.cpp
@@ -366,18 +366,20 @@ class RasterizerUnit
{
//finally, we can use floor here. but, it is slower than we want.
//the best solution is probably to wait until the pipeline is full of fixed point
+ const float fu = u * (float)this->currentTexture->GetRenderWidth() / (float)this->currentTexture->GetWidth();
+ const float fv = v * (float)this->currentTexture->GetRenderHeight() / (float)this->currentTexture->GetHeight();
s32 iu = 0;
s32 iv = 0;
if (!CommonSettings.GFX3D_TXTHack)
{
- iu = s32floor(u * (float)this->currentTexture->GetRenderWidth() / (float)this->currentTexture->GetWidth());
- iv = s32floor(v * (float)this->currentTexture->GetRenderHeight() / (float)this->currentTexture->GetHeight());
+ iu = s32floor(fu);
+ iv = s32floor(fv);
}
else
{
- iu = round_s(u);
- iv = round_s(v);
+ iu = round_s(fu);
+ iv = round_s(fv);
}
const u32 *textureData = this->currentTexture->GetRenderData();

0 comments on commit 36b192a

Please sign in to comment.