@ -1,558 +0,0 @@ | |||||
#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; | |||||
/* | |||||
TODO list: | |||||
- Cache reference to our CoreWindow? | |||||
- Implement gestures support | |||||
*/ | |||||
// Declare uwpWindow as exter to be used by raylib internals | |||||
// NOTE: It should be properly assigned before calling InitWindow() | |||||
extern "C" { EGLNativeWindowType uwpWindow; }; | |||||
/* 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<Platform::String^>^) | |||||
{ | |||||
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<CoreApplicationView^, IActivatedEventArgs^>(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<Platform::Object^>(this, &App::OnResuming); | |||||
} | |||||
// Called when the CoreWindow object is created (or re-created). | |||||
void App::SetWindow(CoreWindow^ window) | |||||
{ | |||||
window->SizeChanged += ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &App::OnWindowSizeChanged); | |||||
window->VisibilityChanged += ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &App::OnVisibilityChanged); | |||||
window->Closed += ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed); | |||||
window->PointerPressed += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::PointerPressed); | |||||
window->PointerReleased += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::PointerReleased); | |||||
window->PointerWheelChanged += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::PointerWheelChanged); | |||||
window->KeyDown += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &App::OnKeyDown); | |||||
window->KeyUp += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &App::OnKeyUp); | |||||
Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &App::MouseMoved); | |||||
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); | |||||
currentDisplayInformation->DpiChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnDpiChanged); | |||||
currentDisplayInformation->OrientationChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged); | |||||
// The CoreWindow has been created, so EGL can be initialized. | |||||
uwpWindow = (EGLNativeWindowType)window; | |||||
InitWindow(800, 450, NULL); | |||||
} | |||||
// 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(); | |||||
} |
@ -1,49 +0,0 @@ | |||||
#pragma once | |||||
#include <string> | |||||
#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; | |||||
}; | |||||
} |
@ -1,4 +0,0 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
<PropertyGroup /> | |||||
</Project> |
@ -1,182 +0,0 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
<ItemGroup Label="ProjectConfigurations"> | |||||
<ProjectConfiguration Include="Debug|Win32"> | |||||
<Configuration>Debug</Configuration> | |||||
<Platform>Win32</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Debug|x64"> | |||||
<Configuration>Debug</Configuration> | |||||
<Platform>x64</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Release|Win32"> | |||||
<Configuration>Release</Configuration> | |||||
<Platform>Win32</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Release|x64"> | |||||
<Configuration>Release</Configuration> | |||||
<Platform>x64</Platform> | |||||
</ProjectConfiguration> | |||||
</ItemGroup> | |||||
<PropertyGroup Label="Globals"> | |||||
<ProjectGuid>{E89D61AC-55DE-4482-AFD4-DF7242EBC859}</ProjectGuid> | |||||
<Keyword>Win32Proj</Keyword> | |||||
<RootNamespace>raylib</RootNamespace> | |||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> | |||||
</PropertyGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v140</PlatformToolset> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v140</PlatformToolset> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<PlatformToolset>v140</PlatformToolset> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<PlatformToolset>v140</PlatformToolset> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<CharacterSet>Unicode</CharacterSet> | |||||
</PropertyGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |||||
<ImportGroup Label="ExtensionSettings"> | |||||
</ImportGroup> | |||||
<ImportGroup Label="Shared"> | |||||
</ImportGroup> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<PropertyGroup Label="UserMacros" /> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||||
<OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir> | |||||
<IntDir>$(SolutionDir)$(ProjectName)\$(Configuration)\temp</IntDir> | |||||
</PropertyGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>Disabled</Optimization> | |||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP</PreprocessorDefinitions> | |||||
<CompileAs>CompileAsC</CompileAs> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\ANGLE</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Windows</SubSystem> | |||||
</Link> | |||||
<Lib> | |||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | |||||
</Lib> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<Optimization>Disabled</Optimization> | |||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP</PreprocessorDefinitions> | |||||
<CompileAs>CompileAsC</CompileAs> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\include\ANGLE</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Windows</SubSystem> | |||||
</Link> | |||||
<Lib> | |||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | |||||
</Lib> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<ClCompile> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<Optimization>MaxSpeed</Optimization> | |||||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP</PreprocessorDefinitions> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\external\ANGLE;$(SolutionDir)..\..\release\include</AdditionalIncludeDirectories> | |||||
<CompileAs>CompileAsC</CompileAs> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Windows</SubSystem> | |||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||||
<OptimizeReferences>true</OptimizeReferences> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
<ClCompile> | |||||
<WarningLevel>Level3</WarningLevel> | |||||
<PrecompiledHeader> | |||||
</PrecompiledHeader> | |||||
<Optimization>MaxSpeed</Optimization> | |||||
<FunctionLevelLinking>true</FunctionLevelLinking> | |||||
<IntrinsicFunctions>true</IntrinsicFunctions> | |||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP</PreprocessorDefinitions> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\external\include\ANGLE;$(SolutionDir)..\..\release\include</AdditionalIncludeDirectories> | |||||
<CompileAs>CompileAsC</CompileAs> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Windows</SubSystem> | |||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | |||||
<OptimizeReferences>true</OptimizeReferences> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemGroup> | |||||
<Text Include="ReadMe.txt" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ClCompile Include="..\..\..\src\audio.c" /> | |||||
<ClCompile Include="..\..\..\src\core.c" /> | |||||
<ClCompile Include="..\..\..\src\models.c" /> | |||||
<ClCompile Include="..\..\..\src\shapes.c" /> | |||||
<ClCompile Include="..\..\..\src\text.c" /> | |||||
<ClCompile Include="..\..\..\src\textures.c" /> | |||||
<ClCompile Include="..\..\..\src\utils.c" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ClInclude Include="..\..\..\src\camera.h" /> | |||||
<ClInclude Include="..\..\..\src\external\glad.h" /> | |||||
<ClInclude Include="..\..\..\src\external\jar_mod.h" /> | |||||
<ClInclude Include="..\..\..\src\external\jar_xm.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image_resize.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image_write.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_rect_pack.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_truetype.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_vorbis.h" /> | |||||
<ClInclude Include="..\..\..\src\gestures.h" /> | |||||
<ClInclude Include="..\..\..\src\raylib.h" /> | |||||
<ClInclude Include="..\..\..\src\raymath.h" /> | |||||
<ClInclude Include="..\..\..\src\rlgl.h" /> | |||||
<ClInclude Include="..\..\..\src\utils.h" /> | |||||
</ItemGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||||
<ImportGroup Label="ExtensionTargets"> | |||||
</ImportGroup> | |||||
</Project> |
@ -0,0 +1,78 @@ | |||||
#include "pch.h" | |||||
#include "app.h" | |||||
#include "raylib.h" | |||||
using namespace raylibUWP; | |||||
// The main function creates an IFrameworkViewSource for our app, and runs the app. | |||||
[Platform::MTAThread] | |||||
int main(Platform::Array<Platform::String^>^) | |||||
{ | |||||
auto appSource = ref new ApplicationSource<App>(); | |||||
CoreApplication::Run(appSource); | |||||
return 0; | |||||
} | |||||
App::App() | |||||
{ | |||||
//This does not work... need to fix this. | |||||
SetConfigFlags(0); | |||||
Setup(640, 480); | |||||
} | |||||
static int posX = 100; | |||||
static int posY = 100; | |||||
static int gTime = 0; | |||||
// This method is called every frame | |||||
void App::Update() | |||||
{ | |||||
//return; | |||||
// Draw | |||||
BeginDrawing(); | |||||
ClearBackground(RAYWHITE); | |||||
posX += GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_X) * 5; | |||||
posY += GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_Y) * -5; | |||||
DrawRectangle(posX, posY, 400, 100, RED); | |||||
DrawLine(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); | |||||
auto mPos = GetMousePosition(); | |||||
DrawCircle(mPos.x, mPos.y, 40, BLUE); | |||||
if (IsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE); | |||||
if (IsKeyPressed(KEY_A)) | |||||
{ | |||||
posX -= 50; | |||||
EnableCursor(); | |||||
} | |||||
if (IsKeyPressed(KEY_D)) | |||||
{ | |||||
posX += 50; | |||||
DisableCursor(); | |||||
} | |||||
if (IsKeyDown(KEY_LEFT_ALT)) | |||||
DrawRectangle(250, 250, 20, 20, BLACK); | |||||
if (IsKeyDown(KEY_BACKSPACE)) | |||||
DrawRectangle(280, 250, 20, 20, BLACK); | |||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) | |||||
DrawRectangle(280, 250, 20, 20, BLACK); | |||||
static int pos = 0; | |||||
pos -= GetMouseWheelMove(); | |||||
DrawRectangle(280, pos + 50, 20, 20, BLACK); | |||||
DrawRectangle(250, 280 + (gTime++ % 60), 10, 10, PURPLE); | |||||
EndDrawing(); | |||||
} |
@ -0,0 +1,25 @@ | |||||
#pragma once | |||||
#include <string> | |||||
#include "pch.h" | |||||
//Define what header we use for BaseApp.h | |||||
#define PCH "pch.h" | |||||
//Enable hold hack | |||||
#define HOLDHACK | |||||
#include "BaseApp.h" | |||||
namespace raylibUWP | |||||
{ | |||||
ref class App sealed : public BaseApp | |||||
{ | |||||
public: | |||||
App(); | |||||
// IFrameworkView Methods. | |||||
void Update() override; | |||||
}; | |||||
} |
@ -0,0 +1,567 @@ | |||||
/********************************************************************************************** | |||||
* | |||||
* raylib.BaseApp - UWP App generic code for managing interface between C and C++ | |||||
* | |||||
* LICENSE: zlib/libpng | |||||
* | |||||
* CONFIGURATION: | |||||
* | |||||
* #define PCH | |||||
* This defines what header is the PCH and needs to be included | |||||
* | |||||
* #define HOLDHACK | |||||
* This enables a hack to fix flickering key presses (Temporary) | |||||
* | |||||
* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) | |||||
* | |||||
* This software is provided "as-is", without any express or implied warranty. In no event | |||||
* will the authors be held liable for any damages arising from the use of this software. | |||||
* | |||||
* Permission is granted to anyone to use this software for any purpose, including commercial | |||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions: | |||||
* | |||||
* 1. The origin of this software must not be misrepresented; you must not claim that you | |||||
* wrote the original software. If you use this software in a product, an acknowledgment | |||||
* in the product documentation would be appreciated but is not required. | |||||
* | |||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented | |||||
* as being the original software. | |||||
* | |||||
* 3. This notice may not be removed or altered from any source distribution. | |||||
* | |||||
**********************************************************************************************/ | |||||
#pragma once | |||||
#if defined(PCH) | |||||
#include PCH | |||||
#endif | |||||
#include <chrono> | |||||
#include <memory> | |||||
#include <wrl.h> | |||||
//EGL | |||||
#include <EGL/eglplatform.h> | |||||
#include "raylib.h" | |||||
#include "utils.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; | |||||
extern "C" { EGLNativeWindowType uwpWindow; }; | |||||
/* | |||||
TODO list: | |||||
- Cache reference to our CoreWindow? | |||||
- Implement gestures support | |||||
*/ | |||||
// 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) | |||||
//Mouse cursor locking | |||||
bool cursorLocked = false; | |||||
Vector2 mouseDelta = {0, 0}; | |||||
//Our mouse cursor | |||||
CoreCursor ^regularCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); // The "visible arrow" cursor type | |||||
//Base app implementation | |||||
ref class BaseApp : public Windows::ApplicationModel::Core::IFrameworkView | |||||
{ | |||||
public: | |||||
// IFrameworkView Methods. | |||||
virtual void Initialize(Windows::ApplicationModel::Core::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<CoreApplicationView^, IActivatedEventArgs^>(this, &BaseApp::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<Platform::Object^>(this, &BaseApp::OnResuming); | |||||
} | |||||
virtual void SetWindow(Windows::UI::Core::CoreWindow^ window) | |||||
{ | |||||
window->SizeChanged += ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &BaseApp::OnWindowSizeChanged); | |||||
window->VisibilityChanged += ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &BaseApp::OnVisibilityChanged); | |||||
window->Closed += ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &BaseApp::OnWindowClosed); | |||||
window->PointerPressed += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &BaseApp::PointerPressed); | |||||
window->PointerWheelChanged += ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &BaseApp::PointerWheelChanged); | |||||
window->KeyDown += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &BaseApp::OnKeyDown); | |||||
window->KeyUp += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &BaseApp::OnKeyUp); | |||||
Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &BaseApp::MouseMoved); | |||||
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); | |||||
currentDisplayInformation->DpiChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &BaseApp::OnDpiChanged); | |||||
currentDisplayInformation->OrientationChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &BaseApp::OnOrientationChanged); | |||||
// The CoreWindow has been created, so EGL can be initialized. | |||||
uwpWindow = (EGLNativeWindowType)window; | |||||
InitWindow(width, height, NULL); | |||||
} | |||||
virtual void Load(Platform::String^ entryPoint) {} | |||||
void Setup(int width, int height) | |||||
{ | |||||
//Set dimensions | |||||
this->width = width; | |||||
this->height = height; | |||||
} | |||||
virtual void Run() | |||||
{ | |||||
//Get display dimensions | |||||
DisplayInformation^ dInfo = DisplayInformation::GetForCurrentView(); | |||||
Vector2 screenSize = { dInfo->ScreenWidthInRawPixels, dInfo->ScreenHeightInRawPixels }; | |||||
//Send display dimensions | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = SetDisplayDims; | |||||
msg->Vector0 = screenSize; | |||||
UWPSendMessage(msg); | |||||
//Send the time to the core | |||||
using clock = std::chrono::high_resolution_clock; | |||||
auto timeStart = clock::now(); | |||||
//Set fps if 0 | |||||
if (GetFPS() <= 0) | |||||
SetTargetFPS(60); | |||||
while (!mWindowClosed) | |||||
{ | |||||
if (mWindowVisible) | |||||
{ | |||||
//Send time | |||||
auto delta = clock::now() - timeStart; | |||||
UWPMessage* timeMsg = CreateUWPMessage(); | |||||
timeMsg->Type = SetGameTime; | |||||
timeMsg->Double0 = std::chrono::duration_cast<std::chrono::seconds>(delta).count(); | |||||
UWPSendMessage(timeMsg); | |||||
//Call update function | |||||
Update(); | |||||
PollInput(); | |||||
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); | |||||
} | |||||
else | |||||
{ | |||||
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); | |||||
} | |||||
} | |||||
CloseWindow(); | |||||
} | |||||
//Called every frame (Maybe add draw) | |||||
virtual void Update() {} | |||||
virtual void Uninitialize() {} | |||||
protected: | |||||
// Input polling | |||||
void PollInput() | |||||
{ | |||||
// Process Messages | |||||
{ | |||||
//Loop over pending messages | |||||
while (UWPHasMessages()) | |||||
{ | |||||
//Get the message | |||||
auto msg = UWPGetMessage(); | |||||
//Carry out the command | |||||
switch(msg->Type) | |||||
{ | |||||
case ShowMouse: //Do the same thing because of how UWP works... | |||||
case UnlockMouse: | |||||
{ | |||||
CoreWindow::GetForCurrentThread()->PointerCursor = regularCursor; | |||||
cursorLocked = false; | |||||
MoveMouse(GetMousePosition()); | |||||
break; | |||||
} | |||||
case HideMouse: //Do the same thing because of how UWP works... | |||||
case LockMouse: | |||||
{ | |||||
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr; | |||||
cursorLocked = true; | |||||
break; | |||||
} | |||||
case SetMouseLocation: | |||||
{ | |||||
MoveMouse(msg->Vector0); | |||||
break; | |||||
} | |||||
} | |||||
//Delete the message | |||||
DeleteUWPMessage(msg); | |||||
} | |||||
} | |||||
// Process Keyboard | |||||
{ | |||||
for (int k = 0x08; k < 0xA6; k++) { | |||||
auto state = CoreWindow::GetForCurrentThread()->GetKeyState((Windows::System::VirtualKey) k); | |||||
#ifdef HOLDHACK | |||||
//Super hacky way of waiting three frames to see if we are ready to register the key as deregistered | |||||
//This will wait an entire 4 frames before deregistering the key, this makes sure that the key is not flickering | |||||
if (KeyboardStateHack[k] == 2) | |||||
{ | |||||
if ((state & CoreVirtualKeyStates::None) == CoreVirtualKeyStates::None) | |||||
{ | |||||
KeyboardStateHack[k] = 3; | |||||
} | |||||
} | |||||
else if (KeyboardStateHack[k] == 3) | |||||
{ | |||||
if ((state & CoreVirtualKeyStates::None) == CoreVirtualKeyStates::None) | |||||
{ | |||||
KeyboardStateHack[k] = 4; | |||||
} | |||||
} | |||||
else if (KeyboardStateHack[k] == 4) | |||||
{ | |||||
if ((state & CoreVirtualKeyStates::None) == CoreVirtualKeyStates::None) | |||||
{ | |||||
//Reset key... | |||||
KeyboardStateHack[k] = 0; | |||||
//Tell core | |||||
RegisterKey(k, 0); | |||||
} | |||||
} | |||||
#endif | |||||
//Left and right alt, KeyUp and KeyDown are not called for it | |||||
//No need to hack because this is not a character | |||||
//TODO: Maybe do all other key registrations like this, no more key events? | |||||
if (k == 0xA4 || k == 0xA5) | |||||
{ | |||||
if ((state & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) | |||||
{ | |||||
RegisterKey(k, 1); | |||||
} | |||||
else | |||||
{ | |||||
RegisterKey(k, 0); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
// Process Mouse | |||||
{ | |||||
if (CurrentPointerID > -1) { | |||||
auto point = PointerPoint::GetCurrentPoint(CurrentPointerID); | |||||
auto props = point->Properties; | |||||
if (props->IsLeftButtonPressed) | |||||
{ | |||||
RegisterClick(MOUSE_LEFT_BUTTON, 1); | |||||
} | |||||
else | |||||
{ | |||||
RegisterClick(MOUSE_LEFT_BUTTON, 0); | |||||
} | |||||
if (props->IsRightButtonPressed) | |||||
{ | |||||
RegisterClick(MOUSE_RIGHT_BUTTON, 1); | |||||
} | |||||
else | |||||
{ | |||||
RegisterClick(MOUSE_RIGHT_BUTTON, 0); | |||||
} | |||||
if (props->IsMiddleButtonPressed) | |||||
{ | |||||
RegisterClick(MOUSE_MIDDLE_BUTTON, 1); | |||||
} | |||||
else | |||||
{ | |||||
RegisterClick(MOUSE_MIDDLE_BUTTON, 0); | |||||
} | |||||
} | |||||
CoreWindow ^window = CoreWindow::GetForCurrentThread(); | |||||
if (cursorLocked) | |||||
{ | |||||
// Track cursor movement delta, recenter it on the client | |||||
auto curMousePos = GetMousePosition(); | |||||
auto x = curMousePos.x + mouseDelta.x; | |||||
auto y = curMousePos.y + mouseDelta.y; | |||||
UpdateMousePosition({ x, 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 | |||||
auto x = window->PointerPosition.X - window->Bounds.X; | |||||
auto y = window->PointerPosition.Y - window->Bounds.Y; | |||||
UpdateMousePosition({ x, 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. | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = MarkGamepadActive; | |||||
msg->Int0 = i; | |||||
msg->Bool0 = i < Gamepad::Gamepads->Size; | |||||
UWPSendMessage(msg); | |||||
} | |||||
// Get current gamepad state | |||||
for (int i = 0; i < MAX_GAMEPADS; i++) | |||||
{ | |||||
if (IsGamepadAvailable(i)) | |||||
{ | |||||
// 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 | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_A, ((reading.Buttons & GamepadButtons::A) == GamepadButtons::A)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_B, ((reading.Buttons & GamepadButtons::B) == GamepadButtons::B)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_X, ((reading.Buttons & GamepadButtons::X) == GamepadButtons::X)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_Y, ((reading.Buttons & GamepadButtons::Y) == GamepadButtons::Y)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_LB, ((reading.Buttons & GamepadButtons::LeftShoulder) == GamepadButtons::LeftShoulder)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_RB, ((reading.Buttons & GamepadButtons::RightShoulder) == GamepadButtons::RightShoulder)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_SELECT, ((reading.Buttons & GamepadButtons::View) == GamepadButtons::View)); // Changed for XB1 Controller | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_START, ((reading.Buttons & GamepadButtons::Menu) == GamepadButtons::Menu)); // Changed for XB1 Controller | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_UP, ((reading.Buttons & GamepadButtons::DPadUp) == GamepadButtons::DPadUp)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_RIGHT, ((reading.Buttons & GamepadButtons::DPadRight) == GamepadButtons::DPadRight)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_DOWN, ((reading.Buttons & GamepadButtons::DPadDown) == GamepadButtons::DPadDown)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_LEFT, ((reading.Buttons & GamepadButtons::DPadLeft) == GamepadButtons::DPadLeft)); | |||||
RegisterGamepadButton(i, GAMEPAD_XBOX_BUTTON_HOME, false); // Home button not supported by UWP | |||||
// Get current axis state | |||||
RegisterGamepadAxis(i, GAMEPAD_XBOX_AXIS_LEFT_X, (float)reading.LeftThumbstickX); | |||||
RegisterGamepadAxis(i, GAMEPAD_XBOX_AXIS_LEFT_Y, (float)reading.LeftThumbstickY); | |||||
RegisterGamepadAxis(i, GAMEPAD_XBOX_AXIS_RIGHT_X, (float)reading.RightThumbstickX); | |||||
RegisterGamepadAxis(i, GAMEPAD_XBOX_AXIS_RIGHT_Y, (float)reading.RightThumbstickY); | |||||
RegisterGamepadAxis(i, GAMEPAD_XBOX_AXIS_LT, (float)reading.LeftTrigger); | |||||
RegisterGamepadAxis(i, GAMEPAD_XBOX_AXIS_RT, (float)reading.RightTrigger); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
// Application lifecycle event handlers. | |||||
void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args) | |||||
{ | |||||
// Run() won't start until the CoreWindow is activated. | |||||
CoreWindow::GetForCurrentThread()->Activate(); | |||||
} | |||||
void OnResuming(Platform::Object^ sender, Platform::Object^ args) {} | |||||
// Window event handlers. | |||||
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args) | |||||
{ | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = HandleResize; | |||||
UWPSendMessage(msg); | |||||
} | |||||
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args) | |||||
{ | |||||
mWindowVisible = args->Visible; | |||||
} | |||||
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args) | |||||
{ | |||||
mWindowClosed = true; | |||||
} | |||||
// 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) | |||||
{ | |||||
//Get the current active pointer ID for our loop | |||||
CurrentPointerID = args->CurrentPoint->PointerId; | |||||
args->Handled = true; | |||||
} | |||||
void PointerWheelChanged(Windows::UI::Core::CoreWindow ^sender, Windows::UI::Core::PointerEventArgs^ args) | |||||
{ | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = ScrollWheelUpdate; | |||||
msg->Float0 = args->CurrentPoint->Properties->MouseWheelDelta; | |||||
UWPSendMessage(msg); | |||||
} | |||||
void MouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args) | |||||
{ | |||||
mouseDelta.x += args->MouseDelta.X; | |||||
mouseDelta.y += args->MouseDelta.Y; | |||||
} | |||||
void OnKeyDown(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) | |||||
{ | |||||
#ifdef HOLDHACK | |||||
//Start the hack | |||||
KeyboardStateHack[(int)args->VirtualKey] = 1; | |||||
#endif | |||||
RegisterKey((int)args->VirtualKey, 1); | |||||
} | |||||
void OnKeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) | |||||
{ | |||||
#ifdef HOLDHACK | |||||
//The same hack | |||||
if (KeyboardStateHack[(int)args->VirtualKey] == 1) | |||||
{ | |||||
KeyboardStateHack[(int)args->VirtualKey] = 2; | |||||
} | |||||
else if (KeyboardStateHack[(int)args->VirtualKey] == 2) | |||||
{ | |||||
KeyboardStateHack[(int)args->VirtualKey] = 3; | |||||
} | |||||
else if (KeyboardStateHack[(int)args->VirtualKey] == 3) | |||||
{ | |||||
KeyboardStateHack[(int)args->VirtualKey] = 4; | |||||
} | |||||
else if (KeyboardStateHack[(int)args->VirtualKey] == 4) | |||||
{ | |||||
RegisterKey((int)args->VirtualKey, 0); | |||||
KeyboardStateHack[(int)args->VirtualKey] = 0; | |||||
} | |||||
#else | |||||
//No hack, allow flickers | |||||
RegisterKey((int)args->VirtualKey, 0); | |||||
#endif | |||||
} | |||||
private: | |||||
void RegisterKey(int key, char status) | |||||
{ | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = UWPMessageType::RegisterKey; | |||||
msg->Int0 = key; | |||||
msg->Char0 = status; | |||||
UWPSendMessage(msg); | |||||
} | |||||
void MoveMouse(Vector2 pos) | |||||
{ | |||||
CoreWindow ^window = CoreWindow::GetForCurrentThread(); | |||||
Point mousePosScreen = Point(pos.x + window->Bounds.X, pos.y + window->Bounds.Y); | |||||
window->PointerPosition = mousePosScreen; | |||||
} | |||||
void RegisterGamepadButton(int gamepad, int button, char status) | |||||
{ | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = MarkGamepadButton; | |||||
msg->Int0 = gamepad; | |||||
msg->Int1 = button; | |||||
msg->Char0 = status; | |||||
UWPSendMessage(msg); | |||||
} | |||||
void RegisterGamepadAxis(int gamepad, int axis, float value) | |||||
{ | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = MarkGamepadAxis; | |||||
msg->Int0 = gamepad; | |||||
msg->Int1 = axis; | |||||
msg->Float0 = value; | |||||
UWPSendMessage(msg); | |||||
} | |||||
void UpdateMousePosition(Vector2 pos) | |||||
{ | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = UpdateMouseLocation; | |||||
msg->Vector0 = pos; | |||||
UWPSendMessage(msg); | |||||
} | |||||
void RegisterClick(int button, char status) | |||||
{ | |||||
UWPMessage* msg = CreateUWPMessage(); | |||||
msg->Type = UWPMessageType::RegisterClick; | |||||
msg->Int0 = button; | |||||
msg->Char0 = status; | |||||
UWPSendMessage(msg); | |||||
} | |||||
bool mWindowClosed = false; | |||||
bool mWindowVisible = true; | |||||
int width = 640; | |||||
int height = 480; | |||||
int CurrentPointerID = -1; | |||||
#ifdef HOLDHACK | |||||
char KeyboardStateHack[0xA6]; //0xA6 because the highest key we compare against is 0xA5 | |||||
#endif | |||||
}; | |||||
//Application source for creating the program | |||||
template<typename AppType> | |||||
ref class ApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource | |||||
{ | |||||
public: | |||||
virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView() | |||||
{ | |||||
return ref new AppType(); | |||||
} | |||||
}; |
@ -0,0 +1,231 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
<ItemGroup Label="ProjectConfigurations"> | |||||
<ProjectConfiguration Include="Debug|ARM"> | |||||
<Configuration>Debug</Configuration> | |||||
<Platform>ARM</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Debug|Win32"> | |||||
<Configuration>Debug</Configuration> | |||||
<Platform>Win32</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Debug|x64"> | |||||
<Configuration>Debug</Configuration> | |||||
<Platform>x64</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Release|ARM"> | |||||
<Configuration>Release</Configuration> | |||||
<Platform>ARM</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Release|Win32"> | |||||
<Configuration>Release</Configuration> | |||||
<Platform>Win32</Platform> | |||||
</ProjectConfiguration> | |||||
<ProjectConfiguration Include="Release|x64"> | |||||
<Configuration>Release</Configuration> | |||||
<Platform>x64</Platform> | |||||
</ProjectConfiguration> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ClInclude Include="..\..\..\src\camera.h" /> | |||||
<ClInclude Include="..\..\..\src\external\glad.h" /> | |||||
<ClInclude Include="..\..\..\src\external\jar_mod.h" /> | |||||
<ClInclude Include="..\..\..\src\external\jar_xm.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image_resize.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image_write.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_rect_pack.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_truetype.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_vorbis.h" /> | |||||
<ClInclude Include="..\..\..\src\gestures.h" /> | |||||
<ClInclude Include="..\..\..\src\raylib.h" /> | |||||
<ClInclude Include="..\..\..\src\raymath.h" /> | |||||
<ClInclude Include="..\..\..\src\rlgl.h" /> | |||||
<ClInclude Include="..\..\..\src\utils.h" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ClCompile Include="..\..\..\src\core.c" /> | |||||
<ClCompile Include="..\..\..\src\models.c" /> | |||||
<ClCompile Include="..\..\..\src\raudio.c" /> | |||||
<ClCompile Include="..\..\..\src\shapes.c" /> | |||||
<ClCompile Include="..\..\..\src\text.c" /> | |||||
<ClCompile Include="..\..\..\src\textures.c" /> | |||||
<ClCompile Include="..\..\..\src\utils.c" /> | |||||
</ItemGroup> | |||||
<PropertyGroup Label="Globals"> | |||||
<ProjectGuid>{ea91e088-7c71-4f32-b761-e054305cd519}</ProjectGuid> | |||||
<Keyword>StaticLibrary</Keyword> | |||||
<RootNamespace>raylib_UWP</RootNamespace> | |||||
<DefaultLanguage>en-US</DefaultLanguage> | |||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | |||||
<AppContainerApplication>true</AppContainerApplication> | |||||
<ApplicationType>Windows Store</ApplicationType> | |||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion> | |||||
<WindowsTargetPlatformMinVersion>10.0.15063.0</WindowsTargetPlatformMinVersion> | |||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision> | |||||
</PropertyGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>true</UseDebugLibraries> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | |||||
<ConfigurationType>StaticLibrary</ConfigurationType> | |||||
<UseDebugLibraries>false</UseDebugLibraries> | |||||
<WholeProgramOptimization>true</WholeProgramOptimization> | |||||
<PlatformToolset>v141</PlatformToolset> | |||||
</PropertyGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |||||
<ImportGroup Label="ExtensionSettings"> | |||||
</ImportGroup> | |||||
<ImportGroup Label="Shared"> | |||||
</ImportGroup> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||||
</ImportGroup> | |||||
<PropertyGroup Label="UserMacros" /> | |||||
<PropertyGroup /> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||||
<GenerateManifest>false</GenerateManifest> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<GenerateManifest>false</GenerateManifest> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> | |||||
<GenerateManifest>false</GenerateManifest> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> | |||||
<GenerateManifest>false</GenerateManifest> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<GenerateManifest>false</GenerateManifest> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
<GenerateManifest>false</GenerateManifest> | |||||
</PropertyGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | |||||
<CompileAsWinRT>false</CompileAsWinRT> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\ANGLE;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | |||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | |||||
<CompileAsWinRT>false</CompileAsWinRT> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\ANGLE;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | |||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | |||||
<CompileAsWinRT>false</CompileAsWinRT> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\ANGLE;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | |||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | |||||
<CompileAsWinRT>false</CompileAsWinRT> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\ANGLE;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | |||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | |||||
<CompileAsWinRT>false</CompileAsWinRT> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\ANGLE;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | |||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |||||
<ClCompile> | |||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | |||||
<CompileAsWinRT>false</CompileAsWinRT> | |||||
<SDLCheck>true</SDLCheck> | |||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;GRAPHICS_API_OPENGL_ES2;PLATFORM_UWP;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\release\include;$(SolutionDir)..\..\src\external\ANGLE;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | |||||
</ClCompile> | |||||
<Link> | |||||
<SubSystem>Console</SubSystem> | |||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> | |||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | |||||
</Link> | |||||
</ItemDefinitionGroup> | |||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||||
<ImportGroup Label="ExtensionTargets"> | |||||
</ImportGroup> | |||||
</Project> |
@ -0,0 +1,29 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||||
<ItemGroup> | |||||
<ClInclude Include="..\..\..\src\camera.h" /> | |||||
<ClInclude Include="..\..\..\src\gestures.h" /> | |||||
<ClInclude Include="..\..\..\src\raylib.h" /> | |||||
<ClInclude Include="..\..\..\src\raymath.h" /> | |||||
<ClInclude Include="..\..\..\src\rlgl.h" /> | |||||
<ClInclude Include="..\..\..\src\utils.h" /> | |||||
<ClInclude Include="..\..\..\src\external\glad.h" /> | |||||
<ClInclude Include="..\..\..\src\external\jar_mod.h" /> | |||||
<ClInclude Include="..\..\..\src\external\jar_xm.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image_resize.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_image_write.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_rect_pack.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_truetype.h" /> | |||||
<ClInclude Include="..\..\..\src\external\stb_vorbis.h" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ClCompile Include="..\..\..\src\core.c" /> | |||||
<ClCompile Include="..\..\..\src\models.c" /> | |||||
<ClCompile Include="..\..\..\src\raudio.c" /> | |||||
<ClCompile Include="..\..\..\src\shapes.c" /> | |||||
<ClCompile Include="..\..\..\src\text.c" /> | |||||
<ClCompile Include="..\..\..\src\textures.c" /> | |||||
<ClCompile Include="..\..\..\src\utils.c" /> | |||||
</ItemGroup> | |||||
</Project> |