Ver Fonte

Review UWP configuration

raysan5 há 7 anos atrás
pai
commit
e18e8c6276

+ 23 - 23
project/vs2015.UWP/raylib.App.UWP/App.cpp

@@ -18,16 +18,21 @@ using namespace Platform;
 using namespace raylibUWP;
 
 /*
-To-do list
+TODO list:
 	- Cache reference to our CoreWindow?
-	- Implement gestures
+	- 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
@@ -36,7 +41,6 @@ static char currentGamepadState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS];     // Curre
 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
@@ -46,7 +50,7 @@ static bool cursorOnScreen = false;         // Tracks if cursor is inside client
 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 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
@@ -122,7 +126,7 @@ void ProcessKeyEvent(Windows::System::VirtualKey key, int action)
 	}
 }
 
-/* CALLBACKS */
+// Callbacks
 void App::PointerPressed(CoreWindow^ window, PointerEventArgs^ args)
 {
 	if (args->CurrentPoint->Properties->IsLeftButtonPressed)
@@ -206,6 +210,7 @@ void UWPSetMousePosition(Vector2 position)
 	window->PointerPosition = mousePosScreen;
 	mousePosition = position;
 }
+
 // Enables cursor (unlock cursor)
 void UWPEnableCursor()
 {
@@ -321,8 +326,7 @@ bool UWPIsKeyPressed(int key)
 {
 	bool pressed = false;
 	
-	if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1))
-		pressed = true;
+	if ((currentKeyState[key] != previousKeyState[key]) && (currentKeyState[key] == 1)) pressed = true;
 	else pressed = false;
 
 	return pressed;
@@ -422,7 +426,10 @@ void App::SetWindow(CoreWindow^ window)
 	currentDisplayInformation->OrientationChanged += ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged);
 
     // The CoreWindow has been created, so EGL can be initialized.
-	InitWindow(800, 450, (EGLNativeWindowType)window);
+
+	uwpWindow = (EGLNativeWindowType)window;
+
+	InitWindow(800, 450, NULL);
 }
 
 // Initializes scene resources
@@ -446,7 +453,6 @@ void App::Run()
 
 				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);
@@ -455,38 +461,32 @@ void App::Run()
 
 				DrawCircle(mousePosition.x, mousePosition.y, 40, BLUE);
 
-				if(UWPIsKeyDown(KEY_S))
-				{
-					DrawCircle(100, 100, 100, BLUE);
-				}
+				if (UWPIsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE);
 
-				if(UWPIsKeyPressed(KEY_A))
+				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);
+				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(280, pos + 50, 20, 20, BLACK);
 				DrawRectangle(250, 280 + (time++ % 60), 10, 10, PURPLE);
 
 		    EndDrawing();
+
 			UWP_PollInput();
 
 			CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);

+ 1 - 1
project/vs2015.UWP/raylib.App.UWP/Package.appxmanifest

@@ -4,7 +4,7 @@
   <mp:PhoneIdentity PhoneProductId="56d2ca94-c361-4e9f-9a33-bacd751552fa" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
   <Properties>
     <DisplayName>raylibUWP</DisplayName>
-    <PublisherDisplayName>Alumno</PublisherDisplayName>
+    <PublisherDisplayName>raysan5</PublisherDisplayName>
     <Logo>Assets\StoreLogo.png</Logo>
   </Properties>
   <Dependencies>

+ 1 - 1
project/vs2015.UWP/raylib.App.UWP/raylib.App.UWP.vcxproj

@@ -34,7 +34,7 @@
     <AppContainerApplication>true</AppContainerApplication>
     <ApplicationType>Windows Store</ApplicationType>
     <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
-    <WindowsTargetPlatformMinVersion>10.0.10586.0</WindowsTargetPlatformMinVersion>
+    <WindowsTargetPlatformMinVersion>10.0.14393.0</WindowsTargetPlatformMinVersion>
     <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
     <ProjectName>raylib.App.UWP</ProjectName>
   </PropertyGroup>

+ 1 - 1
project/vs2015.UWP/raylib/raylib.vcxproj

@@ -28,7 +28,7 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
     <ConfigurationType>StaticLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v141</PlatformToolset>
+    <PlatformToolset>v140</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">