Fix for any aspect ratio in 3D Environments (#320)
* Add initial AnyAspectRatio support * Remove some logic that didn't work * Remove rogue back slash * Remove more remnants * Update UILayer.h * Update some comments * Remove WIP UI changes * Fix diffs * Remove UI resize call from `UpdateAspectRatio` * handle merge conflict * Update to C++ style static cast * Fix syntax
This commit is contained in:
@@ -973,6 +973,9 @@ void gdraw_D3D1X_(SetRendertargetSize)(S32 w, S32 h)
|
|||||||
|
|
||||||
void gdraw_D3D1X_(SetTileOrigin)(ID3D1X(RenderTargetView) *main_rt, ID3D1X(DepthStencilView) *main_ds, ID3D1X(ShaderResourceView) *non_msaa_rt, S32 x, S32 y)
|
void gdraw_D3D1X_(SetTileOrigin)(ID3D1X(RenderTargetView) *main_rt, ID3D1X(DepthStencilView) *main_ds, ID3D1X(ShaderResourceView) *non_msaa_rt, S32 x, S32 y)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!gdraw) return; // AAR - saftey check because windows calls resize early
|
||||||
|
|
||||||
D3D1X_(RENDER_TARGET_VIEW_DESC) desc;
|
D3D1X_(RENDER_TARGET_VIEW_DESC) desc;
|
||||||
|
|
||||||
if (gdraw->frame_done) {
|
if (gdraw->frame_done) {
|
||||||
|
|||||||
@@ -88,8 +88,7 @@ BOOL g_bWidescreen = TRUE;
|
|||||||
int g_iScreenWidth = 1920;
|
int g_iScreenWidth = 1920;
|
||||||
int g_iScreenHeight = 1080;
|
int g_iScreenHeight = 1080;
|
||||||
|
|
||||||
UINT g_ScreenWidth = 1920;
|
float g_iAspectRatio = static_cast<float>(g_iScreenWidth) / g_iScreenHeight;
|
||||||
UINT g_ScreenHeight = 1080;
|
|
||||||
|
|
||||||
char g_Win64Username[17] = { 0 };
|
char g_Win64Username[17] = { 0 };
|
||||||
wchar_t g_Win64UsernameW[17] = { 0 };
|
wchar_t g_Win64UsernameW[17] = { 0 };
|
||||||
@@ -98,6 +97,14 @@ wchar_t g_Win64UsernameW[17] = { 0 };
|
|||||||
static bool g_isFullscreen = false;
|
static bool g_isFullscreen = false;
|
||||||
static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
|
static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Update the Aspect Ratio to support Any Aspect Ratio
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
void UpdateAspectRatio(int width, int height)
|
||||||
|
{
|
||||||
|
g_iAspectRatio = static_cast<float>(width) / height;
|
||||||
|
}
|
||||||
|
|
||||||
struct Win64LaunchOptions
|
struct Win64LaunchOptions
|
||||||
{
|
{
|
||||||
int screenMode;
|
int screenMode;
|
||||||
@@ -468,6 +475,7 @@ ID3D11Texture2D* g_pDepthStencilBuffer = NULL;
|
|||||||
// WM_COMMAND - process the application menu
|
// WM_COMMAND - process the application menu
|
||||||
// WM_PAINT - Paint the main window
|
// WM_PAINT - Paint the main window
|
||||||
// WM_DESTROY - post a quit message and return
|
// WM_DESTROY - post a quit message and return
|
||||||
|
// WM_SIZE - handle resizing logic to support Any Aspect Ratio
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
@@ -585,6 +593,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case WM_SIZE:
|
||||||
|
{
|
||||||
|
UpdateAspectRatio(LOWORD(lParam), HIWORD(lParam));
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
@@ -719,7 +732,7 @@ HRESULT InitDevice()
|
|||||||
//app.DebugPrintf("width: %d, height: %d\n", width, height);
|
//app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||||
width = g_iScreenWidth;
|
width = g_iScreenWidth;
|
||||||
height = g_iScreenHeight;
|
height = g_iScreenHeight;
|
||||||
app.DebugPrintf("width: %d, height: %d\n", width, height);
|
//app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||||
|
|
||||||
UINT createDeviceFlags = 0;
|
UINT createDeviceFlags = 0;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|||||||
@@ -48,13 +48,11 @@ void glLoadIdentity()
|
|||||||
RenderManager.MatrixSetIdentity();
|
RenderManager.MatrixSetIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int g_iScreenWidth;
|
// AAR - Use calculated aspect ratio to support dynamic resizing
|
||||||
extern int g_iScreenHeight;
|
extern float g_iAspectRatio;
|
||||||
|
|
||||||
void gluPerspective(float fovy, float aspect, float zNear, float zFar)
|
void gluPerspective(float fovy, float aspect, float zNear, float zFar)
|
||||||
{
|
{
|
||||||
float dynamicAspect = (float)g_iScreenWidth / (float)g_iScreenHeight;
|
RenderManager.MatrixPerspective(fovy, g_iAspectRatio, zNear, zFar);
|
||||||
RenderManager.MatrixPerspective(fovy, dynamicAspect, zNear, zFar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void glOrtho(float left,float right,float bottom,float top,float zNear,float zFar)
|
void glOrtho(float left,float right,float bottom,float top,float zNear,float zFar)
|
||||||
|
|||||||
Reference in New Issue
Block a user