Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Nov 5, 2022
1 parent d9da8da commit d2e4c95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
15 changes: 6 additions & 9 deletions DeviceResourcesPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,21 +370,15 @@ void DeviceResources::CreateWindowSizeDependentResources()
m_depthStencil.ReleaseAndGetAddressOf()
));

CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D);
ThrowIfFailed(m_d3dDevice->CreateDepthStencilView(
m_depthStencil.Get(),
&depthStencilViewDesc,
nullptr,
m_d3dDepthStencilView.ReleaseAndGetAddressOf()
));
}

// Set the 3D rendering viewport to target the entire window.
m_screenViewport = CD3D11_VIEWPORT(
0.0f,
0.0f,
static_cast<float>(backBufferWidth),
static_cast<float>(backBufferHeight)
);
m_screenViewport = { 0.0f, 0.0f, static_cast<float>(backBufferWidth), static_cast<float>(backBufferHeight), 0.f, 1.f };
}

// This method is called when the Win32 window is created (or re-created).
Expand All @@ -400,11 +394,14 @@ void DeviceResources::SetWindow(HWND window, int width, int height) noexcept
// This method is called when the Win32 window changes size
bool DeviceResources::WindowSizeChanged(int width, int height)
{
if (!m_window)
return false;

RECT newRc;
newRc.left = newRc.top = 0;
newRc.right = width;
newRc.bottom = height;
if (newRc == m_outputSize)
if (m_outputSize.right == width && m_outputSize.bottom == height)
{
// Handle color space settings for HDR
UpdateColorSpace();
Expand Down
16 changes: 12 additions & 4 deletions Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,

AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);

HWND hwnd = CreateWindowW(L"DirectXTKModelViewerWindowClass", g_szAppName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance,
nullptr);
HWND hwnd = CreateWindowExW(0, L"DirectXTKModelViewerWindowClass", g_szAppName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top,
nullptr, nullptr, hInstance,
g_game.get());
if (!hwnd)
return 1;

ShowWindow(hwnd, nCmdShow);
SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(g_game.get()) );

GetClientRect(hwnd, &rc);

Expand Down Expand Up @@ -258,6 +258,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

switch (message)
{
case WM_CREATE:
if (lParam)
{
auto params = reinterpret_cast<LPCREATESTRUCTW>(lParam);
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(params->lpCreateParams));
}
break;

case WM_PAINT:
if (s_in_sizemove && game)
{
Expand Down

0 comments on commit d2e4c95

Please sign in to comment.