Reviewed UWP project config
This commit is contained in:
parent
fe3256be9f
commit
75038baf71
3 changed files with 155 additions and 162 deletions
|
@ -29,6 +29,20 @@ using namespace raylibUWP;
|
|||
#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons 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
|
||||
[Platform::MTAThread]
|
||||
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
|
||||
|
||||
static bool mouseLocked = false;
|
||||
void App::Run()
|
||||
{
|
||||
// Set up our UWP implementation
|
||||
UWPSetQueryTimeFunc([]()
|
||||
{
|
||||
UWPSetQueryTimeFunc([]() {
|
||||
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);
|
||||
return time_span.count();
|
||||
});
|
||||
return time_span.count(); });
|
||||
|
||||
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
|
||||
DisplayInformation^ dInfo = DisplayInformation::GetForCurrentView();
|
||||
*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;
|
||||
});
|
||||
mouseLocked = true; });
|
||||
|
||||
UWPSetMouseShowFunc([]()
|
||||
{
|
||||
UWPSetMouseUnlockFunc([]() {
|
||||
CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
|
||||
});
|
||||
mouseLocked = false; });
|
||||
|
||||
UWPSetMouseLockFunc([]()
|
||||
{
|
||||
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
|
||||
mouseLocked = true;
|
||||
});
|
||||
|
||||
UWPSetMouseUnlockFunc([]()
|
||||
{
|
||||
CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
|
||||
mouseLocked = false;
|
||||
});
|
||||
|
||||
UWPSetMouseSetPosFunc([](int x, int y)
|
||||
{
|
||||
UWPSetMouseSetPosFunc([](int x, int y) {
|
||||
CoreWindow^ window = CoreWindow::GetForCurrentThread();
|
||||
Point mousePosScreen = Point(x + window->Bounds.X, y + window->Bounds.Y);
|
||||
window->PointerPosition = mousePosScreen;
|
||||
});
|
||||
window->PointerPosition = mousePosScreen; });
|
||||
|
||||
// Set custom output handle
|
||||
SetTraceLogCallback([](int logType, const char* text, va_list args)
|
||||
|
@ -165,7 +162,7 @@ void App::Run()
|
|||
});
|
||||
|
||||
// Create window
|
||||
InitWindow(640, 480, "raylib game example");
|
||||
InitWindow(800, 450, "raylib UWP - Basic example");
|
||||
|
||||
// Run game loop
|
||||
while (!WindowShouldClose() && !mSuspended)
|
||||
|
@ -175,8 +172,13 @@ void App::Run()
|
|||
PreProcessInputs();
|
||||
GameLoop();
|
||||
PostProcessInputs();
|
||||
|
||||
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
|
||||
} else CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
|
||||
}
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
|
@ -187,10 +189,6 @@ void App::Uninitialize()
|
|||
// Do any UWP cleanup here.
|
||||
}
|
||||
|
||||
static int posX = 100;
|
||||
static int posY = 100;
|
||||
static int gTime = 0;
|
||||
|
||||
// This method is called every frame
|
||||
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()
|
||||
{
|
||||
// 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 controlState = (sender->GetKeyState(Windows::System::VirtualKey::Control) & Windows::UI::Core::CoreVirtualKeyStates::Down) == Windows::UI::Core::CoreVirtualKeyStates::Down;
|
||||
if (k != -1) {
|
||||
UWPKeyDownEvent(k, true, controlState);
|
||||
}
|
||||
if (k != -1) UWPKeyDownEvent(k, true, controlState);
|
||||
args->Handled = true;
|
||||
}
|
||||
|
||||
void App::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
|
||||
{
|
||||
auto k = GetRaylibKey(args->VirtualKey);
|
||||
if (k != -1)
|
||||
UWPKeyDownEvent(k, false, false);
|
||||
if (k != -1) UWPKeyDownEvent(k, false, false);
|
||||
args->Handled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,28 +61,28 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<IncludePath>$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM'">
|
||||
<Link>
|
||||
|
@ -110,6 +110,9 @@
|
|||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
|
||||
<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>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkLibraryDependencies>
|
||||
|
@ -125,6 +128,9 @@
|
|||
<PreprocessorDefinitions>PLATFORM_UWP;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Default</CompileAs>
|
||||
<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>
|
||||
<Link>
|
||||
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/NODEFAULTLIB %(AdditionalOptions)</AdditionalOptions>
|
||||
|
|
|
@ -129,33 +129,33 @@
|
|||
<PropertyGroup />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)\obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)\Build\$(ProjectName)\bin\$(Configuration)\$(Platform)</OutDir>
|
||||
<IntDir>$(SolutionDir)\Build\$(ProjectName)\obj\$(Configuration)\$(Platform)</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue