Reviewed UWP project config

This commit is contained in:
Ray 2021-03-13 13:08:05 +01:00
parent fe3256be9f
commit 75038baf71
3 changed files with 155 additions and 162 deletions

View file

@ -29,6 +29,20 @@ using namespace raylibUWP;
#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad) #define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad)
#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad) #define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad)
// Gamepad bindings struct
struct GamepadBinding
{
Gamepad^ Gamepad = nullptr;
bool Ready = false;
};
// Global variables
static int posX = 100;
static int posY = 100;
static int gTime = 0;
static bool mouseLocked = false;
static GamepadBinding gGamepadBindings[MAX_GAMEPADS];
// The main function creates an IFrameworkViewSource for our app, and runs the app // The main function creates an IFrameworkViewSource for our app, and runs the app
[Platform::MTAThread] [Platform::MTAThread]
int main(Platform::Array<Platform::String^>^) int main(Platform::Array<Platform::String^>^)
@ -92,55 +106,38 @@ void App::SetWindow(Windows::UI::Core::CoreWindow^ window)
void App::Load(Platform::String ^entryPoint) {} // Ignored for this example void App::Load(Platform::String ^entryPoint) {} // Ignored for this example
static bool mouseLocked = false;
void App::Run() void App::Run()
{ {
// Set up our UWP implementation // Set up our UWP implementation
UWPSetQueryTimeFunc([]() UWPSetQueryTimeFunc([]() {
{
static auto timeStart = std::chrono::high_resolution_clock::now(); static auto timeStart = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::high_resolution_clock::now() - timeStart); std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::high_resolution_clock::now() - timeStart);
return time_span.count(); return time_span.count(); });
});
UWPSetSleepFunc([](double seconds) { std::this_thread::sleep_for(std::chrono::duration<double>(seconds)); }); UWPSetSleepFunc([](double seconds) { std::this_thread::sleep_for(std::chrono::duration<double>(seconds)); });
UWPSetDisplaySizeFunc([](int* width, int* height) UWPSetDisplaySizeFunc([](int* width, int* height) {
{
// Get display dimensions // Get display dimensions
DisplayInformation^ dInfo = DisplayInformation::GetForCurrentView(); DisplayInformation^ dInfo = DisplayInformation::GetForCurrentView();
*width = dInfo->ScreenWidthInRawPixels; *width = dInfo->ScreenWidthInRawPixels;
*height = dInfo->ScreenHeightInRawPixels; *height = dInfo->ScreenHeightInRawPixels; });
});
UWPSetMouseHideFunc([]() UWPSetMouseHideFunc([]() { CoreWindow::GetForCurrentThread()->PointerCursor = nullptr; });
{
UWPSetMouseShowFunc([]() { CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); });
UWPSetMouseLockFunc([]() {
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr; CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
}); mouseLocked = true; });
UWPSetMouseShowFunc([]() UWPSetMouseUnlockFunc([]() {
{
CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
}); mouseLocked = false; });
UWPSetMouseLockFunc([]() UWPSetMouseSetPosFunc([](int x, int y) {
{
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
mouseLocked = true;
});
UWPSetMouseUnlockFunc([]()
{
CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
mouseLocked = false;
});
UWPSetMouseSetPosFunc([](int x, int y)
{
CoreWindow^ window = CoreWindow::GetForCurrentThread(); CoreWindow^ window = CoreWindow::GetForCurrentThread();
Point mousePosScreen = Point(x + window->Bounds.X, y + window->Bounds.Y); Point mousePosScreen = Point(x + window->Bounds.X, y + window->Bounds.Y);
window->PointerPosition = mousePosScreen; window->PointerPosition = mousePosScreen; });
});
// Set custom output handle // Set custom output handle
SetTraceLogCallback([](int logType, const char* text, va_list args) SetTraceLogCallback([](int logType, const char* text, va_list args)
@ -165,7 +162,7 @@ void App::Run()
}); });
// Create window // Create window
InitWindow(640, 480, "raylib game example"); InitWindow(800, 450, "raylib UWP - Basic example");
// Run game loop // Run game loop
while (!WindowShouldClose() && !mSuspended) while (!WindowShouldClose() && !mSuspended)
@ -175,8 +172,13 @@ void App::Run()
PreProcessInputs(); PreProcessInputs();
GameLoop(); GameLoop();
PostProcessInputs(); PostProcessInputs();
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
} else CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); }
else
{
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
}
} }
CloseWindow(); CloseWindow();
@ -187,10 +189,6 @@ void App::Uninitialize()
// Do any UWP cleanup here. // Do any UWP cleanup here.
} }
static int posX = 100;
static int posY = 100;
static int gTime = 0;
// This method is called every frame // This method is called every frame
void App::GameLoop() void App::GameLoop()
{ {
@ -242,14 +240,6 @@ void App::GameLoop()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
struct GamepadBinding
{
Gamepad^ Gamepad = nullptr;
bool Ready = false;
};
static GamepadBinding gGamepadBindings[MAX_GAMEPADS];
void App::PreProcessInputs() void App::PreProcessInputs()
{ {
// Here, we will see if we have bound gamepads. If we do we check they are still present. If they aren't present we free the binding. // Here, we will see if we have bound gamepads. If we do we check they are still present. If they aren't present we free the binding.
@ -555,17 +545,14 @@ void App::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::Ke
{ {
auto k = GetRaylibKey(args->VirtualKey); auto k = GetRaylibKey(args->VirtualKey);
auto controlState = (sender->GetKeyState(Windows::System::VirtualKey::Control) & Windows::UI::Core::CoreVirtualKeyStates::Down) == Windows::UI::Core::CoreVirtualKeyStates::Down; auto controlState = (sender->GetKeyState(Windows::System::VirtualKey::Control) & Windows::UI::Core::CoreVirtualKeyStates::Down) == Windows::UI::Core::CoreVirtualKeyStates::Down;
if (k != -1) { if (k != -1) UWPKeyDownEvent(k, true, controlState);
UWPKeyDownEvent(k, true, controlState);
}
args->Handled = true; args->Handled = true;
} }
void App::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) void App::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
{ {
auto k = GetRaylibKey(args->VirtualKey); auto k = GetRaylibKey(args->VirtualKey);
if (k != -1) if (k != -1) UWPKeyDownEvent(k, false, false);
UWPKeyDownEvent(k, false, false);
args->Handled = true; args->Handled = true;
} }

View file

@ -61,28 +61,28 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<IncludePath>$(IncludePath)</IncludePath> <IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath> <LibraryPath>$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM'"> <ItemDefinitionGroup Condition="'$(Platform)'=='ARM'">
<Link> <Link>
@ -110,6 +110,9 @@
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings> <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
<PreprocessorDefinitions>PLATFORM_UWP;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>PLATFORM_UWP;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile> </ClCompile>
<ProjectReference> <ProjectReference>
<LinkLibraryDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkLibraryDependencies> <LinkLibraryDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkLibraryDependencies>
@ -125,6 +128,9 @@
<PreprocessorDefinitions>PLATFORM_UWP;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>PLATFORM_UWP;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Default</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Default</CompileAs>
<OmitDefaultLibName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</OmitDefaultLibName> <OmitDefaultLibName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</OmitDefaultLibName>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">MultiThreadedDLL</RuntimeLibrary>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MultiThreadedDLL</RuntimeLibrary>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MultiThreadedDLL</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>

View file

@ -129,33 +129,33 @@
<PropertyGroup /> <PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<GenerateManifest>false</GenerateManifest> <GenerateManifest>false</GenerateManifest>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<GenerateManifest>false</GenerateManifest> <GenerateManifest>false</GenerateManifest>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<GenerateManifest>false</GenerateManifest> <GenerateManifest>false</GenerateManifest>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<GenerateManifest>false</GenerateManifest> <GenerateManifest>false</GenerateManifest>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<GenerateManifest>false</GenerateManifest> <GenerateManifest>false</GenerateManifest>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<GenerateManifest>false</GenerateManifest> <GenerateManifest>false</GenerateManifest>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>