1
0
mirror of synced 2024-11-12 01:50:47 +01:00

ウインドウのアスペクト比を維持するように (#512)

* ウインドウのアスペクト比を維持するように

* 修正

* 修正2
This commit is contained in:
Takkkom 2023-10-22 20:08:52 +09:00 committed by GitHub
parent 547faacc09
commit 56c7a4bb5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -411,6 +411,7 @@ namespace SampleFramework
{
double fps = 1.0f / deltaTime;
TimeMs = (long)(Window_.Time * 1000);
Update();
}
@ -428,6 +429,19 @@ namespace SampleFramework
public void Window_Resize(Vector2D<int> size)
{
if (size.X > 0 && size.Y > 0 && Window_.WindowState == WindowState.Normal)
{
float resolutionAspect = (float)GameWindowSize.Width / GameWindowSize.Height;
if (WindowSize.X != size.X)
{
size.Y = (int)(size.X / (resolutionAspect));
}
else
{
size.X = (int)(size.Y * (resolutionAspect));
}
}
WindowSize = size;
GraphicsDevice.SetViewPort(0, 0, (uint)size.X, (uint)size.Y);
}