From dfc6dc2fa115889d39a2a18912489d275b993368 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 23 Mar 2024 23:31:09 +0800 Subject: [PATCH] some update --- projects/Xcode15/main.c | 152 +++++++++++ .../Xcode15/raylib.xcodeproj/project.pbxproj | 239 ++++++++++-------- src/platforms/rcore_ios.c | 73 +++++- 3 files changed, 355 insertions(+), 109 deletions(-) create mode 100644 projects/Xcode15/main.c diff --git a/projects/Xcode15/main.c b/projects/Xcode15/main.c new file mode 100644 index 000000000000..c603fd0c3d39 --- /dev/null +++ b/projects/Xcode15/main.c @@ -0,0 +1,152 @@ +/******************************************************************************************* +* +* raylib [core] examples - basic screen manager +* +* NOTE: This example illustrates a very simple screen manager based on a states machines +* +* Example originally created with raylib 4.0, last time updated with raylib 4.0 +* +* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software +* +* Copyright (c) 2021-2024 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +//------------------------------------------------------------------------------------------ +// Types and Structures Definition +//------------------------------------------------------------------------------------------ +typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen; + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int ios_main(int argc, char * argv[]) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [core] example - basic screen manager"); + + GameScreen currentScreen = LOGO; + + // TODO: Initialize all required variables and load all required data here! + + int framesCounter = 0; // Useful to count frames + + SetTargetFPS(60); // Set desired framerate (frames-per-second) + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + switch(currentScreen) + { + case LOGO: + { + // TODO: Update LOGO screen variables here! + + framesCounter++; // Count frames + + // Wait for 2 seconds (120 frames) before jumping to TITLE screen + if (framesCounter > 120) + { + currentScreen = TITLE; + } + } break; + case TITLE: + { + // TODO: Update TITLE screen variables here! + + // Press enter to change to GAMEPLAY screen + if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) + { + currentScreen = GAMEPLAY; + } + } break; + case GAMEPLAY: + { + // TODO: Update GAMEPLAY screen variables here! + + // Press enter to change to ENDING screen + if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) + { + currentScreen = ENDING; + } + } break; + case ENDING: + { + // TODO: Update ENDING screen variables here! + + // Press enter to return to TITLE screen + if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) + { + currentScreen = TITLE; + } + } break; + default: break; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + switch(currentScreen) + { + case LOGO: + { + // TODO: Draw LOGO screen here! + DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY); + DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY); + + } break; + case TITLE: + { + // TODO: Draw TITLE screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); + DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); + DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN); + + } break; + case GAMEPLAY: + { + // TODO: Draw GAMEPLAY screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE); + DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); + DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON); + + } break; + case ENDING: + { + // TODO: Draw ENDING screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, BLUE); + DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); + DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE); + + } break; + default: break; + } + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + + // TODO: Unload all loaded data (textures, fonts, audio) here! + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} diff --git a/projects/Xcode15/raylib.xcodeproj/project.pbxproj b/projects/Xcode15/raylib.xcodeproj/project.pbxproj index 11cc79bb9249..191082c84876 100644 --- a/projects/Xcode15/raylib.xcodeproj/project.pbxproj +++ b/projects/Xcode15/raylib.xcodeproj/project.pbxproj @@ -7,46 +7,65 @@ objects = { /* Begin PBXBuildFile section */ - 1B16D9052BAEDC41001FD5E0 /* libGLESv2.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B16D9032BAEDC41001FD5E0 /* libGLESv2.xcframework */; }; - 1B16D9062BAEDC41001FD5E0 /* libEGL.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B16D9042BAEDC41001FD5E0 /* libEGL.xcframework */; }; - 1B3BE7442BAEE2D700EF4B82 /* rshapes.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B3BE73D2BAEE2D700EF4B82 /* rshapes.c */; }; - 1B3BE7452BAEE2D700EF4B82 /* utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B3BE73E2BAEE2D700EF4B82 /* utils.c */; }; - 1B3BE7462BAEE2D700EF4B82 /* rtext.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B3BE73F2BAEE2D700EF4B82 /* rtext.c */; }; - 1B3BE7472BAEE2D700EF4B82 /* rtextures.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B3BE7402BAEE2D700EF4B82 /* rtextures.c */; }; - 1B3BE7482BAEE2D700EF4B82 /* raudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B3BE7412BAEE2D700EF4B82 /* raudio.c */; }; - 1B3BE7492BAEE2D700EF4B82 /* rcore.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B3BE7422BAEE2D700EF4B82 /* rcore.c */; }; - 1B3BE74A2BAEE2D700EF4B82 /* rmodels.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B3BE7432BAEE2D700EF4B82 /* rmodels.c */; }; - 1BF3FC952BAEE3BD00D3B043 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BF3FC942BAEE3BD00D3B043 /* AVFoundation.framework */; }; - 1BF3FC972BAEE3CF00D3B043 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BF3FC962BAEE3CF00D3B043 /* Foundation.framework */; }; - 1BF3FC992BAEE43900D3B043 /* AVFAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BF3FC982BAEE43800D3B043 /* AVFAudio.framework */; }; + 1BF3FCDE2BAF1C1800D3B043 /* libEGL.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B16D9042BAEDC41001FD5E0 /* libEGL.xcframework */; }; + 1BF3FCDF2BAF1C1800D3B043 /* libEGL.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1B16D9042BAEDC41001FD5E0 /* libEGL.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 1BF3FCE02BAF1C1800D3B043 /* libGLESv2.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B16D9032BAEDC41001FD5E0 /* libGLESv2.xcframework */; }; + 1BF3FCE12BAF1C1800D3B043 /* libGLESv2.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1B16D9032BAEDC41001FD5E0 /* libGLESv2.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 1BF3FCE62BAF1C3000D3B043 /* AVFAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BF3FCE42BAF1C3000D3B043 /* AVFAudio.framework */; }; + 1BF3FCE72BAF1C3000D3B043 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BF3FCE52BAF1C3000D3B043 /* AVFoundation.framework */; }; + 1BF3FCE92BAF1C3800D3B043 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BF3FCE82BAF1C3800D3B043 /* Foundation.framework */; }; + 1BF3FCF12BAF1D3300D3B043 /* raudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 1BF3FCEA2BAF1D3300D3B043 /* raudio.c */; }; + 1BF3FCF22BAF1D3300D3B043 /* utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 1BF3FCEB2BAF1D3300D3B043 /* utils.c */; }; + 1BF3FCF32BAF1D3300D3B043 /* rshapes.c in Sources */ = {isa = PBXBuildFile; fileRef = 1BF3FCEC2BAF1D3300D3B043 /* rshapes.c */; }; + 1BF3FCF42BAF1D3300D3B043 /* rtextures.c in Sources */ = {isa = PBXBuildFile; fileRef = 1BF3FCED2BAF1D3300D3B043 /* rtextures.c */; }; + 1BF3FCF52BAF1D3300D3B043 /* rcore.c in Sources */ = {isa = PBXBuildFile; fileRef = 1BF3FCEE2BAF1D3300D3B043 /* rcore.c */; }; + 1BF3FCF62BAF1D3300D3B043 /* rtext.c in Sources */ = {isa = PBXBuildFile; fileRef = 1BF3FCEF2BAF1D3300D3B043 /* rtext.c */; }; + 1BF3FCF72BAF1D3300D3B043 /* rmodels.c in Sources */ = {isa = PBXBuildFile; fileRef = 1BF3FCF02BAF1D3300D3B043 /* rmodels.c */; }; + 1BF3FCFD2BAF2CFD00D3B043 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 1BF3FCFC2BAF2CFD00D3B043 /* main.c */; }; /* End PBXBuildFile section */ +/* Begin PBXCopyFilesBuildPhase section */ + 1BF3FCE22BAF1C1900D3B043 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 1BF3FCE12BAF1C1800D3B043 /* libGLESv2.xcframework in Embed Frameworks */, + 1BF3FCDF2BAF1C1800D3B043 /* libEGL.xcframework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ - 1B16D8F82BAEDBEA001FD5E0 /* raylib.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = raylib.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1B16D9032BAEDC41001FD5E0 /* libGLESv2.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = libGLESv2.xcframework; sourceTree = ""; }; 1B16D9042BAEDC41001FD5E0 /* libEGL.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = libEGL.xcframework; sourceTree = ""; }; - 1B3BE73D2BAEE2D700EF4B82 /* rshapes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rshapes.c; path = ../../../src/rshapes.c; sourceTree = ""; }; - 1B3BE73E2BAEE2D700EF4B82 /* utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = utils.c; path = ../../../src/utils.c; sourceTree = ""; }; - 1B3BE73F2BAEE2D700EF4B82 /* rtext.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rtext.c; path = ../../../src/rtext.c; sourceTree = ""; }; - 1B3BE7402BAEE2D700EF4B82 /* rtextures.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rtextures.c; path = ../../../src/rtextures.c; sourceTree = ""; }; - 1B3BE7412BAEE2D700EF4B82 /* raudio.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; name = raudio.c; path = ../../../src/raudio.c; sourceTree = ""; }; - 1B3BE7422BAEE2D700EF4B82 /* rcore.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rcore.c; path = ../../../src/rcore.c; sourceTree = ""; }; - 1B3BE7432BAEE2D700EF4B82 /* rmodels.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rmodels.c; path = ../../../src/rmodels.c; sourceTree = ""; }; - 1BF3FC942BAEE3BD00D3B043 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; }; - 1BF3FC962BAEE3CF00D3B043 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - 1BF3FC982BAEE43800D3B043 /* AVFAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFAudio.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/AVFAudio.framework; sourceTree = DEVELOPER_DIR; }; + 1BF3FCC32BAF1BC900D3B043 /* raylib.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = raylib.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1BF3FCE42BAF1C3000D3B043 /* AVFAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFAudio.framework; path = System/Library/Frameworks/AVFAudio.framework; sourceTree = SDKROOT; }; + 1BF3FCE52BAF1C3000D3B043 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + 1BF3FCE82BAF1C3800D3B043 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1BF3FCEA2BAF1D3300D3B043 /* raudio.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; name = raudio.c; path = ../../../src/raudio.c; sourceTree = ""; }; + 1BF3FCEB2BAF1D3300D3B043 /* utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = utils.c; path = ../../../src/utils.c; sourceTree = ""; }; + 1BF3FCEC2BAF1D3300D3B043 /* rshapes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rshapes.c; path = ../../../src/rshapes.c; sourceTree = ""; }; + 1BF3FCED2BAF1D3300D3B043 /* rtextures.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rtextures.c; path = ../../../src/rtextures.c; sourceTree = ""; }; + 1BF3FCEE2BAF1D3300D3B043 /* rcore.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; name = rcore.c; path = ../../../src/rcore.c; sourceTree = ""; }; + 1BF3FCEF2BAF1D3300D3B043 /* rtext.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rtext.c; path = ../../../src/rtext.c; sourceTree = ""; }; + 1BF3FCF02BAF1D3300D3B043 /* rmodels.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rmodels.c; path = ../../../src/rmodels.c; sourceTree = ""; }; + 1BF3FCFC2BAF2CFD00D3B043 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 1B16D8F52BAEDBEA001FD5E0 /* Frameworks */ = { + 1BF3FCC02BAF1BC900D3B043 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1BF3FC992BAEE43900D3B043 /* AVFAudio.framework in Frameworks */, - 1BF3FC972BAEE3CF00D3B043 /* Foundation.framework in Frameworks */, - 1BF3FC952BAEE3BD00D3B043 /* AVFoundation.framework in Frameworks */, - 1B16D9062BAEDC41001FD5E0 /* libEGL.xcframework in Frameworks */, - 1B16D9052BAEDC41001FD5E0 /* libGLESv2.xcframework in Frameworks */, + 1BF3FCE92BAF1C3800D3B043 /* Foundation.framework in Frameworks */, + 1BF3FCE72BAF1C3000D3B043 /* AVFoundation.framework in Frameworks */, + 1BF3FCE62BAF1C3000D3B043 /* AVFAudio.framework in Frameworks */, + 1BF3FCE02BAF1C1800D3B043 /* libGLESv2.xcframework in Frameworks */, + 1BF3FCDE2BAF1C1800D3B043 /* libEGL.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -56,75 +75,66 @@ 1B16D8EE2BAEDBEA001FD5E0 = { isa = PBXGroup; children = ( - 1B16D8FA2BAEDBEA001FD5E0 /* raylib */, + 1BF3FCFC2BAF2CFD00D3B043 /* main.c */, + 1BF3FCC42BAF1BC900D3B043 /* raylib */, 1B16D8F92BAEDBEA001FD5E0 /* Products */, - 1BF3FC932BAEE3BC00D3B043 /* Frameworks */, + 1BF3FCE32BAF1C3000D3B043 /* Frameworks */, ); sourceTree = ""; }; 1B16D8F92BAEDBEA001FD5E0 /* Products */ = { isa = PBXGroup; children = ( - 1B16D8F82BAEDBEA001FD5E0 /* raylib.framework */, + 1BF3FCC32BAF1BC900D3B043 /* raylib.app */, ); name = Products; sourceTree = ""; }; - 1B16D8FA2BAEDBEA001FD5E0 /* raylib */ = { + 1B16D9022BAEDC1C001FD5E0 /* Frameworks */ = { isa = PBXGroup; children = ( - 1B3BE7412BAEE2D700EF4B82 /* raudio.c */, - 1B3BE7422BAEE2D700EF4B82 /* rcore.c */, - 1B3BE7432BAEE2D700EF4B82 /* rmodels.c */, - 1B3BE73D2BAEE2D700EF4B82 /* rshapes.c */, - 1B3BE73F2BAEE2D700EF4B82 /* rtext.c */, - 1B3BE7402BAEE2D700EF4B82 /* rtextures.c */, - 1B3BE73E2BAEE2D700EF4B82 /* utils.c */, - 1B16D9022BAEDC1C001FD5E0 /* Frameworks */, + 1B16D9042BAEDC41001FD5E0 /* libEGL.xcframework */, + 1B16D9032BAEDC41001FD5E0 /* libGLESv2.xcframework */, ); - path = raylib; + path = Frameworks; sourceTree = ""; }; - 1B16D9022BAEDC1C001FD5E0 /* Frameworks */ = { + 1BF3FCC42BAF1BC900D3B043 /* raylib */ = { isa = PBXGroup; children = ( - 1B16D9042BAEDC41001FD5E0 /* libEGL.xcframework */, - 1B16D9032BAEDC41001FD5E0 /* libGLESv2.xcframework */, + 1BF3FCEA2BAF1D3300D3B043 /* raudio.c */, + 1BF3FCEE2BAF1D3300D3B043 /* rcore.c */, + 1BF3FCF02BAF1D3300D3B043 /* rmodels.c */, + 1BF3FCEC2BAF1D3300D3B043 /* rshapes.c */, + 1BF3FCEF2BAF1D3300D3B043 /* rtext.c */, + 1BF3FCED2BAF1D3300D3B043 /* rtextures.c */, + 1BF3FCEB2BAF1D3300D3B043 /* utils.c */, + 1B16D9022BAEDC1C001FD5E0 /* Frameworks */, ); - path = Frameworks; + path = raylib; sourceTree = ""; }; - 1BF3FC932BAEE3BC00D3B043 /* Frameworks */ = { + 1BF3FCE32BAF1C3000D3B043 /* Frameworks */ = { isa = PBXGroup; children = ( - 1BF3FC982BAEE43800D3B043 /* AVFAudio.framework */, - 1BF3FC962BAEE3CF00D3B043 /* Foundation.framework */, - 1BF3FC942BAEE3BD00D3B043 /* AVFoundation.framework */, + 1BF3FCE82BAF1C3800D3B043 /* Foundation.framework */, + 1BF3FCE42BAF1C3000D3B043 /* AVFAudio.framework */, + 1BF3FCE52BAF1C3000D3B043 /* AVFoundation.framework */, ); name = Frameworks; sourceTree = ""; }; /* End PBXGroup section */ -/* Begin PBXHeadersBuildPhase section */ - 1B16D8F32BAEDBEA001FD5E0 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - /* Begin PBXNativeTarget section */ - 1B16D8F72BAEDBEA001FD5E0 /* raylib */ = { + 1BF3FCC22BAF1BC900D3B043 /* raylib */ = { isa = PBXNativeTarget; - buildConfigurationList = 1B16D8FF2BAEDBEA001FD5E0 /* Build configuration list for PBXNativeTarget "raylib" */; + buildConfigurationList = 1BF3FCDB2BAF1BCB00D3B043 /* Build configuration list for PBXNativeTarget "raylib" */; buildPhases = ( - 1B16D8F32BAEDBEA001FD5E0 /* Headers */, - 1B16D8F42BAEDBEA001FD5E0 /* Sources */, - 1B16D8F52BAEDBEA001FD5E0 /* Frameworks */, - 1B16D8F62BAEDBEA001FD5E0 /* Resources */, + 1BF3FCBF2BAF1BC900D3B043 /* Sources */, + 1BF3FCC02BAF1BC900D3B043 /* Frameworks */, + 1BF3FCC12BAF1BC900D3B043 /* Resources */, + 1BF3FCE22BAF1C1900D3B043 /* Embed Frameworks */, ); buildRules = ( ); @@ -132,8 +142,8 @@ ); name = raylib; productName = raylib; - productReference = 1B16D8F82BAEDBEA001FD5E0 /* raylib.framework */; - productType = "com.apple.product-type.framework"; + productReference = 1BF3FCC32BAF1BC900D3B043 /* raylib.app */; + productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -144,7 +154,7 @@ BuildIndependentTargetsInParallel = 1; LastUpgradeCheck = 1520; TargetAttributes = { - 1B16D8F72BAEDBEA001FD5E0 = { + 1BF3FCC22BAF1BC900D3B043 = { CreatedOnToolsVersion = 15.2; }; }; @@ -162,13 +172,13 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 1B16D8F72BAEDBEA001FD5E0 /* raylib */, + 1BF3FCC22BAF1BC900D3B043 /* raylib */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 1B16D8F62BAEDBEA001FD5E0 /* Resources */ = { + 1BF3FCC12BAF1BC900D3B043 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( @@ -178,17 +188,18 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 1B16D8F42BAEDBEA001FD5E0 /* Sources */ = { + 1BF3FCBF2BAF1BC900D3B043 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 1B3BE7462BAEE2D700EF4B82 /* rtext.c in Sources */, - 1B3BE7442BAEE2D700EF4B82 /* rshapes.c in Sources */, - 1B3BE7472BAEE2D700EF4B82 /* rtextures.c in Sources */, - 1B3BE7492BAEE2D700EF4B82 /* rcore.c in Sources */, - 1B3BE7482BAEE2D700EF4B82 /* raudio.c in Sources */, - 1B3BE7452BAEE2D700EF4B82 /* utils.c in Sources */, - 1B3BE74A2BAEE2D700EF4B82 /* rmodels.c in Sources */, + 1BF3FCF32BAF1D3300D3B043 /* rshapes.c in Sources */, + 1BF3FCF12BAF1D3300D3B043 /* raudio.c in Sources */, + 1BF3FCF42BAF1D3300D3B043 /* rtextures.c in Sources */, + 1BF3FCF62BAF1D3300D3B043 /* rtext.c in Sources */, + 1BF3FCF52BAF1D3300D3B043 /* rcore.c in Sources */, + 1BF3FCFD2BAF2CFD00D3B043 /* main.c in Sources */, + 1BF3FCF22BAF1D3300D3B043 /* utils.c in Sources */, + 1BF3FCF72BAF1D3300D3B043 /* rmodels.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -317,67 +328,79 @@ }; name = Release; }; - 1B16D9002BAEDBEA001FD5E0 /* Debug */ = { + 1BF3FCDC2BAF1BCB00D3B043 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_WARN_COMMA = NO; + CLANG_WARN_STRICT_PROTOTYPES = NO; + CLANG_WARN_UNREACHABLE_CODE = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = NO; DEVELOPMENT_TEAM = A7A93GC9AY; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_MODULE_VERIFIER = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = ""; + INFOPLIST_KEY_UIRequiredDeviceCapabilities = metal; + INFOPLIST_KEY_UIStatusBarHidden = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", - "@loader_path/Frameworks", ); MARKETING_VERSION = 1.0; - MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; - MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; PRODUCT_BUNDLE_IDENTIFIER = com.example.raylib; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../src; }; name = Debug; }; - 1B16D9012BAEDBEA001FD5E0 /* Release */ = { + 1BF3FCDD2BAF1BCB00D3B043 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_WARN_COMMA = NO; + CLANG_WARN_STRICT_PROTOTYPES = NO; + CLANG_WARN_UNREACHABLE_CODE = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = NO; DEVELOPMENT_TEAM = A7A93GC9AY; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_MODULE_VERIFIER = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = ""; + INFOPLIST_KEY_UIRequiredDeviceCapabilities = metal; + INFOPLIST_KEY_UIStatusBarHidden = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", - "@loader_path/Frameworks", ); MARKETING_VERSION = 1.0; - MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; - MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; PRODUCT_BUNDLE_IDENTIFIER = com.example.raylib; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = ../../src; }; name = Release; }; @@ -393,11 +416,11 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 1B16D8FF2BAEDBEA001FD5E0 /* Build configuration list for PBXNativeTarget "raylib" */ = { + 1BF3FCDB2BAF1BCB00D3B043 /* Build configuration list for PBXNativeTarget "raylib" */ = { isa = XCConfigurationList; buildConfigurations = ( - 1B16D9002BAEDBEA001FD5E0 /* Debug */, - 1B16D9012BAEDBEA001FD5E0 /* Release */, + 1BF3FCDC2BAF1BCB00D3B043 /* Debug */, + 1BF3FCDD2BAF1BCB00D3B043 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 45ef07f7b39c..9dfbba5d2343 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -49,11 +49,23 @@ // TODO: Include the platform specific libraries #include "libEGL/libEGL.h" +#import + +/* GameViewController */ +@interface GameViewController : UIViewController +@end + +/* AppDelegate */ +@interface AppDelegate : UIResponder +@property (strong, nonatomic) UIWindow *window; +@end + //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- typedef struct { // TODO: Define the platform specific variables required + GameViewController *viewController; // Root view controller // Display data EGLDisplay device; // Native display device (physical screen connection) @@ -510,7 +522,9 @@ int InitPlatform(void) eglGetConfigAttrib(platform.device, platform.config, EGL_NATIVE_VISUAL_ID, &displayFormat); // eglCreateWindowSurface(platform.device, platform.config, platform.app->window, NULL); - platform.surface = eglCreateWindowSurface(platform.device, platform.config, NULL, NULL); + // bridged cast rootViewController.view.layer; to void* + void* native_window = (__bridge void*)platform.viewController.view.layer; + platform.surface = eglCreateWindowSurface(platform.device, platform.config, native_window, NULL); // There must be at least one frame displayed before the buffers are swapped eglSwapInterval(platform.device, 1); @@ -608,4 +622,61 @@ void ClosePlatform(void) } } + +@implementation GameViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // self.modalPresentationCapturesStatusBarAppearance = true; + platform.viewController = self; +} + +- (bool)prefersStatusBarHidden +{ + return true; +} + +@end + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + NSLog(@"bounds: %@", NSStringFromCGRect([UIScreen mainScreen].bounds)); + self.window.backgroundColor = [UIColor redColor]; + self.window.rootViewController = [[GameViewController alloc] init]; + [self.window makeKeyAndVisible]; + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +@end + +// To allow easier porting to android, we allow the user to define a +// main function which we call from android_main, defined by ourselves +extern int ios_main(int argc, char *argv[]); + +/* main() */ +int main(int argc, char * argv[]) { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); +} + // EOF