From 88549aebcda4c14a77b6b12388177577df276bd4 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 12 Jan 2008 02:12:09 +0000 Subject: [PATCH] - For compatibility with the software renderer, D3DFB::DrawTextureV needs to truncate the coordinates to integers before sending them to the hardware. Otherwise, there can be one pixel gaps compared to the software renderer, because the hardware is rounding to nearest but the software renderer is simply truncating the fractional part of the coordinate. This is the real cause of the gap above the status bar at 1152x864 (and another gap to the left of the status bar at 800x500). - Fixed: When D3DFB::DrawTextureV had to clip a tile, it adjusted the texture coordinates erroneously, still using the old calculations from before texture packing was implemented. SVN r695 (trunk) --- docs/rh-log.txt | 10 + src/g_shared/shared_sbar.cpp | 3 - src/win32/fb_d3d9.cpp | 16 +- zdoom.vcproj | 1240 +++++++++++++++++----------------- 4 files changed, 640 insertions(+), 629 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index b74db371c..352586608 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,14 @@ January 11, 2008 +- For compatibility with the software renderer, D3DFB::DrawTextureV needs to + truncate the coordinates to integers before sending them to the hardware. + Otherwise, there can be one pixel gaps compared to the software renderer, + because the hardware is rounding to nearest but the software renderer is + simply truncating the fractional part of the coordinate. This is the real + cause of the gap at the top of the status bar at 1152x864 (and another gap + to the left of the status bar at 800x500). +- Fixed: When D3DFB::DrawTextureV had to clip a tile, it adjusted the + texture coordinates erroneously, still using the old calculations from + before texture packing was implemented. - Moved thingdef_codeptr.cpp into thingdef/ with the other thingdef files. January 11, 2008 (Changes by Graf Zahl) diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 6913c6562..e586100ed 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -213,9 +213,6 @@ void FBaseStatusBar::SetScaled (bool scale) ::ST_Y = Scale(ST_Y - 100, SCREENHEIGHT*3, BaseRatioSizes[4][1]) + SCREENHEIGHT/2 + (SCREENHEIGHT - SCREENHEIGHT * BaseRatioSizes[4][3] / 48) / 2; } - // If this is odd, add one to make it even and close the gap between the - // status bar and the rest of the screen - ::ST_Y += (::ST_Y & 1); Displacement = 0; } ::ST_X = ST_X; diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index c394f0eca..9fa13cb0f 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -2160,8 +2160,8 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi float v0 = tex->Box->Top; float u1 = tex->Box->Right; float v1 = tex->Box->Bottom; - float uscale = 1.f / (parms.texwidth / u1); - float vscale = 1.f / (parms.texheight / v1) / yscale; + float uscale = 1.f / tex->Box->Owner->Width; + float vscale = 1.f / tex->Box->Owner->Height / yscale; if (y0 < parms.uclip) { @@ -2210,10 +2210,14 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi } float yoffs = GatheringWipeScreen ? 0.5f : 0.5f - LBOffset; - x0 -= 0.5f; - y0 -= yoffs; - x1 -= 0.5f; - y1 -= yoffs; + + // Coordinates are truncated to integers, because that's effectively + // what the software renderer does. The hardware will instead round + // to nearest, it seems. + x0 = floorf(x0) - 0.5f; + y0 = floorf(y0) - yoffs; + x1 = floorf(x1) - 0.5f; + y1 = floorf(y1) - yoffs; FBVERTEX *vert = &VertexData[VertexPos]; diff --git a/zdoom.vcproj b/zdoom.vcproj index 3fa390beb..a4cf0d5aa 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -2721,14 +2729,6 @@ GeneratePreprocessedFile="0" /> - - - @@ -2751,7 +2751,7 @@ /> - - - @@ -4806,6 +4796,16 @@ Outputs="$(IntDir)/$(InputName).obj" /> + + + @@ -4830,16 +4830,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -4850,6 +4840,16 @@ Outputs="$(IntDir)/$(InputName).obj" /> + + + @@ -4874,16 +4874,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -4894,6 +4884,16 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + @@ -4918,16 +4918,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -4938,6 +4928,16 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + @@ -4962,16 +4962,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - @@ -4982,6 +4972,16 @@ Outputs="$(IntDir)\$(InputName).obj" /> + + + @@ -5069,7 +5069,7 @@ /> + + + @@ -5408,14 +5416,6 @@ Outputs="$(IntDir)\$(InputName).obj" /> - - - - - - @@ -5650,6 +5642,14 @@ GeneratePreprocessedFile="0" /> + + + @@ -5671,7 +5671,7 @@ /> + + + @@ -9176,14 +9184,6 @@ AdditionalIncludeDirectories="src\win32;$(NoInherit)" /> - - - @@ -9358,7 +9358,7 @@ />