@@ -69,7 +69,7 @@ namespace AzFramework
|
||||
//! Toggle the full screen state of the window.
|
||||
virtual void ToggleFullScreenState() = 0;
|
||||
|
||||
//! Returns a scalar multiplier representing how dots-per-inch this window has, compared
|
||||
//! Returns a scalar multiplier representing how many dots-per-inch this window has, compared
|
||||
//! to a "standard" value of 96, the default for Windows in a DPI unaware setting. This can
|
||||
//! be used to scale user interface elements to ensure legibility on high density displays.
|
||||
virtual float GetDpiScaleFactor() const = 0;
|
||||
|
||||
+2
-2
@@ -65,8 +65,7 @@ namespace AzFramework
|
||||
NativeWindowImpl_Win32::NativeWindowImpl_Win32()
|
||||
{
|
||||
// Attempt to load GetDpiForWindow from user32 at runtime, available on Windows 10+ versions >= 1607
|
||||
auto user32module = LoadLibraryA("user32.dll");
|
||||
if (user32module)
|
||||
if (auto user32module = LoadLibraryA("user32.dll"))
|
||||
{
|
||||
m_getDpiFunction = reinterpret_cast<GetDpiForWindowType*>(GetProcAddress(user32module, "GetDpiForWindow"));
|
||||
}
|
||||
@@ -255,6 +254,7 @@ namespace AzFramework
|
||||
{
|
||||
const float newScaleFactor = nativeWindowImpl->GetDpiScaleFactor();
|
||||
WindowNotificationBus::Event(nativeWindowImpl->GetWindowHandle(), &WindowNotificationBus::Events::OnDpiScaleFactorChanged, newScaleFactor);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
@@ -65,15 +65,15 @@ namespace AZ
|
||||
ConstViewPtr GetDefaultView() const;
|
||||
|
||||
//! Gets the current size of the viewport.
|
||||
//! This value is cached and updated on-demand, so may be performantly queried.
|
||||
//! This value is cached and updated on-demand, so may be efficiently queried.
|
||||
AzFramework::WindowSize GetViewportSize() const;
|
||||
|
||||
//! Gets the screen DPI scaling factor.
|
||||
//! This value is cached and updated on-demand, so may be performantly queried.
|
||||
//! This value is cached and updated on-demand, so may be efficiently queried.
|
||||
//! \see AzFramework::WindowRequests::GetDpiScaleFactor
|
||||
float GetDpiScalingFactor() const;
|
||||
|
||||
// SceneNotificationBus interface
|
||||
// SceneNotificationBus interface overrides...
|
||||
//! Ensures our default view remains set when our scene's render pipelines are modified.
|
||||
void OnRenderPipelineAdded(RenderPipelinePtr pipeline) override;
|
||||
//! Ensures our default view remains set when our scene's render pipelines are modified.
|
||||
@@ -81,7 +81,7 @@ namespace AZ
|
||||
//! OnBeginPrepareRender is forwarded to our RenderTick notification to allow subscribers to do rendering.
|
||||
void OnBeginPrepareRender() override;
|
||||
|
||||
//WindowNotificationBus interface
|
||||
// WindowNotificationBus interface overrides...
|
||||
//! Used to fire a notification when our window resizes.
|
||||
void OnWindowResized(uint32_t width, uint32_t height) override;
|
||||
//! Used to fire a notification when our window DPI changes.
|
||||
@@ -119,7 +119,7 @@ namespace AZ
|
||||
//! Notifies consumers when this ViewportContext is about to be destroyed.
|
||||
void ConnectAboutToBeDestroyedHandler(ViewportIdEvent::Handler& handler);
|
||||
|
||||
// ViewportRequestBus interface
|
||||
// ViewportRequestBus interface overrides...
|
||||
//! Gets the current camera's view matrix.
|
||||
const AZ::Matrix4x4& GetCameraViewMatrix() const override;
|
||||
//! Sets the current camera's view matrix.
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Atom/RPI.Public/ViewportContextBus.h>
|
||||
#include <Atom/RPI.Public/ViewportContextManager.h>
|
||||
#include <Atom/RPI.Public/View.h>
|
||||
#include "..\..\Include\Atom\RPI.Public\ViewportContext.h"
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace AZ
|
||||
auto onSizeChanged = [this, viewportId](AzFramework::WindowSize size)
|
||||
{
|
||||
// Ensure we emit OnViewportSizeChanged with the correct name.
|
||||
auto viewportContext = this->GetViewportContextById(viewportId);
|
||||
auto viewportContext = GetViewportContextById(viewportId);
|
||||
if (viewportContext)
|
||||
{
|
||||
ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportSizeChanged, size);
|
||||
@@ -65,7 +65,7 @@ namespace AZ
|
||||
auto onDpiScalingChanged = [this, viewportId](float dpiScalingFactor)
|
||||
{
|
||||
// Ensure we emit OnViewportDpiScalingChanged with the correct name.
|
||||
auto viewportContext = this->GetViewportContextById(viewportId);
|
||||
auto viewportContext = GetViewportContextById(viewportId);
|
||||
if (viewportContext)
|
||||
{
|
||||
ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportDpiScalingChanged, dpiScalingFactor);
|
||||
|
||||
+1
-1
@@ -157,7 +157,7 @@ namespace AZ::Render
|
||||
auto viewportSize = viewportContext->GetViewportSize();
|
||||
m_drawParams.m_position = AZ::Vector3(viewportSize.m_width, 0.0f, 1.0f) + AZ::Vector3(r_topRightBorderPadding);
|
||||
m_drawParams.m_color = AZ::Colors::White;
|
||||
m_drawParams.m_scale = AZ::Vector2(0.7f * viewportContext->GetDpiScalingFactor());
|
||||
m_drawParams.m_scale = AZ::Vector2(BaseFontSize * viewportContext->GetDpiScalingFactor());
|
||||
m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right;
|
||||
m_drawParams.m_monospace = false;
|
||||
m_drawParams.m_depthTest = false;
|
||||
|
||||
+2
@@ -60,6 +60,8 @@ namespace AZ
|
||||
void DrawPassInfo();
|
||||
void DrawFramerate();
|
||||
|
||||
static constexpr float BaseFontSize = 0.7f;
|
||||
|
||||
AZStd::string m_rendererDescription;
|
||||
AzFramework::TextDrawParameters m_drawParams;
|
||||
AzFramework::FontDrawInterface* m_fontDrawInterface = nullptr;
|
||||
|
||||
@@ -50,7 +50,8 @@ namespace AZ
|
||||
{
|
||||
ImGui::OtherActiveImGuiRequestBus::Handler::BusConnect();
|
||||
|
||||
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
auto atomViewportRequests = AZ::RPI::ViewportContextRequests::Get();
|
||||
AZ_Assert(atomViewportRequests, "AtomViewportContextRequests interface not found!");
|
||||
const AZ::Name contextName = atomViewportRequests->GetDefaultViewportContextName();
|
||||
AZ::RPI::ViewportContextNotificationBus::Handler::BusConnect(contextName);
|
||||
|
||||
@@ -105,7 +106,7 @@ namespace AZ
|
||||
// Let our ImguiAtomSystemComponent know once we successfully connect and update the viewport size.
|
||||
if (!m_initialized)
|
||||
{
|
||||
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
auto atomViewportRequests = AZ::RPI::ViewportContextRequests::Get();
|
||||
auto defaultViewportContext = atomViewportRequests->GetDefaultViewportContext();
|
||||
OnViewportDpiScalingChanged(defaultViewportContext->GetDpiScalingFactor());
|
||||
m_initialized = true;
|
||||
|
||||
Reference in New Issue
Block a user