From e604fe1ace1f5cb4b771172a3bcd50feafd25457 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 19 Jan 2018 13:07:32 +0100 Subject: [PATCH] Added VS2017 UWP project Reviewed VS2015 UWP project --- .../raylib.App.UWP/Package.appxmanifest | 36 +- project/vs2015.UWP/raylib/raylib.vcxproj | 8 +- project/vs2017.UWP/raylib.App.UWP/App.cpp | 558 ++++++++++++++++++ project/vs2017.UWP/raylib.App.UWP/App.h | 49 ++ .../raylib.App.UWP/Assets/Logo.scale-100.png | Bin 0 -> 801 bytes .../Assets/SmallLogo.scale-100.png | Bin 0 -> 329 bytes .../Assets/SplashScreen.scale-100.png | Bin 0 -> 2146 bytes .../Assets/StoreLogo.scale-100.png | Bin 0 -> 429 bytes .../Assets/WideLogo.scale-100.png | Bin 0 -> 2150 bytes .../raylib.App.UWP/Package.appxmanifest | 26 + .../vs2017.UWP/raylib.App.UWP/packages.config | 4 + project/vs2017.UWP/raylib.App.UWP/pch.cpp | 1 + project/vs2017.UWP/raylib.App.UWP/pch.h | 16 + .../raylib.App.UWP.TemporaryKey.pfx | Bin 0 -> 2512 bytes .../raylib.App.UWP/raylib.App.UWP.filters | 42 ++ .../raylib.App.UWP/raylib.App.UWP.user | 4 + 16 files changed, 711 insertions(+), 33 deletions(-) create mode 100644 project/vs2017.UWP/raylib.App.UWP/App.cpp create mode 100644 project/vs2017.UWP/raylib.App.UWP/App.h create mode 100644 project/vs2017.UWP/raylib.App.UWP/Assets/Logo.scale-100.png create mode 100644 project/vs2017.UWP/raylib.App.UWP/Assets/SmallLogo.scale-100.png create mode 100644 project/vs2017.UWP/raylib.App.UWP/Assets/SplashScreen.scale-100.png create mode 100644 project/vs2017.UWP/raylib.App.UWP/Assets/StoreLogo.scale-100.png create mode 100644 project/vs2017.UWP/raylib.App.UWP/Assets/WideLogo.scale-100.png create mode 100644 project/vs2017.UWP/raylib.App.UWP/Package.appxmanifest create mode 100644 project/vs2017.UWP/raylib.App.UWP/packages.config create mode 100644 project/vs2017.UWP/raylib.App.UWP/pch.cpp create mode 100644 project/vs2017.UWP/raylib.App.UWP/pch.h create mode 100644 project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.TemporaryKey.pfx create mode 100644 project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.filters create mode 100644 project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.user diff --git a/project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest b/project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest index dbd8121ad..f0f568628 100644 --- a/project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest +++ b/project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest @@ -1,47 +1,25 @@  - - - - - - - + + + - UWP_OpenGLES2 + raylibUWP Alumno Assets\StoreLogo.png - - - + - - - + + - diff --git a/project/vs2015.UWP/raylib/raylib.vcxproj b/project/vs2015.UWP/raylib/raylib.vcxproj index d48e62600..32e59759b 100644 --- a/project/vs2015.UWP/raylib/raylib.vcxproj +++ b/project/vs2015.UWP/raylib/raylib.vcxproj @@ -22,13 +22,13 @@ {E89D61AC-55DE-4482-AFD4-DF7242EBC859} Win32Proj raylib - 8.1 + 10.0.16299.0 StaticLibrary true - v140 + v141 Unicode @@ -85,7 +85,7 @@ Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP CompileAsC - $(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\include\ANGLE + $(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\ANGLE Windows @@ -120,7 +120,7 @@ true true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP - $(SolutionDir)..\..\src\external\include\ANGLE;$(SolutionDir)..\..\release\include + $(SolutionDir)..\..\src\external\ANGLE;$(SolutionDir)..\..\release\include CompileAsC diff --git a/project/vs2017.UWP/raylib.App.UWP/App.cpp b/project/vs2017.UWP/raylib.App.UWP/App.cpp new file mode 100644 index 000000000..375b668c0 --- /dev/null +++ b/project/vs2017.UWP/raylib.App.UWP/App.cpp @@ -0,0 +1,558 @@ +#include "pch.h" +#include "app.h" + +#include "raylib.h" + +using namespace Windows::ApplicationModel::Core; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::UI::Core; +using namespace Windows::UI::Input; +using namespace Windows::Devices::Input; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::Gaming::Input; +using namespace Windows::Graphics::Display; +using namespace Microsoft::WRL; +using namespace Platform; + +using namespace raylibUWP; + +/* +To-do list + - Cache reference to our CoreWindow? + - Implement gestures +*/ + +/* INPUT CODE */ +// Stand-ins for "core.c" variables +#define MAX_GAMEPADS 4 // Max number of gamepads supported +#define MAX_GAMEPAD_BUTTONS 32 // Max bumber of buttons supported (per gamepad) +#define MAX_GAMEPAD_AXIS 8 // Max number of axis supported (per gamepad) +static bool gamepadReady[MAX_GAMEPADS] = { false }; // Flag to know if gamepad is ready +static float gamepadAxisState[MAX_GAMEPADS][MAX_GAMEPAD_AXIS]; // Gamepad axis state +static char previousGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state +static char currentGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Current gamepad buttons state + +static char previousKeyState[512] = { 0 }; // Contains previous frame keyboard state +static char currentKeyState[512] = { 0 }; // Contains current frame keyboard state + +//... +static char previousMouseState[3] = { 0 }; // Registers previous mouse button state +static char currentMouseState[3] = { 0 }; // Registers current mouse button state +static int previousMouseWheelY = 0; // Registers previous mouse wheel variation +static int currentMouseWheelY = 0; // Registers current mouse wheel variation + +static bool cursorOnScreen = false; // Tracks if cursor is inside client area +static bool cursorHidden = false; // Track if cursor is hidden + +static Vector2 mousePosition; +static Vector2 mouseDelta; // NOTE: Added to keep track of mouse movement while the cursor is locked - no equivalent in "core.c" +static bool toggleCursorLock; + +CoreCursor ^regularCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); // The "visible arrow" cursor type + +// Helper to process key events +void ProcessKeyEvent(Windows::System::VirtualKey key, int action) +{ + using Windows::System::VirtualKey; + switch (key) + { + case VirtualKey::Space: currentKeyState[KEY_SPACE] = action; break; + case VirtualKey::Escape: currentKeyState[KEY_ESCAPE] = action; break; + case VirtualKey::Enter: currentKeyState[KEY_ENTER] = action; break; + case VirtualKey::Delete: currentKeyState[KEY_BACKSPACE] = action; break; + case VirtualKey::Right: currentKeyState[KEY_RIGHT] = action; break; + case VirtualKey::Left: currentKeyState[KEY_LEFT] = action; break; + case VirtualKey::Down: currentKeyState[KEY_DOWN] = action; break; + case VirtualKey::Up: currentKeyState[KEY_UP] = action; break; + case VirtualKey::F1: currentKeyState[KEY_F1] = action; break; + case VirtualKey::F2: currentKeyState[KEY_F2] = action; break; + case VirtualKey::F3: currentKeyState[KEY_F4] = action; break; + case VirtualKey::F4: currentKeyState[KEY_F5] = action; break; + case VirtualKey::F5: currentKeyState[KEY_F6] = action; break; + case VirtualKey::F6: currentKeyState[KEY_F7] = action; break; + case VirtualKey::F7: currentKeyState[KEY_F8] = action; break; + case VirtualKey::F8: currentKeyState[KEY_F9] = action; break; + case VirtualKey::F9: currentKeyState[KEY_F10] = action; break; + case VirtualKey::F10: currentKeyState[KEY_F11] = action; break; + case VirtualKey::F11: currentKeyState[KEY_F12] = action; break; + case VirtualKey::LeftShift: currentKeyState[KEY_LEFT_SHIFT] = action; break; + case VirtualKey::LeftControl: currentKeyState[KEY_LEFT_CONTROL] = action; break; + case VirtualKey::LeftMenu: currentKeyState[KEY_LEFT_ALT] = action; break; // NOTE: Potential UWP bug with Alt key: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/9bebfb0a-7637-400e-8bda-e55620091407/unexpected-behavior-in-windowscoreuicorephysicalkeystatusismenukeydown + case VirtualKey::RightShift: currentKeyState[KEY_RIGHT_SHIFT] = action; break; + case VirtualKey::RightControl: currentKeyState[KEY_RIGHT_CONTROL] = action; break; + case VirtualKey::RightMenu: currentKeyState[KEY_RIGHT_ALT] = action; break; + case VirtualKey::Number0: currentKeyState[KEY_ZERO] = action; break; + case VirtualKey::Number1: currentKeyState[KEY_ONE] = action; break; + case VirtualKey::Number2: currentKeyState[KEY_TWO] = action; break; + case VirtualKey::Number3: currentKeyState[KEY_THREE] = action; break; + case VirtualKey::Number4: currentKeyState[KEY_FOUR] = action; break; + case VirtualKey::Number5: currentKeyState[KEY_FIVE] = action; break; + case VirtualKey::Number6: currentKeyState[KEY_SIX] = action; break; + case VirtualKey::Number7: currentKeyState[KEY_SEVEN] = action; break; + case VirtualKey::Number8: currentKeyState[KEY_EIGHT] = action; break; + case VirtualKey::Number9: currentKeyState[KEY_NINE] = action; break; + case VirtualKey::A: currentKeyState[KEY_A] = action; break; + case VirtualKey::B: currentKeyState[KEY_B] = action; break; + case VirtualKey::C: currentKeyState[KEY_C] = action; break; + case VirtualKey::D: currentKeyState[KEY_D] = action; break; + case VirtualKey::E: currentKeyState[KEY_E] = action; break; + case VirtualKey::F: currentKeyState[KEY_F] = action; break; + case VirtualKey::G: currentKeyState[KEY_G] = action; break; + case VirtualKey::H: currentKeyState[KEY_H] = action; break; + case VirtualKey::I: currentKeyState[KEY_I] = action; break; + case VirtualKey::J: currentKeyState[KEY_J] = action; break; + case VirtualKey::K: currentKeyState[KEY_K] = action; break; + case VirtualKey::L: currentKeyState[KEY_L] = action; break; + case VirtualKey::M: currentKeyState[KEY_M] = action; break; + case VirtualKey::N: currentKeyState[KEY_N] = action; break; + case VirtualKey::O: currentKeyState[KEY_O] = action; break; + case VirtualKey::P: currentKeyState[KEY_P] = action; break; + case VirtualKey::Q: currentKeyState[KEY_Q] = action; break; + case VirtualKey::R: currentKeyState[KEY_R] = action; break; + case VirtualKey::S: currentKeyState[KEY_S] = action; break; + case VirtualKey::T: currentKeyState[KEY_T] = action; break; + case VirtualKey::U: currentKeyState[KEY_U] = action; break; + case VirtualKey::V: currentKeyState[KEY_V] = action; break; + case VirtualKey::W: currentKeyState[KEY_W] = action; break; + case VirtualKey::X: currentKeyState[KEY_X] = action; break; + case VirtualKey::Y: currentKeyState[KEY_Y] = action; break; + case VirtualKey::Z: currentKeyState[KEY_Z] = action; break; + + } +} + +/* CALLBACKS */ +void App::PointerPressed(CoreWindow^ window, PointerEventArgs^ args) +{ + if (args->CurrentPoint->Properties->IsLeftButtonPressed) + { + currentMouseState[MOUSE_LEFT_BUTTON] = 1; + } + if (args->CurrentPoint->Properties->IsRightButtonPressed) + { + currentMouseState[MOUSE_RIGHT_BUTTON] = 1; + } + if (args->CurrentPoint->Properties->IsMiddleButtonPressed) + { + currentMouseState[MOUSE_MIDDLE_BUTTON] = 1; + } +} + +void App::PointerReleased(CoreWindow ^window, PointerEventArgs^ args) +{ + if (!(args->CurrentPoint->Properties->IsLeftButtonPressed)) + { + currentMouseState[MOUSE_LEFT_BUTTON] = 0; + } + if (!(args->CurrentPoint->Properties->IsRightButtonPressed)) + { + currentMouseState[MOUSE_RIGHT_BUTTON] = 0; + } + if (!(args->CurrentPoint->Properties->IsMiddleButtonPressed)) + { + currentMouseState[MOUSE_MIDDLE_BUTTON] = 0; + } +} + +void App::PointerWheelChanged(CoreWindow ^window, PointerEventArgs^ args) +{ + // TODO: Scale the MouseWheelDelta to match GLFW's mouse wheel sensitivity. + currentMouseWheelY += args->CurrentPoint->Properties->MouseWheelDelta; +} + +void App::MouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args) +{ + mouseDelta.x += args->MouseDelta.X; + mouseDelta.y += args->MouseDelta.Y; +} + +void App::OnKeyDown(CoreWindow ^ sender, KeyEventArgs ^ args) +{ + ProcessKeyEvent(args->VirtualKey, 1); +} + +void App::OnKeyUp(CoreWindow ^ sender, KeyEventArgs ^ args) +{ + ProcessKeyEvent(args->VirtualKey, 0); +} + +/* REIMPLEMENTED FROM CORE.C */ +// Get one key state +static bool GetKeyStatus(int key) +{ + return currentKeyState[key]; +} + +// Show mouse cursor +void UWPShowCursor() +{ + CoreWindow::GetForCurrentThread()->PointerCursor = regularCursor; + cursorHidden = false; +} + +// Hides mouse cursor +void UWPHideCursor() +{ + CoreWindow::GetForCurrentThread()->PointerCursor = nullptr; + cursorHidden = true; +} + +// Set mouse position XY +void UWPSetMousePosition(Vector2 position) +{ + CoreWindow ^window = CoreWindow::GetForCurrentThread(); + Point mousePosScreen = Point(position.x + window->Bounds.X, position.y + window->Bounds.Y); + window->PointerPosition = mousePosScreen; + mousePosition = position; +} +// Enables cursor (unlock cursor) +void UWPEnableCursor() +{ + UWPShowCursor(); + UWPSetMousePosition(mousePosition); // The mouse is hidden in the center of the screen - move it to where it should appear + toggleCursorLock = false; +} + +// Disables cursor (lock cursor) +void UWPDisableCursor() +{ + UWPHideCursor(); + toggleCursorLock = true; +} + +// Get one mouse button state +static bool UWPGetMouseButtonStatus(int button) +{ + return currentMouseState[button]; +} + +// Poll (store) all input events +void UWP_PollInput() +{ + // Register previous keyboard state + for (int k = 0; k < 512; k++) previousKeyState[k] = currentKeyState[k]; + + // Process Mouse + { + // Register previous mouse states + for (int i = 0; i < 3; i++) previousMouseState[i] = currentMouseState[i]; + previousMouseWheelY = currentMouseWheelY; + currentMouseWheelY = 0; + + CoreWindow ^window = CoreWindow::GetForCurrentThread(); + if (toggleCursorLock) + { + // Track cursor movement delta, recenter it on the client + mousePosition.x += mouseDelta.x; + mousePosition.y += mouseDelta.y; + + // Why we're not using UWPSetMousePosition here... + // UWPSetMousePosition changes the "mousePosition" variable to match where the cursor actually is. + // Our cursor is locked to the middle of screen, and we don't want that reflected in "mousePosition" + Vector2 centerClient = { (float)(GetScreenWidth() / 2), (float)(GetScreenHeight() / 2) }; + window->PointerPosition = Point(centerClient.x + window->Bounds.X, centerClient.y + window->Bounds.Y); + } + else + { + // Record the cursor's position relative to the client + mousePosition.x = window->PointerPosition.X - window->Bounds.X; + mousePosition.y = window->PointerPosition.Y - window->Bounds.Y; + } + + mouseDelta = { 0 ,0 }; + } + + // Process Gamepads + { + // Check if gamepads are ready + for (int i = 0; i < MAX_GAMEPADS; i++) + { + // HACK: UWP keeps a contiguous list of gamepads. For the interest of time I'm just doing a 1:1 mapping of + // connected gamepads with their spot in the list, but this has serious robustness problems + // e.g. player 1, 2, and 3 are playing a game - if player2 disconnects, p3's controller would now be mapped to p2's character since p3 is now second in the list. + + gamepadReady[i] = (i < Gamepad::Gamepads->Size); + } + + // Get current gamepad state + for (int i = 0; i < MAX_GAMEPADS; i++) + { + if (gamepadReady[i]) + { + // Register previous gamepad states + for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) previousGamepadState[i][k] = currentGamepadState[i][k]; + + // Get current gamepad state + auto gamepad = Gamepad::Gamepads->GetAt(i); + GamepadReading reading = gamepad->GetCurrentReading(); + + // NOTE: Maybe it would be wiser to redefine the gamepad button mappings in "raylib.h" for the UWP platform instead of remapping them manually + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_A] = ((reading.Buttons & GamepadButtons::A) == GamepadButtons::A); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_B] = ((reading.Buttons & GamepadButtons::B) == GamepadButtons::B); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_X] = ((reading.Buttons & GamepadButtons::X) == GamepadButtons::X); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_Y] = ((reading.Buttons & GamepadButtons::Y) == GamepadButtons::Y); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_LB] = ((reading.Buttons & GamepadButtons::LeftShoulder) == GamepadButtons::LeftShoulder); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_RB] = ((reading.Buttons & GamepadButtons::RightShoulder) == GamepadButtons::RightShoulder); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_SELECT] = ((reading.Buttons & GamepadButtons::View) == GamepadButtons::View); // Changed for XB1 Controller + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_START] = ((reading.Buttons & GamepadButtons::Menu) == GamepadButtons::Menu); // Changed for XB1 Controller + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_UP] = ((reading.Buttons & GamepadButtons::DPadUp) == GamepadButtons::DPadUp); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_RIGHT] = ((reading.Buttons & GamepadButtons::DPadRight) == GamepadButtons::DPadRight); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_DOWN] = ((reading.Buttons & GamepadButtons::DPadLeft) == GamepadButtons::DPadDown); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_LEFT] = ((reading.Buttons & GamepadButtons::DPadDown) == GamepadButtons::DPadLeft); + currentGamepadState[i][GAMEPAD_XBOX_BUTTON_HOME] = false; // Home button not supported by UWP + + // Get current axis state + gamepadAxisState[i][GAMEPAD_XBOX_AXIS_LEFT_X] = reading.LeftThumbstickX; + gamepadAxisState[i][GAMEPAD_XBOX_AXIS_LEFT_Y] = reading.LeftThumbstickY; + gamepadAxisState[i][GAMEPAD_XBOX_AXIS_RIGHT_X] = reading.RightThumbstickX; + gamepadAxisState[i][GAMEPAD_XBOX_AXIS_RIGHT_Y] = reading.RightThumbstickY; + gamepadAxisState[i][GAMEPAD_XBOX_AXIS_LT] = reading.LeftTrigger; + gamepadAxisState[i][GAMEPAD_XBOX_AXIS_RT] = reading.RightTrigger; + } + } + } + +} + +// The following functions were ripped from core.c and have *no additional work done on them* +// Detect if a key has been pressed once +bool UWPIsKeyPressed(int key) +{ + bool pressed = false; + + if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) + pressed = true; + else pressed = false; + + return pressed; +} + +// Detect if a key is being pressed (key held down) +bool UWPIsKeyDown(int key) +{ + if (GetKeyStatus(key) == 1) return true; + else return false; +} + +// Detect if a key has been released once +bool UWPIsKeyReleased(int key) +{ + bool released = false; + + if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 0)) released = true; + else released = false; + + return released; +} + +// Detect if a key is NOT being pressed (key not held down) +bool UWPIsKeyUp(int key) +{ + if (GetKeyStatus(key) == 0) return true; + else return false; +} + +/* OTHER CODE */ + +// Helper to convert a length in device-independent pixels (DIPs) to a length in physical pixels. +inline float ConvertDipsToPixels(float dips, float dpi) +{ + static const float dipsPerInch = 96.0f; + return floor(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer. +} + +// Implementation of the IFrameworkViewSource interface, necessary to run our app. +ref class SimpleApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource +{ +public: + virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView() + { + return ref new App(); + } +}; + +// The main function creates an IFrameworkViewSource for our app, and runs the app. +[Platform::MTAThread] +int main(Platform::Array^) +{ + auto simpleApplicationSource = ref new SimpleApplicationSource(); + CoreApplication::Run(simpleApplicationSource); + + return 0; +} + +App::App() : + mWindowClosed(false), + mWindowVisible(true) +{ +} + +// The first method called when the IFrameworkView is being created. +void App::Initialize(CoreApplicationView^ applicationView) +{ + // Register event handlers for app lifecycle. This example includes Activated, so that we + // can make the CoreWindow active and start rendering on the window. + applicationView->Activated += ref new TypedEventHandler(this, &App::OnActivated); + + // Logic for other event handlers could go here. + // Information about the Suspending and Resuming event handlers can be found here: + // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx + + CoreApplication::Resuming += ref new EventHandler(this, &App::OnResuming); +} + +// Called when the CoreWindow object is created (or re-created). +void App::SetWindow(CoreWindow^ window) +{ + window->SizeChanged += ref new TypedEventHandler(this, &App::OnWindowSizeChanged); + window->VisibilityChanged += ref new TypedEventHandler(this, &App::OnVisibilityChanged); + window->Closed += ref new TypedEventHandler(this, &App::OnWindowClosed); + + window->PointerPressed += ref new TypedEventHandler(this, &App::PointerPressed); + window->PointerReleased += ref new TypedEventHandler(this, &App::PointerReleased); + window->PointerWheelChanged += ref new TypedEventHandler(this, &App::PointerWheelChanged); + window->KeyDown += ref new TypedEventHandler(this, &App::OnKeyDown); + window->KeyUp += ref new TypedEventHandler(this, &App::OnKeyUp); + + Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += ref new TypedEventHandler(this, &App::MouseMoved); + + DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); + currentDisplayInformation->DpiChanged += ref new TypedEventHandler(this, &App::OnDpiChanged); + currentDisplayInformation->OrientationChanged += ref new TypedEventHandler(this, &App::OnOrientationChanged); + + // The CoreWindow has been created, so EGL can be initialized. + InitWindow(800, 450, (EGLNativeWindowType)window); +} + +// Initializes scene resources +void App::Load(Platform::String^ entryPoint) +{ + // InitWindow() --> rlglInit() +} + +static int posX = 100; +static int posY = 100; +static int time = 0; +// This method is called after the window becomes active. +void App::Run() +{ + while (!mWindowClosed) + { + if (mWindowVisible) + { + // Draw + BeginDrawing(); + + ClearBackground(RAYWHITE); + + + posX += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_X] * 5; + posY += gamepadAxisState[GAMEPAD_PLAYER1][GAMEPAD_XBOX_AXIS_LEFT_Y] * -5; + DrawRectangle(posX, posY, 400, 100, RED); + + DrawLine(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); + + DrawCircle(mousePosition.x, mousePosition.y, 40, BLUE); + + if(UWPIsKeyDown(KEY_S)) + { + DrawCircle(100, 100, 100, BLUE); + } + + if(UWPIsKeyPressed(KEY_A)) + { + posX -= 50; + UWPEnableCursor(); + } + if (UWPIsKeyPressed(KEY_D)) + { + posX += 50; + + UWPDisableCursor(); + } + + if(currentKeyState[KEY_LEFT_ALT]) + DrawRectangle(250, 250, 20, 20, BLACK); + if (currentKeyState[KEY_BACKSPACE]) + DrawRectangle(280, 250, 20, 20, BLACK); + + if (currentMouseState[MOUSE_LEFT_BUTTON]) + DrawRectangle(280, 250, 20, 20, BLACK); + + static int pos = 0; + pos -= currentMouseWheelY; + DrawRectangle(280, pos + 50, 20, 20, BLACK); + + DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE); + + EndDrawing(); + UWP_PollInput(); + + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); + } + else + { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); + } + } + + CloseWindow(); +} + +// Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView +// class is torn down while the app is in the foreground. +void App::Uninitialize() +{ + // CloseWindow(); +} + +// Application lifecycle event handler. +void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) +{ + // Run() won't start until the CoreWindow is activated. + CoreWindow::GetForCurrentThread()->Activate(); +} + +void App::OnResuming(Object^ sender, Object^ args) +{ + // Restore any data or state that was unloaded on suspend. By default, data + // and state are persisted when resuming from suspend. Note that this event + // does not occur if the app was previously terminated. +} + +void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args) +{ + // TODO: Update window and render area size + //m_deviceResources->SetLogicalSize(Size(sender->Bounds.Width, sender->Bounds.Height)); + //m_main->UpdateForWindowSizeChange(); +} + +// Window event handlers. +void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) +{ + mWindowVisible = args->Visible; + + // raylib core has the variable windowMinimized to register state, + // it should be modifyed by this event... +} + +void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) +{ + mWindowClosed = true; + + // raylib core has the variable windowShouldClose to register state, + // it should be modifyed by this event... +} + +void App::OnDpiChanged(DisplayInformation^ sender, Object^ args) +{ + //m_deviceResources->SetDpi(sender->LogicalDpi); + //m_main->UpdateForWindowSizeChange(); +} + +void App::OnOrientationChanged(DisplayInformation^ sender, Object^ args) +{ + //m_deviceResources->SetCurrentOrientation(sender->CurrentOrientation); + //m_main->UpdateForWindowSizeChange(); +} diff --git a/project/vs2017.UWP/raylib.App.UWP/App.h b/project/vs2017.UWP/raylib.App.UWP/App.h new file mode 100644 index 000000000..5b58528ba --- /dev/null +++ b/project/vs2017.UWP/raylib.App.UWP/App.h @@ -0,0 +1,49 @@ +#pragma once + +#include + +#include "pch.h" + +namespace raylibUWP +{ + ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView + { + public: + App(); + + // IFrameworkView Methods. + virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); + virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); + virtual void Load(Platform::String^ entryPoint); + virtual void Run(); + virtual void Uninitialize(); + + protected: + + // Application lifecycle event handlers. + void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); + void OnResuming(Platform::Object^ sender, Platform::Object^ args); + + // Window event handlers. + void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); + void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); + void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args); + + // DisplayInformation event handlers. + void OnDpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); + void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); + + // Input event handlers + void PointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); + void PointerReleased(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args); + void PointerWheelChanged(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args); + void MouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args); + void OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args); + void OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args); + + private: + + bool mWindowClosed; + bool mWindowVisible; + }; +} diff --git a/project/vs2017.UWP/raylib.App.UWP/Assets/Logo.scale-100.png b/project/vs2017.UWP/raylib.App.UWP/Assets/Logo.scale-100.png new file mode 100644 index 0000000000000000000000000000000000000000..e26771cb33a49bbef824aa333737181b0a5b09a3 GIT binary patch literal 801 zcmeAS@N?(olHy`uVBq!ia0vp^(?FPm4M^HB7Cr(}k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m=1foIEGZ*dUJQLud<^=L*gE#63Ho!PGzwUb%GPK6&5iF zt!p@aGNX}6(PVh|N)M-?0RNcTbjaWgEU8noxUax-n>&3Ay)#!y&O11y2sKEF zt72@XC1)RvT6Xw=y_`Ce)`nGULLL^lI$kwi^E+dQT7YeXY4GvlRR%kj1x$VZi%Bdd zz}2Giy=-_$h+v#(S+};)DuE4EM?_^qB_eDeo@&q%StD1F>L|*0ZC2sb-}llSMTM?O z6{b3iid~yk@VE7q7Wb+P8?H5IYp?pSVcLE~18m#ygK20HL@6W5woI~Fjlw$fX1U{xQA5a+t0 zH$WNIb=fNpWHo}M9#;K6eszDZKty_|-?j4iocj5#zotrWc;@;w`H@=mjsvS2wXX0_ zY}l$4@^sE?UcC)ji*L=Z&}P!xaL&2((OQlj2dv~pV-ifAS;ZsH1{`D!GY%yys5WH)f>ZLo5m%6XjuXdbKMR7MEHSyb{m!_{Afji&MT$_sz7 z>1{~MlIFe28FRN(GC_~;#Jp4ADipP+9hh|P#-&`vO-Upt3jE0@YLh(^55uYWl9g)Z RA3>Rb!PC{xWt~$(69A&hN*MqE literal 0 HcmV?d00001 diff --git a/project/vs2017.UWP/raylib.App.UWP/Assets/SmallLogo.scale-100.png b/project/vs2017.UWP/raylib.App.UWP/Assets/SmallLogo.scale-100.png new file mode 100644 index 0000000000000000000000000000000000000000..1eb0d9d528c42f132872e8af4dc563081b0b9aff GIT binary patch literal 329 zcmV-P0k-~$P)q$gGRCwC#*X;?zAP@%N+|i#I!$mrh zlQ>KU$Rdu>|JH&931_?y6Djl{gb>4nCV5pzDJ?S!mq|4ZejKj%i@j$H{#ML~2Y{DF z$=}bKPaz+UGt{v(4CTQQXym}&iW8{s!ew~XIE7NLjQpy#I2S$rous$~?f%DHT#B*+ zq=#!zc5=0FEqWFpB%UE(L807on!pidHPLgYO}XEgorrg;PB=8ipgQ5u5`&g_MQaRd zaU7Ao8XQMuuN21-s0PPTs1%38x_Yl3Fs-|Y4!C-;M-8g@n*v@1|s#GQ665=9@Rxy?u0YW0&WN+~=RXpPbVXXL4m7Aq=E6I0%{06TwRn=U9d8>exk> zD-Z%M3DNQ`bTLSEF=%NFyoHcAkD*CiXqljo*0E?o$GiDC4q}}|%*0WghLlK#npw?hecrM}Mw?`E(z5C8< z8&*b^!{>5?4aT89vdrgBgSc-x6JZD3F^l#*G(@OO*^1D%Eu7?HAy<3kTLqW9N{^#6vso zVQwY48q7)m{~xQ64RV7{E7Y=&T~?^05Ky`5oNQ8bLgFCPq9co^R09BVRS1OAmH;hU zC#q(N!gNqm!zU#%sv{r5mm-Uv8b-~a1F-;p^>)pnXfKge4s9?;;MFIr*fixPG}NBA z6_G5BEmeO6XXh(emkciB{7tA;iwC2^s^VzyU_h0@ae84ACMY`cIDEju=<`q|2QAEv zW_)W|i|9aknqdmS=#w73eW_csQ$8IhT^vY1^1;X3&J0{%*tcQq!gJpr3w?TJc~@5= zKV5sM{$3k>b#S$@CTkhIF*{v*u(F&$&Yq1naHxt8Mz2N%7aQ3(^VNRZahk1||7?Bl z*idzO_u)FhRj4cPzDO>YA>>lxAGaciEiX8Xzp1SVPv91};$OG3cC&8!v3{Jq^kH@8 UTIccK;hzT5*3#}uZuEx!0OwrBv;Y7A literal 0 HcmV?d00001 diff --git a/project/vs2017.UWP/raylib.App.UWP/Assets/StoreLogo.scale-100.png b/project/vs2017.UWP/raylib.App.UWP/Assets/StoreLogo.scale-100.png new file mode 100644 index 0000000000000000000000000000000000000000..dcb672712c6823a0c91548ded70a8acb85536b4d GIT binary patch literal 429 zcmV;e0aE^nP)NtYJa1l)bQ5qwGXpZbs7%2oRMd4y35$s&66(fxhNg8W02!vSn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#U{wSc`jPWA*d>CkNgc@jKRGZw{T zYY-b^twjUKEW^f1G8RS2ZIGM8wRI`E3#fatE)}==ZJ6mPQ)ZqA5u^7g;>x;vxi&G! z`!dZvXaTWyV>higq@MzJXi10+%WS|1D8sXZC^F*;ygu~E?L<&84u{}((#>+XfcLea zj#?ojMP#mG9t$_`=f1OtuP!obr$bZI-VTquTA4$;7dlKW<8LCkW4lBZ*O)rmZTLe+ zo1-Y!)tvS|?0Eraxv;N`^P8yEM=|=cBx*h_{R{T>%jb)Qz;iugTGnHldHwc&=MZ2; xJ}0F|Sf88oi>EL3`G1{Z|MDC?5Z*eEbmw_S^{I|Wg1-UKp2(Pprrqh^{0*n}B{Tp4 literal 0 HcmV?d00001 diff --git a/project/vs2017.UWP/raylib.App.UWP/Package.appxmanifest b/project/vs2017.UWP/raylib.App.UWP/Package.appxmanifest new file mode 100644 index 000000000..f0f568628 --- /dev/null +++ b/project/vs2017.UWP/raylib.App.UWP/Package.appxmanifest @@ -0,0 +1,26 @@ + + + + + + raylibUWP + Alumno + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/vs2017.UWP/raylib.App.UWP/packages.config b/project/vs2017.UWP/raylib.App.UWP/packages.config new file mode 100644 index 000000000..70c3dea0e --- /dev/null +++ b/project/vs2017.UWP/raylib.App.UWP/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/project/vs2017.UWP/raylib.App.UWP/pch.cpp b/project/vs2017.UWP/raylib.App.UWP/pch.cpp new file mode 100644 index 000000000..bcb5590be --- /dev/null +++ b/project/vs2017.UWP/raylib.App.UWP/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" diff --git a/project/vs2017.UWP/raylib.App.UWP/pch.h b/project/vs2017.UWP/raylib.App.UWP/pch.h new file mode 100644 index 000000000..dcbd23785 --- /dev/null +++ b/project/vs2017.UWP/raylib.App.UWP/pch.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +// OpenGL ES includes +#include +#include + +// EGL includes +#include +#include +#include + +// ANGLE include for Windows Store +#include \ No newline at end of file diff --git a/project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.TemporaryKey.pfx b/project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.TemporaryKey.pfx new file mode 100644 index 0000000000000000000000000000000000000000..0ada3be0187f9bb2285ade2c7a7200c7401c41bc GIT binary patch literal 2512 zcmZXUc{tST9>9MyW`-F|N65bK#xlkpg`~m3QMOx&kR=g@A={xLXQnL4&RDYV`*LO^ z)F9JHE(tkg$r2_@mPnoHJoldS+~+>;^W8q*<$eEozi0xS0S2+532-6|uAE?=u+I%* z2Ne3oMz1asH=^3jqQb5g^~t1jr#;6o&XOW(`L| zIPUyxcs`tJrUVAFzlIPX6K3%?;vq)WD7u}{7g$?mD6AM7LO(%oaw~IDY-bR>xo|36 z9{oJGR!ZJ!eqW-Wih+jeKW+&yFKJAJe8LXxMbc;K4gzB8_-@%$fdIo4xIo(c)h5*Z zN(G~)tPTkiE~N1TG_ihPZFMAG7wz9 zT|EgzFw>;BmSwzmZkx_M{V2MXB!x=3vlKKZ&56}$JDPkk-_;hXQZbp=vM@zSEZt7Z z^;_36Gk(&PZ$BOqJ8V)`;zd&$Of+{Rg}mPH_n=&eE@l6eos8ys%P2;VRCP!mBJ;1h z8})thSU>yWiF97wVwK#vV~(vnqg7X!P$rZI(jTy`Qk2MS<-0J$-r6dhe7{k7YFsTV zmilo)?Y1$0RN;Bzds-|iOnWCSx;3!_W47nWwb>(Bnb>6Q?uoz=6jeQgH5FQVI^VzTEgJF7H(5vvGAd z+|P4AmG;^eRm1XJo@QLPOt{|J;On;cjW%M|(Oz`$!e4u3uktwkTwyZT=i>nR*cJHj zsFqzl#;JbH4mz~m#ni+0UG@{0f zs##W1Oa(nLB5w(YeZGlLNS-!j z@Nnjd#}IgkdE1H07YPy1U?hgdVib$@4iGrod6eAOeI#w(TKF((uQk0+(me5AB_X8d zjkTdko#YU(gN*5zfJT+D4Fp|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rPc=>`x%co47^h;HAuyk zD0++;?wG8UX5UAqMEG_=2cMO$ybO7sHWbNeERMf)8a{Is`#?z;)@+|E&(&}F`(OsT zjTfW$BotcjcJ1fp{G-TnIirrWv(j^u{@1RAPkd6RNNn@4ndR3X8@|LFW4cEKuQTui zf%S>MBBI1jqbDQ=uxJCc1ezTNMIqV1!Vtc=V<)~`fo0_ucD|K>8U?SJGByziUzBLT YG2F`Z(uo5~&L~gs>KoEr;g65@C-mBMcK`qY literal 0 HcmV?d00001 diff --git a/project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.filters b/project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.filters new file mode 100644 index 000000000..4e83c9790 --- /dev/null +++ b/project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.filters @@ -0,0 +1,42 @@ + + + + + + + + + + + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + + + + + + + + + + + + {d16954bb-de54-472b-ac10-ecab10d3fdc8} + + + \ No newline at end of file diff --git a/project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.user b/project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.user new file mode 100644 index 000000000..abe8dd896 --- /dev/null +++ b/project/vs2017.UWP/raylib.App.UWP/raylib.App.UWP.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file