わかりました - 私の質問は私の頭と同じくらい曇っていたようです。もう一度試してみましょう。
D3D デバイスのビューポートを構成する際に 3 つのプロパティがあります。 - デバイスが実行されている解像度 (フルスクリーン)。- モニターの物理的な縦横比 (分数と浮動小数点数: 1、例: 4:3 & 1.33)。- ソースの解像度の縦横比 (ソースの解像度自体は意味がなく、レンダリングが必要とする縦横比と実行するのに理想的な解像度の種類以外はほとんどわかりません)。
次に、これに遭遇します:
// -- figure out aspect ratio adjusted VPs --
m_nativeVP.Width = xRes;
m_nativeVP.Height = yRes;
m_nativeVP.X = 0;
m_nativeVP.Y = 0;
m_nativeVP.MaxZ = 1.f;
m_nativeVP.MinZ = 0.f;
FIX_ME // this does not cover all bases -- fix!
uint xResAdj, yResAdj;
if (g_displayAspectRatio.Get() < g_renderAspectRatio.Get())
{
xResAdj = xRes;
yResAdj = (uint) ((float) xRes / g_renderAspectRatio.Get());
}
else if (g_displayAspectRatio.Get() > g_renderAspectRatio.Get())
{
xResAdj = (uint) ((float) yRes * g_renderAspectRatio.Get());
yResAdj = yRes;
}
else // ==
{
xResAdj = xRes;
yResAdj = yRes;
}
m_fullVP.Width = xResAdj;
m_fullVP.Height = yResAdj;
m_fullVP.X = (xRes - xResAdj) >> 1;
m_fullVP.Y = (yRes - yResAdj) >> 1;
m_fullVP.MaxZ = 1.f;
m_fullVP.MinZ = 0.f;
g_displayAspectRatio が xRes/yRes の比率 (= デバイスの解像度から適応) に等しい限り、すべて問題なく、このコードは期待どおりに動作します。しかし、これらの 2 つの値が関連しなくなるとすぐに (たとえば、誰かが 16:10 の画面で 4:3 の解像度をハードウェア ストレッチで実行すると)、補正するために別の手順が必要になります。 .
(そしてps私はアトミック型でCスタイルのキャストを使用し、それと一緒に暮らします:-))