You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Code/LauncherUnified/Platform/Windows/Launcher_Windows.cpp

62 lines
2.0 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Launcher.h>
#include <AzCore/Math/Vector2.h>
#include <AzCore/Memory/SystemAllocator.h>
int APIENTRY WinMain([[maybe_unused]] HINSTANCE hInstance, [[maybe_unused]] HINSTANCE hPrevInstance, [[maybe_unused]] LPSTR lpCmdLine, [[maybe_unused]] int nCmdShow)
{
InitRootDir();
using namespace O3DELauncher;
PlatformMainInfo mainInfo;
mainInfo.m_instance = GetModuleHandle(0);
mainInfo.CopyCommandLine(__argc, __argv);
// Prevent allocator from growing in small chunks
// Pre-create our system allocator and configure it to ask for larger chunks from the OS
// Creating this here to be consistent with other platforms
AZ::SystemAllocator::Descriptor sysHeapDesc;
sysHeapDesc.m_heap.m_systemChunkSize = 64 * 1024 * 1024;
AZ::AllocatorInstance<AZ::SystemAllocator>::Create(sysHeapDesc);
ReturnCode status = Run(mainInfo);
#if !defined(_RELEASE)
bool noPrompt = (strstr(mainInfo.m_commandLine, "-noprompt") != nullptr);
#else
bool noPrompt = false;
#endif // !defined(_RELEASE)
if (!noPrompt && status != ReturnCode::Success)
{
MessageBoxA(0, GetReturnCodeString(status), "Error", MB_OK | MB_DEFAULT_DESKTOP_ONLY | MB_ICONERROR);
}
// there is no way to transfer ownership of the allocator to the component application
// without altering the app descriptor, so it must be destroyed here
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
return static_cast<int>(status);
}
void CVar_OnViewportPosition(const AZ::Vector2& value)
{
if (HWND windowHandle = GetActiveWindow())
{
SetWindowPos(windowHandle, nullptr,
static_cast<int>(value.GetX()),
static_cast<int>(value.GetY()),
0, 0, SWP_NOOWNERZORDER | SWP_NOSIZE);
}
}