From d0a13c68382ca5d5c020fdbb9342175e7c73ad9d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 22 Mar 2024 20:12:40 +0800 Subject: [PATCH 01/44] init --- src/platforms/rcore_ios.c | 591 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 591 insertions(+) create mode 100644 src/platforms/rcore_ios.c diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c new file mode 100644 index 00000000..7a48c465 --- /dev/null +++ b/src/platforms/rcore_ios.c @@ -0,0 +1,591 @@ +/********************************************************************************************** +* +* rcore_ template - Functions to manage window, graphics device and inputs +* +* PLATFORM: +* - TODO: Define the target platform for the core +* +* LIMITATIONS: +* - Limitation 01 +* - Limitation 02 +* +* POSSIBLE IMPROVEMENTS: +* - Improvement 01 +* - Improvement 02 +* +* ADDITIONAL NOTES: +* - TRACELOG() function is located in raylib [utils] module +* +* CONFIGURATION: +* #define RCORE_PLATFORM_CUSTOM_FLAG +* Custom flag for rcore on target platform -not used- +* +* DEPENDENCIES: +* - +* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs) +* +* +* LICENSE: zlib/libpng +* +* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) and contributors +* +* 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. +* +**********************************************************************************************/ + +// TODO: Include the platform specific libraries + +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- +typedef struct { + // TODO: Define the platform specific variables required + + // Display data + EGLDisplay device; // Native display device (physical screen connection) + EGLSurface surface; // Surface to draw on, framebuffers (connected to context) + EGLContext context; // Graphic context, mode in which drawing can be done + EGLConfig config; // Graphic config +} PlatformData; + +//---------------------------------------------------------------------------------- +// Global Variables Definition +//---------------------------------------------------------------------------------- +extern CoreData CORE; // Global CORE state context + +static PlatformData platform = { 0 }; // Platform specific data + +//---------------------------------------------------------------------------------- +// Module Internal Functions Declaration +//---------------------------------------------------------------------------------- +int InitPlatform(void); // Initialize platform (graphics, inputs and more) +bool InitGraphicsDevice(void); // Initialize graphics device + +//---------------------------------------------------------------------------------- +// Module Functions Declaration +//---------------------------------------------------------------------------------- +// NOTE: Functions declaration is provided by raylib.h + +//---------------------------------------------------------------------------------- +// Module Functions Definition: Window and Graphics Device +//---------------------------------------------------------------------------------- + +// Check if application should close +bool WindowShouldClose(void) +{ + if (CORE.Window.ready) return CORE.Window.shouldClose; + else return true; +} + +// Toggle fullscreen mode +void ToggleFullscreen(void) +{ + TRACELOG(LOG_WARNING, "ToggleFullscreen() not available on target platform"); +} + +// Toggle borderless windowed mode +void ToggleBorderlessWindowed(void) +{ + TRACELOG(LOG_WARNING, "ToggleBorderlessWindowed() not available on target platform"); +} + +// Set window state: maximized, if resizable +void MaximizeWindow(void) +{ + TRACELOG(LOG_WARNING, "MaximizeWindow() not available on target platform"); +} + +// Set window state: minimized +void MinimizeWindow(void) +{ + TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform"); +} + +// Set window state: not minimized/maximized +void RestoreWindow(void) +{ + TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform"); +} + +// Set window configuration state using flags +void SetWindowState(unsigned int flags) +{ + TRACELOG(LOG_WARNING, "SetWindowState() not available on target platform"); +} + +// Clear window configuration state flags +void ClearWindowState(unsigned int flags) +{ + TRACELOG(LOG_WARNING, "ClearWindowState() not available on target platform"); +} + +// Set icon for window +void SetWindowIcon(Image image) +{ + TRACELOG(LOG_WARNING, "SetWindowIcon() not available on target platform"); +} + +// Set icon for window +void SetWindowIcons(Image *images, int count) +{ + TRACELOG(LOG_WARNING, "SetWindowIcons() not available on target platform"); +} + +// Set title for window +void SetWindowTitle(const char *title) +{ + CORE.Window.title = title; +} + +// Set window position on screen (windowed mode) +void SetWindowPosition(int x, int y) +{ + TRACELOG(LOG_WARNING, "SetWindowPosition() not available on target platform"); +} + +// Set monitor for the current window +void SetWindowMonitor(int monitor) +{ + TRACELOG(LOG_WARNING, "SetWindowMonitor() not available on target platform"); +} + +// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE) +void SetWindowMinSize(int width, int height) +{ + CORE.Window.screenMin.width = width; + CORE.Window.screenMin.height = height; +} + +// Set window maximum dimensions (FLAG_WINDOW_RESIZABLE) +void SetWindowMaxSize(int width, int height) +{ + CORE.Window.screenMax.width = width; + CORE.Window.screenMax.height = height; +} + +// Set window dimensions +void SetWindowSize(int width, int height) +{ + TRACELOG(LOG_WARNING, "SetWindowSize() not available on target platform"); +} + +// Set window opacity, value opacity is between 0.0 and 1.0 +void SetWindowOpacity(float opacity) +{ + TRACELOG(LOG_WARNING, "SetWindowOpacity() not available on target platform"); +} + +// Set window focused +void SetWindowFocused(void) +{ + TRACELOG(LOG_WARNING, "SetWindowFocused() not available on target platform"); +} + +// Get native window handle +void *GetWindowHandle(void) +{ + TRACELOG(LOG_WARNING, "GetWindowHandle() not implemented on target platform"); + return NULL; +} + +// Get number of monitors +int GetMonitorCount(void) +{ + TRACELOG(LOG_WARNING, "GetMonitorCount() not implemented on target platform"); + return 1; +} + +// Get number of monitors +int GetCurrentMonitor(void) +{ + TRACELOG(LOG_WARNING, "GetCurrentMonitor() not implemented on target platform"); + return 0; +} + +// Get selected monitor position +Vector2 GetMonitorPosition(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorPosition() not implemented on target platform"); + return (Vector2){ 0, 0 }; +} + +// Get selected monitor width (currently used by monitor) +int GetMonitorWidth(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform"); + return 0; +} + +// Get selected monitor height (currently used by monitor) +int GetMonitorHeight(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform"); + return 0; +} + +// Get selected monitor physical width in millimetres +int GetMonitorPhysicalWidth(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() not implemented on target platform"); + return 0; +} + +// Get selected monitor physical height in millimetres +int GetMonitorPhysicalHeight(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() not implemented on target platform"); + return 0; +} + +// Get selected monitor refresh rate +int GetMonitorRefreshRate(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorRefreshRate() not implemented on target platform"); + return 0; +} + +// Get the human-readable, UTF-8 encoded name of the selected monitor +const char *GetMonitorName(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorName() not implemented on target platform"); + return ""; +} + +// Get window position XY on monitor +Vector2 GetWindowPosition(void) +{ + TRACELOG(LOG_WARNING, "GetWindowPosition() not implemented on target platform"); + return (Vector2){ 0, 0 }; +} + +// Get window scale DPI factor for current monitor +Vector2 GetWindowScaleDPI(void) +{ + TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform"); + return (Vector2){ 1.0f, 1.0f }; +} + +// Set clipboard text content +void SetClipboardText(const char *text) +{ + TRACELOG(LOG_WARNING, "SetClipboardText() not implemented on target platform"); +} + +// Get clipboard text content +// NOTE: returned string is allocated and freed by GLFW +const char *GetClipboardText(void) +{ + TRACELOG(LOG_WARNING, "GetClipboardText() not implemented on target platform"); + return NULL; +} + +// Show mouse cursor +void ShowCursor(void) +{ + CORE.Input.Mouse.cursorHidden = false; +} + +// Hides mouse cursor +void HideCursor(void) +{ + CORE.Input.Mouse.cursorHidden = true; +} + +// Enables cursor (unlock cursor) +void EnableCursor(void) +{ + // Set cursor position in the middle + SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); + + CORE.Input.Mouse.cursorHidden = false; +} + +// Disables cursor (lock cursor) +void DisableCursor(void) +{ + // Set cursor position in the middle + SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); + + CORE.Input.Mouse.cursorHidden = true; +} + +// Swap back buffer with front buffer (screen drawing) +void SwapScreenBuffer(void) +{ + eglSwapBuffers(platform.device, platform.surface); +} + +//---------------------------------------------------------------------------------- +// Module Functions Definition: Misc +//---------------------------------------------------------------------------------- + +// Get elapsed time measure in seconds since InitTimer() +double GetTime(void) +{ + double time = 0.0; + struct timespec ts = { 0 }; + clock_gettime(CLOCK_MONOTONIC, &ts); + unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec; + + time = (double)(nanoSeconds - CORE.Time.base)*1e-9; // Elapsed time since InitTimer() + + return time; +} + +// Open URL with default system browser (if available) +// NOTE: This function is only safe to use if you control the URL given. +// A user could craft a malicious string performing another action. +// Only call this function yourself not with user input or make sure to check the string yourself. +// Ref: https://github.com/raysan5/raylib/issues/686 +void OpenURL(const char *url) +{ + // Security check to (partially) avoid malicious code on target platform + if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character"); + else + { + // TODO: + } +} + +//---------------------------------------------------------------------------------- +// Module Functions Definition: Inputs +//---------------------------------------------------------------------------------- + +// Set internal gamepad mappings +int SetGamepadMappings(const char *mappings) +{ + TRACELOG(LOG_WARNING, "SetGamepadMappings() not implemented on target platform"); + return 0; +} + +// Set mouse position XY +void SetMousePosition(int x, int y) +{ + CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y }; + CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; +} + +// Set mouse cursor +void SetMouseCursor(int cursor) +{ + TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform"); +} + +// Register all input events +void PollInputEvents(void) +{ +#if defined(SUPPORT_GESTURES_SYSTEM) + // NOTE: Gestures update must be called every frame to reset gestures correctly + // because ProcessGestureEvent() is just called on an event, not every frame + UpdateGestures(); +#endif + + // Reset keys/chars pressed registered + CORE.Input.Keyboard.keyPressedQueueCount = 0; + CORE.Input.Keyboard.charPressedQueueCount = 0; + + // Reset key repeats + for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0; + + // Reset last gamepad button/axis registered state + CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN + //CORE.Input.Gamepad.axisCount = 0; + + // Register previous touch states + for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i]; + + // Reset touch positions + // TODO: It resets on target platform the mouse position and not filled again until a move-event, + // so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed! + //for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; + + // Register previous keys states + // NOTE: Android supports up to 260 keys + for (int i = 0; i < 260; i++) + { + CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i]; + CORE.Input.Keyboard.keyRepeatInFrame[i] = 0; + } + + // TODO: Poll input events for current platform +} + + +//---------------------------------------------------------------------------------- +// Module Internal Functions Definition +//---------------------------------------------------------------------------------- + +// Initialize platform: graphics, inputs and more +int InitPlatform(void) +{ + // TODO: Initialize graphic device: display/window + // It usually requires setting up the platform display system configuration + // and connexion with the GPU through some system graphic API + // raylib uses OpenGL so, platform should create that kind of connection + // Below example illustrates that process using EGL library + //---------------------------------------------------------------------------- + CORE.Window.fullscreen = true; + CORE.Window.flags |= FLAG_FULLSCREEN_MODE; + + EGLint samples = 0; + EGLint sampleBuffer = 0; + if (CORE.Window.flags & FLAG_MSAA_4X_HINT) + { + samples = 4; + sampleBuffer = 1; + TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4"); + } + + const EGLint framebufferAttribs[] = + { + EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support + EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5) + EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6) + EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5) + //EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI) + EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!) + //EGL_STENCIL_SIZE, 8, // Stencil buffer size + EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA + EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs) + EGL_NONE + }; + + const EGLint contextAttribs[] = + { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + + EGLint numConfigs = 0; + + // Get an EGL device connection + platform.device = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (platform.device == EGL_NO_DISPLAY) + { + TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device"); + return false; + } + + // Initialize the EGL device connection + if (eglInitialize(platform.device, NULL, NULL) == EGL_FALSE) + { + // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred. + TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device"); + return false; + } + + // Get an appropriate EGL framebuffer configuration + eglChooseConfig(platform.device, framebufferAttribs, &platform.config, 1, &numConfigs); + + // Set rendering API + eglBindAPI(EGL_OPENGL_ES_API); + + // Create an EGL rendering context + platform.context = eglCreateContext(platform.device, platform.config, EGL_NO_CONTEXT, contextAttribs); + if (platform.context == EGL_NO_CONTEXT) + { + TRACELOG(LOG_WARNING, "DISPLAY: Failed to create EGL context"); + return -1; + } + + // Create an EGL window surface + EGLint displayFormat = 0; + + // EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is guaranteed to be accepted by ANativeWindow_setBuffersGeometry() + // As soon as we picked a EGLConfig, we can safely reconfigure the ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID + eglGetConfigAttrib(platform.device, platform.config, EGL_NATIVE_VISUAL_ID, &displayFormat); + + // Android specific call + ANativeWindow_setBuffersGeometry(platform.app->window, 0, 0, displayFormat); // Force use of native display size + + platform.surface = eglCreateWindowSurface(platform.device, platform.config, platform.app->window, NULL); + + // There must be at least one frame displayed before the buffers are swapped + eglSwapInterval(platform.device, 1); + + EGLBoolean result = eglMakeCurrent(platform.device, platform.surface, platform.surface, platform.context); + + // Check surface and context activation + if (result != EGL_FALSE) + { + CORE.Window.ready = true; + + CORE.Window.render.width = CORE.Window.screen.width; + CORE.Window.render.height = CORE.Window.screen.height; + CORE.Window.currentFbo.width = CORE.Window.render.width; + CORE.Window.currentFbo.height = CORE.Window.render.height; + + TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); + TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); + TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); + TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); + TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); + } + else + { + TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphics device"); + return -1; + } + //---------------------------------------------------------------------------- + + // If everything work as expected, we can continue + CORE.Window.render.width = CORE.Window.screen.width; + CORE.Window.render.height = CORE.Window.screen.height; + CORE.Window.currentFbo.width = CORE.Window.render.width; + CORE.Window.currentFbo.height = CORE.Window.render.height; + + TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); + TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); + TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); + TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); + TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); + + // TODO: Load OpenGL extensions + // NOTE: GL procedures address loader is required to load extensions + //---------------------------------------------------------------------------- + rlLoadExtensions(eglGetProcAddress); + //---------------------------------------------------------------------------- + + // TODO: Initialize input events system + // It could imply keyboard, mouse, gamepad, touch... + // Depending on the platform libraries/SDK it could use a callback mechanism + // For system events and inputs evens polling on a per-frame basis, use PollInputEvents() + //---------------------------------------------------------------------------- + // ... + //---------------------------------------------------------------------------- + + // TODO: Initialize timing system + //---------------------------------------------------------------------------- + InitTimer(); + //---------------------------------------------------------------------------- + + // TODO: Initialize storage system + //---------------------------------------------------------------------------- + CORE.Storage.basePath = GetWorkingDirectory(); + //---------------------------------------------------------------------------- + + TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully"); + + return 0; +} + +// Close platform +void ClosePlatform(void) +{ + // TODO: De-initialize graphics, inputs and more +} + +// EOF From 0caa4133a87fb4d57feecf33b3dd9e7b78dd0ddb Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 23 Mar 2024 18:36:57 +0800 Subject: [PATCH 02/44] create XCode15 project targeting iOS --- .../Xcode15/raylib.xcodeproj/project.pbxproj | 408 ++++++++++++++++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 + projects/Xcode15/raylib/.gitignore | 1 + src/platforms/rcore_ios.c | 7 +- src/rcore.c | 2 + 5 files changed, 422 insertions(+), 4 deletions(-) create mode 100644 projects/Xcode15/raylib.xcodeproj/project.pbxproj create mode 100644 projects/Xcode15/raylib.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 projects/Xcode15/raylib/.gitignore diff --git a/projects/Xcode15/raylib.xcodeproj/project.pbxproj b/projects/Xcode15/raylib.xcodeproj/project.pbxproj new file mode 100644 index 00000000..11cc79bb --- /dev/null +++ b/projects/Xcode15/raylib.xcodeproj/project.pbxproj @@ -0,0 +1,408 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + 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 */; }; +/* End PBXBuildFile 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; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1B16D8F52BAEDBEA001FD5E0 /* 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 */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1B16D8EE2BAEDBEA001FD5E0 = { + isa = PBXGroup; + children = ( + 1B16D8FA2BAEDBEA001FD5E0 /* raylib */, + 1B16D8F92BAEDBEA001FD5E0 /* Products */, + 1BF3FC932BAEE3BC00D3B043 /* Frameworks */, + ); + sourceTree = ""; + }; + 1B16D8F92BAEDBEA001FD5E0 /* Products */ = { + isa = PBXGroup; + children = ( + 1B16D8F82BAEDBEA001FD5E0 /* raylib.framework */, + ); + name = Products; + sourceTree = ""; + }; + 1B16D8FA2BAEDBEA001FD5E0 /* raylib */ = { + 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 */, + ); + path = raylib; + sourceTree = ""; + }; + 1B16D9022BAEDC1C001FD5E0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1B16D9042BAEDC41001FD5E0 /* libEGL.xcframework */, + 1B16D9032BAEDC41001FD5E0 /* libGLESv2.xcframework */, + ); + path = Frameworks; + sourceTree = ""; + }; + 1BF3FC932BAEE3BC00D3B043 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1BF3FC982BAEE43800D3B043 /* AVFAudio.framework */, + 1BF3FC962BAEE3CF00D3B043 /* Foundation.framework */, + 1BF3FC942BAEE3BD00D3B043 /* 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 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1B16D8FF2BAEDBEA001FD5E0 /* Build configuration list for PBXNativeTarget "raylib" */; + buildPhases = ( + 1B16D8F32BAEDBEA001FD5E0 /* Headers */, + 1B16D8F42BAEDBEA001FD5E0 /* Sources */, + 1B16D8F52BAEDBEA001FD5E0 /* Frameworks */, + 1B16D8F62BAEDBEA001FD5E0 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = raylib; + productName = raylib; + productReference = 1B16D8F82BAEDBEA001FD5E0 /* raylib.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1B16D8EF2BAEDBEA001FD5E0 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1520; + TargetAttributes = { + 1B16D8F72BAEDBEA001FD5E0 = { + CreatedOnToolsVersion = 15.2; + }; + }; + }; + buildConfigurationList = 1B16D8F22BAEDBEA001FD5E0 /* Build configuration list for PBXProject "raylib" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 1B16D8EE2BAEDBEA001FD5E0; + productRefGroup = 1B16D8F92BAEDBEA001FD5E0 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1B16D8F72BAEDBEA001FD5E0 /* raylib */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1B16D8F62BAEDBEA001FD5E0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1B16D8F42BAEDBEA001FD5E0 /* 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 */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1B16D8FD2BAEDBEA001FD5E0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "c++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = NO; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = c17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 1B16D8FE2BAEDBEA001FD5E0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "c++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = NO; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = c17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 1B16D9002BAEDBEA001FD5E0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_COMMA = 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_WARN_64_TO_32_BIT_CONVERSION = NO; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + 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; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1B16D9012BAEDBEA001FD5E0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_COMMA = 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_WARN_64_TO_32_BIT_CONVERSION = NO; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + 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; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1B16D8F22BAEDBEA001FD5E0 /* Build configuration list for PBXProject "raylib" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1B16D8FD2BAEDBEA001FD5E0 /* Debug */, + 1B16D8FE2BAEDBEA001FD5E0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1B16D8FF2BAEDBEA001FD5E0 /* Build configuration list for PBXNativeTarget "raylib" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1B16D9002BAEDBEA001FD5E0 /* Debug */, + 1B16D9012BAEDBEA001FD5E0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1B16D8EF2BAEDBEA001FD5E0 /* Project object */; +} diff --git a/projects/Xcode15/raylib.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/projects/Xcode15/raylib.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/projects/Xcode15/raylib.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/projects/Xcode15/raylib/.gitignore b/projects/Xcode15/raylib/.gitignore new file mode 100644 index 00000000..358491a9 --- /dev/null +++ b/projects/Xcode15/raylib/.gitignore @@ -0,0 +1 @@ +Frameworks diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 7a48c465..5ba5edeb 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -47,6 +47,7 @@ **********************************************************************************************/ // TODO: Include the platform specific libraries +#include "libEGL/libEGL.h" //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -508,10 +509,8 @@ int InitPlatform(void) // As soon as we picked a EGLConfig, we can safely reconfigure the ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID eglGetConfigAttrib(platform.device, platform.config, EGL_NATIVE_VISUAL_ID, &displayFormat); - // Android specific call - ANativeWindow_setBuffersGeometry(platform.app->window, 0, 0, displayFormat); // Force use of native display size - - platform.surface = eglCreateWindowSurface(platform.device, platform.config, platform.app->window, NULL); + // eglCreateWindowSurface(platform.device, platform.config, platform.app->window, NULL); + platform.surface = eglCreateWindowSurface(platform.device, platform.config, NULL, NULL); // There must be at least one frame displayed before the buffers are swapped eglSwapInterval(platform.device, 1); diff --git a/src/rcore.c b/src/rcore.c index dcdc3bef..4da6f547 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -502,6 +502,8 @@ const char *TextFormat(const char *text, ...); // Formatting of tex #include "platforms/rcore_drm.c" #elif defined(PLATFORM_ANDROID) #include "platforms/rcore_android.c" +#elif defined(PLATFORM_IOS) || defined(PLATFORM_IOSSIMULATOR) + #include "platforms/rcore_ios.c" #else // TODO: Include your custom platform backend! // i.e software rendering backend or console backend! From b3b2d50d583d43f17b6557f2f8de16edd3a7786f Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 23 Mar 2024 18:53:32 +0800 Subject: [PATCH 03/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 5ba5edeb..45ef07f7 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -2,8 +2,8 @@ * * rcore_ template - Functions to manage window, graphics device and inputs * -* PLATFORM: -* - TODO: Define the target platform for the core +* PLATFORM: IOS +* - iOS (arm64) * * LIMITATIONS: * - Limitation 01 @@ -357,7 +357,7 @@ void OpenURL(const char *url) if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character"); else { - // TODO: + TRACELOG(LOG_WARNING, "OpenURL() not implemented on target platform"); } } @@ -585,6 +585,27 @@ int InitPlatform(void) void ClosePlatform(void) { // TODO: De-initialize graphics, inputs and more + + // Close surface, context and display + if (platform.device != EGL_NO_DISPLAY) + { + eglMakeCurrent(platform.device, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (platform.surface != EGL_NO_SURFACE) + { + eglDestroySurface(platform.device, platform.surface); + platform.surface = EGL_NO_SURFACE; + } + + if (platform.context != EGL_NO_CONTEXT) + { + eglDestroyContext(platform.device, platform.context); + platform.context = EGL_NO_CONTEXT; + } + + eglTerminate(platform.device); + platform.device = EGL_NO_DISPLAY; + } } // EOF From dfc6dc2fa115889d39a2a18912489d275b993368 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 23 Mar 2024 23:31:09 +0800 Subject: [PATCH 04/44] 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 00000000..c603fd0c --- /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 11cc79bb..191082c8 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 45ef07f7..9dfbba5d 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 From d1ffab40cc58d213dfeab7faa67152603ac705bd Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 24 Mar 2024 01:01:30 +0800 Subject: [PATCH 05/44] the first working version --- projects/Xcode15/main.c | 201 +++++++++--------- .../Xcode15/raylib.xcodeproj/project.pbxproj | 9 + src/platforms/rcore_ios.c | 39 +++- src/rcore.c | 2 +- src/rlgl.h | 9 +- 5 files changed, 146 insertions(+), 114 deletions(-) diff --git a/projects/Xcode15/main.c b/projects/Xcode15/main.c index c603fd0c..ee07d156 100644 --- a/projects/Xcode15/main.c +++ b/projects/Xcode15/main.c @@ -20,126 +20,120 @@ //------------------------------------------------------------------------------------------ typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen; -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int ios_main(int argc, char * argv[]) -{ +const int screenWidth = 800; +const int screenHeight = 450; +GameScreen currentScreen = LOGO; +int framesCounter = 0; // Useful to count frames + +void ios_ready(){ // 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 + +void ios_update() +{ + // Update + //---------------------------------------------------------------------------------- + switch(currentScreen) { - // Update - //---------------------------------------------------------------------------------- - switch(currentScreen) + case LOGO: { - 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) { - // 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: + 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)) { - // 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: + 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)) { - // 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) + 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)) { - 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; + currentScreen = TITLE; } - - EndDrawing(); - //---------------------------------------------------------------------------------- + } 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(); + //---------------------------------------------------------------------------------- +} +void ios_destroy(){ // De-Initialization //-------------------------------------------------------------------------------------- @@ -148,5 +142,4 @@ int ios_main(int argc, char * argv[]) 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 191082c8..7f6a8a0d 100644 --- a/projects/Xcode15/raylib.xcodeproj/project.pbxproj +++ b/projects/Xcode15/raylib.xcodeproj/project.pbxproj @@ -341,6 +341,11 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = A7A93GC9AY; GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + GRAPHICS_API_OPENGL_ES2, + PLATFORM_IOS, + ); GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -379,6 +384,10 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = A7A93GC9AY; GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_PREPROCESSOR_DEFINITIONS = ( + GRAPHICS_API_OPENGL_ES2, + PLATFORM_IOS, + ); GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_INFOPLIST_FILE = YES; diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 9dfbba5d..ef3aceb4 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -49,10 +49,17 @@ // TODO: Include the platform specific libraries #include "libEGL/libEGL.h" +// iOS only supports callbacks +// We are not able to give users full control of the game loop +extern void ios_ready(); +extern void ios_update(); +extern void ios_destroy(); + #import /* GameViewController */ @interface GameViewController : UIViewController +- (void)update; @end /* AppDelegate */ @@ -476,10 +483,17 @@ int InitPlatform(void) EGL_NONE }; +// const EGLint contextAttribs[] = +// { +// EGL_CONTEXT_CLIENT_VERSION, 2, +// EGL_NONE +// }; + const EGLint contextAttribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE + EGL_CONTEXT_MAJOR_VERSION, 2, + EGL_CONTEXT_MINOR_VERSION, 0, + EGL_NONE, }; EGLint numConfigs = 0; @@ -590,7 +604,7 @@ int InitPlatform(void) CORE.Storage.basePath = GetWorkingDirectory(); //---------------------------------------------------------------------------- - TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully"); + TRACELOG(LOG_INFO, "PLATFORM: IOS: Initialized successfully"); return 0; } @@ -632,6 +646,11 @@ void ClosePlatform(void) platform.viewController = self; } +- (void)update +{ + ios_update(); +} + - (bool)prefersStatusBarHidden { return true; @@ -644,10 +663,14 @@ void ClosePlatform(void) - (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]; + + ios_ready(); + + CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self.window.rootViewController selector:@selector(update)]; + [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; return YES; } @@ -668,11 +691,11 @@ void ClosePlatform(void) // 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 +- (void)applicationWillTerminate:(UIApplication *)application { + ios_destroy(); +} -// 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[]); +@end /* main() */ int main(int argc, char * argv[]) { diff --git a/src/rcore.c b/src/rcore.c index 4da6f547..ca184849 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -502,7 +502,7 @@ const char *TextFormat(const char *text, ...); // Formatting of tex #include "platforms/rcore_drm.c" #elif defined(PLATFORM_ANDROID) #include "platforms/rcore_android.c" -#elif defined(PLATFORM_IOS) || defined(PLATFORM_IOSSIMULATOR) +#elif defined(PLATFORM_IOS) #include "platforms/rcore_ios.c" #else // TODO: Include your custom platform backend! diff --git a/src/rlgl.h b/src/rlgl.h index 0f784025..b13c595f 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -815,7 +815,14 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad #include "external/glad.h" // GLAD extensions loading library, includes OpenGL headers #endif -#if defined(GRAPHICS_API_OPENGL_ES3) +#if defined(PLATFORM_IOS) + #ifndef GRAPHICS_API_OPENGL_ES2 + #error "GRAPHICS_API_OPENGL_ES2 required on PLATFORM_IOS" + #endif + #include "libGLESv2/GLES/glext.h" + #include "libGLESv2/GLES2/gl2.h" + #include "libGLESv2/GLES2/gl2ext.h" // OpenGL ES 2.0 extensions library +#elif defined(GRAPHICS_API_OPENGL_ES3) #include // OpenGL ES 3.0 library #define GL_GLEXT_PROTOTYPES #include // OpenGL ES 2.0 extensions library From cae863af450fb58ffe58a2d76af1a8876b20cf6a Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 24 Mar 2024 01:41:35 +0800 Subject: [PATCH 06/44] some fix --- projects/Xcode15/main.c | 9 ++++-- src/platforms/rcore_ios.c | 59 ++++++++++++++++++++------------------- src/rcore.c | 2 ++ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/projects/Xcode15/main.c b/projects/Xcode15/main.c index ee07d156..06d8fd58 100644 --- a/projects/Xcode15/main.c +++ b/projects/Xcode15/main.c @@ -20,15 +20,17 @@ //------------------------------------------------------------------------------------------ typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen; -const int screenWidth = 800; -const int screenHeight = 450; +int screenWidth = 0; +int screenHeight = 0; GameScreen currentScreen = LOGO; int framesCounter = 0; // Useful to count frames void ios_ready(){ // Initialization //-------------------------------------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib [core] example - basic screen manager"); + InitWindow(0, 0, "raylib [core] example - basic screen manager"); + screenWidth = GetScreenWidth(); + screenHeight = GetScreenHeight(); // TODO: Initialize all required variables and load all required data here! SetTargetFPS(60); // Set desired framerate (frames-per-second) @@ -129,6 +131,7 @@ void ios_update() default: break; } + DrawFPS(screenWidth / 2, 0); EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index ef3aceb4..d7bcf528 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -440,7 +440,8 @@ void PollInputEvents(void) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0; } - // TODO: Poll input events for current platform + // TODO: Poll input events for iOS + } @@ -451,6 +452,24 @@ void PollInputEvents(void) // Initialize platform: graphics, inputs and more int InitPlatform(void) { + if(CORE.Window.screen.width == 0){ + CORE.Window.screen.width = platform.viewController.view.frame.size.width; + } + if(CORE.Window.screen.height == 0){ + CORE.Window.screen.height = platform.viewController.view.frame.size.height; + } + + int orientation = [[UIApplication sharedApplication] statusBarOrientation]; + if(orientation == UIInterfaceOrientationPortrait){ + TRACELOG(LOG_INFO, "IOS: Window orientation set as Portrait"); + }else if(orientation == UIInterfaceOrientationPortraitUpsideDown){ + TRACELOG(LOG_INFO, "IOS: Window orientation set as PortraitUpsideDown"); + }else if(orientation == UIInterfaceOrientationLandscapeLeft){ + TRACELOG(LOG_INFO, "IOS: Window orientation set as LandscapeLeft"); + }else if(orientation == UIInterfaceOrientationLandscapeRight){ + TRACELOG(LOG_INFO, "IOS: Window orientation set as LandscapeRight"); + } + // TODO: Initialize graphic device: display/window // It usually requires setting up the platform display system configuration // and connexion with the GPU through some system graphic API @@ -541,15 +560,15 @@ int InitPlatform(void) 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); + //eglSwapInterval(platform.device, 1); - EGLBoolean result = eglMakeCurrent(platform.device, platform.surface, platform.surface, platform.context); - - // Check surface and context activation - if (result != EGL_FALSE) + if (eglMakeCurrent(platform.device, platform.surface, platform.surface, platform.context) == EGL_FALSE) + { + TRACELOG(LOG_WARNING, "DISPLAY: Failed to attach EGL rendering context to EGL surface"); + return -1; + } + else { - CORE.Window.ready = true; - CORE.Window.render.width = CORE.Window.screen.width; CORE.Window.render.height = CORE.Window.screen.height; CORE.Window.currentFbo.width = CORE.Window.render.width; @@ -561,30 +580,12 @@ int InitPlatform(void) TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); } - else - { - TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphics device"); - return -1; - } //---------------------------------------------------------------------------- - - // If everything work as expected, we can continue - CORE.Window.render.width = CORE.Window.screen.width; - CORE.Window.render.height = CORE.Window.screen.height; - CORE.Window.currentFbo.width = CORE.Window.render.width; - CORE.Window.currentFbo.height = CORE.Window.render.height; - - TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); - TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); - TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); - TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); - TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); - - // TODO: Load OpenGL extensions + // Load OpenGL extensions // NOTE: GL procedures address loader is required to load extensions - //---------------------------------------------------------------------------- rlLoadExtensions(eglGetProcAddress); - //---------------------------------------------------------------------------- + + CORE.Window.ready = true; // TODO: Initialize input events system // It could imply keyboard, mouse, gamepad, touch... diff --git a/src/rcore.c b/src/rcore.c index ca184849..7c39a236 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -572,6 +572,8 @@ void InitWindow(int width, int height, const char *title) TRACELOG(LOG_INFO, "Platform backend: NATIVE DRM"); #elif defined(PLATFORM_ANDROID) TRACELOG(LOG_INFO, "Platform backend: ANDROID"); +#elif defined(PLATFORM_IOS) + TRACELOG(LOG_INFO, "Platform backend: IOS"); #else // TODO: Include your custom platform backend! // i.e software rendering backend or console backend! From 29006070f48d889b674bcba4e0d807376c4f654c Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 24 Mar 2024 01:59:56 +0800 Subject: [PATCH 07/44] prepare to add touch callbacks --- src/platforms/rcore_ios.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index d7bcf528..d917b9e6 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -60,6 +60,11 @@ extern void ios_destroy(); /* GameViewController */ @interface GameViewController : UIViewController - (void)update; +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesEstimatedPropertiesUpdated:(NSSet *)touches; @end /* AppDelegate */ @@ -71,7 +76,6 @@ extern void ios_destroy(); // Types and Structures Definition //---------------------------------------------------------------------------------- typedef struct { - // TODO: Define the platform specific variables required GameViewController *viewController; // Root view controller // Display data @@ -92,7 +96,6 @@ static PlatformData platform = { 0 }; // Platform specific data // Module Internal Functions Declaration //---------------------------------------------------------------------------------- int InitPlatform(void); // Initialize platform (graphics, inputs and more) -bool InitGraphicsDevice(void); // Initialize graphics device //---------------------------------------------------------------------------------- // Module Functions Declaration @@ -441,7 +444,9 @@ void PollInputEvents(void) } // TODO: Poll input events for iOS - + + // Register touch points count + // https://developer.apple.com/documentation/uikit/touches_presses_and_gestures } @@ -645,6 +650,7 @@ void ClosePlatform(void) [super viewDidLoad]; // self.modalPresentationCapturesStatusBarAppearance = true; platform.viewController = self; + self.view.multipleTouchEnabled = true; } - (void)update From 74da3b7a769afdc6bc4681c4f7bbb336e708f096 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 24 Mar 2024 02:37:22 +0800 Subject: [PATCH 08/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 55 +++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index d917b9e6..4f2201ad 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -64,7 +64,7 @@ extern void ios_destroy(); - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; -- (void)touchesEstimatedPropertiesUpdated:(NSSet *)touches; +//- (void)touchesEstimatedPropertiesUpdated:(NSSet *)touches; @end /* AppDelegate */ @@ -444,8 +444,6 @@ void PollInputEvents(void) } // TODO: Poll input events for iOS - - // Register touch points count // https://developer.apple.com/documentation/uikit/touches_presses_and_gestures } @@ -653,14 +651,61 @@ void ClosePlatform(void) self.view.multipleTouchEnabled = true; } +- (bool)prefersStatusBarHidden +{ + return true; +} + - (void)update { ios_update(); } -- (bool)prefersStatusBarHidden +void call_gesture(int action) { - return true; +#if defined(SUPPORT_GESTURES_SYSTEM) + GestureEvent gestureEvent = { 0 }; + + gestureEvent.pointCount = CORE.Input.Touch.pointCount; + + // Register touch actions + gestureEvent.touchAction = action; + + for (int i = 0; (i < gestureEvent.pointCount) && (i < MAX_TOUCH_POINTS); i++) + { + gestureEvent.pointId[i] = CORE.Input.Touch.pointId[i]; + gestureEvent.position[i] = CORE.Input.Touch.position[i]; + gestureEvent.position[i].x /= (float)GetScreenWidth(); + gestureEvent.position[i].y /= (float)GetScreenHeight(); + } + + // Gesture data is sent to gestures system for processing + ProcessGestureEvent(gestureEvent); +#endif +} + +// touch callbacks +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + CORE.Input.Touch.pointCount += touches.count; + if (CORE.Input.Touch.pointCount > 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1; + for(UITouch* touch in touches) call_gesture(TOUCH_ACTION_DOWN); +} +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + CORE.Input.Touch.pointCount -= touches.count; + if (CORE.Input.Touch.pointCount == 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0; + for(UITouch* touch in touches) call_gesture(TOUCH_ACTION_UP); +} +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + for(UITouch* touch in touches) call_gesture(TOUCH_ACTION_MOVE); +} +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event +{ + CORE.Input.Touch.pointCount = 0; + CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0; + for(UITouch* touch in touches) call_gesture(TOUCH_ACTION_CANCEL); } @end From 9f7dec63ef85190f33a915ff8f5a841e55aacfab Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 24 Mar 2024 13:41:58 +0800 Subject: [PATCH 09/44] support more touches --- projects/Xcode15/main.c | 188 ++++++++---------- .../Xcode15/raylib.xcodeproj/project.pbxproj | 8 +- src/platforms/rcore_ios.c | 112 ++++++++--- 3 files changed, 169 insertions(+), 139 deletions(-) diff --git a/projects/Xcode15/main.c b/projects/Xcode15/main.c index 06d8fd58..7fa60769 100644 --- a/projects/Xcode15/main.c +++ b/projects/Xcode15/main.c @@ -1,148 +1,120 @@ /******************************************************************************************* * -* raylib [core] examples - basic screen manager +* raylib [core] example - Input Gestures Detection * -* 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 originally created with raylib 1.4, last time updated with raylib 4.2 * * 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) +* Copyright (c) 2016-2024 Ramon Santamaria (@raysan5) * ********************************************************************************************/ #include "raylib.h" -//------------------------------------------------------------------------------------------ -// Types and Structures Definition -//------------------------------------------------------------------------------------------ -typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen; - +int MAX_GESTURE_STRINGS = 20; int screenWidth = 0; int screenHeight = 0; -GameScreen currentScreen = LOGO; -int framesCounter = 0; // Useful to count frames +Vector2 touchPosition; +Rectangle touchArea; +int gesturesCount = 0; +char gestureStrings[100][32]; +int currentGesture = GESTURE_NONE; +int lastGesture = GESTURE_NONE; void ios_ready(){ - // Initialization - //-------------------------------------------------------------------------------------- - InitWindow(0, 0, "raylib [core] example - basic screen manager"); + InitWindow(0, 0, "raylib [core] example - input gestures"); + screenWidth = GetScreenWidth(); screenHeight = GetScreenHeight(); - - // TODO: Initialize all required variables and load all required data here! - SetTargetFPS(60); // Set desired framerate (frames-per-second) - //-------------------------------------------------------------------------------------- + + touchPosition = (Vector2){ 0, 0 }; + touchArea = (Rectangle){ 220, 10, screenWidth - 230.0f, screenHeight - 20.0f }; + + //SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected + SetTargetFPS(60); + MAX_GESTURE_STRINGS = (screenHeight - 50) / 20; } +static void add_gesture(const char* title){ + if (gesturesCount >= MAX_GESTURE_STRINGS) + { + for (int i = 0; i < MAX_GESTURE_STRINGS; i++) TextCopy(gestureStrings[i], "\0"); + gesturesCount = 0; + } + TextCopy(gestureStrings[gesturesCount], title); + gesturesCount++; +} void ios_update() { - // Update - //---------------------------------------------------------------------------------- - switch(currentScreen) + lastGesture = currentGesture; + currentGesture = GetGestureDetected(); + touchPosition = GetTouchPosition(0); + + if(IsMouseButtonPressed(0)) add_gesture("MouseButtonPressed"); + if(IsMouseButtonReleased(0)) add_gesture("MouseButtonReleased"); + + if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != GESTURE_NONE)) { - 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: + if (currentGesture != lastGesture) { - // TODO: Update ENDING screen variables here! - - // Press enter to return to TITLE screen - if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) + // Store gesture string + switch (currentGesture) { - currentScreen = TITLE; + case GESTURE_TAP: add_gesture( "GESTURE TAP"); break; + case GESTURE_DOUBLETAP: add_gesture( "GESTURE DOUBLETAP"); break; + case GESTURE_HOLD: add_gesture( "GESTURE HOLD"); break; + case GESTURE_DRAG: add_gesture( "GESTURE DRAG"); break; + case GESTURE_SWIPE_RIGHT: add_gesture( "GESTURE SWIPE RIGHT"); break; + case GESTURE_SWIPE_LEFT: add_gesture( "GESTURE SWIPE LEFT"); break; + case GESTURE_SWIPE_UP: add_gesture( "GESTURE SWIPE UP"); break; + case GESTURE_SWIPE_DOWN: add_gesture( "GESTURE SWIPE DOWN"); break; + case GESTURE_PINCH_IN: add_gesture( "GESTURE PINCH IN"); break; + case GESTURE_PINCH_OUT: add_gesture( "GESTURE PINCH OUT"); break; + default: break; } - } break; - default: break; + } } - //---------------------------------------------------------------------------------- - + // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + ClearBackground(RAYWHITE); - - switch(currentScreen) + + DrawRectangleRec(touchArea, GRAY); + DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE); + + DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5f)); + + for (int i = 0; i < gesturesCount; i++) { - 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; + if (i % 2 == 0){ + DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.5f)); + }else{ + DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.3f)); + } + if (i < gesturesCount - 1){ + DrawText(gestureStrings[i], 35, 36 + 20*i, 10, DARKGRAY); + }else{ + DrawText(gestureStrings[i], 35, 36 + 20*i, 10, MAROON); + } + } + + DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY); + DrawText( + TextFormat("TOUCH COUNT: %d", GetTouchPointCount()), + 50, 15, 10, GRAY + ); + + for(int i=0; i < GetTouchPointCount(); i++){ + DrawCircleV(GetTouchPosition(i), 30, MAROON); } - - DrawFPS(screenWidth / 2, 0); EndDrawing(); - //---------------------------------------------------------------------------------- } void ios_destroy(){ - // De-Initialization - //-------------------------------------------------------------------------------------- - - // TODO: Unload all loaded data (textures, fonts, audio) here! - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - } diff --git a/projects/Xcode15/raylib.xcodeproj/project.pbxproj b/projects/Xcode15/raylib.xcodeproj/project.pbxproj index 7f6a8a0d..c11484b8 100644 --- a/projects/Xcode15/raylib.xcodeproj/project.pbxproj +++ b/projects/Xcode15/raylib.xcodeproj/project.pbxproj @@ -354,9 +354,9 @@ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = ""; INFOPLIST_KEY_UIRequiredDeviceCapabilities = metal; + INFOPLIST_KEY_UIRequiresFullScreen = YES; INFOPLIST_KEY_UIStatusBarHidden = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -396,9 +396,9 @@ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = ""; INFOPLIST_KEY_UIRequiredDeviceCapabilities = metal; + INFOPLIST_KEY_UIRequiresFullScreen = YES; INFOPLIST_KEY_UIStatusBarHidden = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 4f2201ad..cd95530c 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -1,13 +1,13 @@ /********************************************************************************************** * -* rcore_ template - Functions to manage window, graphics device and inputs +* rcore_ios - Functions to manage window, graphics device and touch inputs * * PLATFORM: IOS * - iOS (arm64) * * LIMITATIONS: -* - Limitation 01 -* - Limitation 02 +* - No keyboard input support +* - No gamepad input support * * POSSIBLE IMPROVEMENTS: * - Improvement 01 @@ -21,7 +21,7 @@ * Custom flag for rcore on target platform -not used- * * DEPENDENCIES: -* - +* - ANGLE for iOS * - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs) * * @@ -48,6 +48,7 @@ // TODO: Include the platform specific libraries #include "libEGL/libEGL.h" +#include // iOS only supports callbacks // We are not able to give users full control of the game loop @@ -60,11 +61,6 @@ extern void ios_destroy(); /* GameViewController */ @interface GameViewController : UIViewController - (void)update; -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; -//- (void)touchesEstimatedPropertiesUpdated:(NSSet *)touches; @end /* AppDelegate */ @@ -661,7 +657,28 @@ void ClosePlatform(void) ios_update(); } -void call_gesture(int action) +- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer +{ + // In iOS 17, Messages allows you to interactively resize iMessage apps with a vertical pan gesture. Messages handles any conflicts between resize gestures and your custom gestures. If your app uses manual touch handling, override those methods in your app’s UIView. You can either change your manual touch handling code to use a gesture recognizer instead, or your UIView can override gestureRecognizerShouldBegin: and return NO when your iMessage app doesn’t own the gesture. + return false; +} + +static void sync_all_touches(UIEvent* event) +{ + CORE.Input.Touch.pointCount = event.allTouches.count; + int i = 0; + for (UITouch *touch in event.allTouches) + { + CGPoint location = [touch locationInView:platform.viewController.view]; + CORE.Input.Touch.position[i] = (Vector2){ location.x, location.y }; + CORE.Input.Touch.pointId[i] = (int)touch; + i++; + if(i >= MAX_TOUCH_POINTS) break; + } + // TODO: Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height +} + +static void send_gesture_event(NSSet * touches, int action) { #if defined(SUPPORT_GESTURES_SYSTEM) GestureEvent gestureEvent = { 0 }; @@ -682,30 +699,65 @@ void call_gesture(int action) // Gesture data is sent to gestures system for processing ProcessGestureEvent(gestureEvent); #endif + + if(action == TOUCH_ACTION_UP){ + // One of the touchpoints is released, remove it from touch point arrays + for (UITouch *touch in touches) + { + for (int i = 0; i < MAX_TOUCH_POINTS; i++) + { + if(CORE.Input.Touch.pointId[i] == (int)touch){ + CORE.Input.Touch.pointId[i] = 0; + CORE.Input.Touch.position[i] = (Vector2){ 0.0f, 0.0f }; + break; + } + } + } + // re-arrange the touch points + int j = 0; + for (int i = 0; i < MAX_TOUCH_POINTS; i++) + { + if(CORE.Input.Touch.pointId[i] != 0){ + CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[i]; + CORE.Input.Touch.position[j] = CORE.Input.Touch.position[i]; + j++; + } + } + CORE.Input.Touch.pointCount -= touches.count; + } + + if(action == TOUCH_ACTION_MOVE){ + CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; + }else{ + CORE.Input.Mouse.previousPosition = CORE.Input.Touch.position[0]; + } + + // Map touch[0] as mouse input for convenience + CORE.Input.Mouse.currentPosition = CORE.Input.Touch.position[0]; + CORE.Input.Mouse.currentWheelMove = (Vector2){ 0.0f, 0.0f }; } // touch callbacks - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - CORE.Input.Touch.pointCount += touches.count; - if (CORE.Input.Touch.pointCount > 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1; - for(UITouch* touch in touches) call_gesture(TOUCH_ACTION_DOWN); + sync_all_touches(event); + send_gesture_event(touches, TOUCH_ACTION_DOWN); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - CORE.Input.Touch.pointCount -= touches.count; - if (CORE.Input.Touch.pointCount == 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0; - for(UITouch* touch in touches) call_gesture(TOUCH_ACTION_UP); + sync_all_touches(event); + send_gesture_event(touches, TOUCH_ACTION_UP); + // post sync needed } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - for(UITouch* touch in touches) call_gesture(TOUCH_ACTION_MOVE); + sync_all_touches(event); + send_gesture_event(touches, TOUCH_ACTION_MOVE); } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - CORE.Input.Touch.pointCount = 0; - CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0; - for(UITouch* touch in touches) call_gesture(TOUCH_ACTION_CANCEL); + sync_all_touches(event); + send_gesture_event(touches, TOUCH_ACTION_CANCEL); } @end @@ -718,9 +770,7 @@ void call_gesture(int action) self.window.backgroundColor = [UIColor redColor]; self.window.rootViewController = [[GameViewController alloc] init]; [self.window makeKeyAndVisible]; - ios_ready(); - CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self.window.rootViewController selector:@selector(update)]; [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; return YES; @@ -729,8 +779,12 @@ void call_gesture(int action) - (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. + CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED; +} +- (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. + CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED; } - - (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. } @@ -739,12 +793,16 @@ void call_gesture(int action) // 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. -} - - (void)applicationWillTerminate:(UIApplication *)application { ios_destroy(); + + if (platform.device != EGL_NO_DISPLAY) + { + // the user does not call CloseWindow() before exiting + TRACELOG(LOG_ERROR, "DISPLAY: CloseWindow() should be called before terminating the application"); + } + // If 'platform.device' is already set to 'EGL_NO_DISPLAY' + // this means that the user has already called 'CloseWindow()' } @end From c66c9e9ffda0c037d9d1a9142f6fcc754fb27578 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 24 Mar 2024 14:27:07 +0800 Subject: [PATCH 10/44] some fix --- .../Xcode15/raylib.xcodeproj/project.pbxproj | 4 +- src/platforms/rcore_ios.c | 41 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/projects/Xcode15/raylib.xcodeproj/project.pbxproj b/projects/Xcode15/raylib.xcodeproj/project.pbxproj index c11484b8..94f31373 100644 --- a/projects/Xcode15/raylib.xcodeproj/project.pbxproj +++ b/projects/Xcode15/raylib.xcodeproj/project.pbxproj @@ -346,7 +346,7 @@ GRAPHICS_API_OPENGL_ES2, PLATFORM_IOS, ); - GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = ""; @@ -388,7 +388,7 @@ GRAPHICS_API_OPENGL_ES2, PLATFORM_IOS, ); - GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = ""; diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index cd95530c..206d6bc5 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -458,7 +458,7 @@ int InitPlatform(void) CORE.Window.screen.height = platform.viewController.view.frame.size.height; } - int orientation = [[UIApplication sharedApplication] statusBarOrientation]; + long long orientation = [[UIApplication sharedApplication] statusBarOrientation]; if(orientation == UIInterfaceOrientationPortrait){ TRACELOG(LOG_INFO, "IOS: Window orientation set as Portrait"); }else if(orientation == UIInterfaceOrientationPortraitUpsideDown){ @@ -665,19 +665,25 @@ void ClosePlatform(void) static void sync_all_touches(UIEvent* event) { - CORE.Input.Touch.pointCount = event.allTouches.count; + CORE.Input.Touch.pointCount = (int)event.allTouches.count; int i = 0; for (UITouch *touch in event.allTouches) { CGPoint location = [touch locationInView:platform.viewController.view]; CORE.Input.Touch.position[i] = (Vector2){ location.x, location.y }; - CORE.Input.Touch.pointId[i] = (int)touch; + CORE.Input.Touch.pointId[i] = (long long)touch; i++; if(i >= MAX_TOUCH_POINTS) break; } // TODO: Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height } +static int array_index_of(long long needle, long long *haystack, int size) +{ + for (int i = 0; i < size; i++) if(haystack[i] == needle) return i; + return -1; +} + static void send_gesture_event(NSSet * touches, int action) { #if defined(SUPPORT_GESTURES_SYSTEM) @@ -704,26 +710,21 @@ static void send_gesture_event(NSSet * touches, int action) // One of the touchpoints is released, remove it from touch point arrays for (UITouch *touch in touches) { - for (int i = 0; i < MAX_TOUCH_POINTS; i++) - { - if(CORE.Input.Touch.pointId[i] == (int)touch){ - CORE.Input.Touch.pointId[i] = 0; - CORE.Input.Touch.position[i] = (Vector2){ 0.0f, 0.0f }; - break; + int size = CORE.Input.Touch.pointCount; + if(size > MAX_TOUCH_POINTS) size = MAX_TOUCH_POINTS; + int i = array_index_of((long long)touch, CORE.Input.Touch.pointId, size); + if(i >= 0){ + // remove i-th touch point + for (int j = i; j < size - 1; j++) + { + CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[j + 1]; + CORE.Input.Touch.position[j] = CORE.Input.Touch.position[j + 1]; } + CORE.Input.Touch.pointCount--; + }else{ + TRACELOG(LOG_WARNING, "Touch point not found. This may be a bug!"); } } - // re-arrange the touch points - int j = 0; - for (int i = 0; i < MAX_TOUCH_POINTS; i++) - { - if(CORE.Input.Touch.pointId[i] != 0){ - CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[i]; - CORE.Input.Touch.position[j] = CORE.Input.Touch.position[i]; - j++; - } - } - CORE.Input.Touch.pointCount -= touches.count; } if(action == TOUCH_ACTION_MOVE){ From a552997745160ac47d97998ad7feae176556e823 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 24 Mar 2024 14:29:02 +0800 Subject: [PATCH 11/44] change `pointId[]` to `long long` --- src/raylib.h | 2 +- src/rcore.c | 6 +++--- src/rgestures.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index 1a15e124..a3e2583e 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1195,7 +1195,7 @@ RLAPI void SetMouseCursor(int cursor); // Set mouse curso RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size) RLAPI int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size) RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size) -RLAPI int GetTouchPointId(int index); // Get touch point identifier for given index +RLAPI long long GetTouchPointId(int index); // Get touch point identifier for given index RLAPI int GetTouchPointCount(void); // Get number of touch points //------------------------------------------------------------------------------------ diff --git a/src/rcore.c b/src/rcore.c index 7c39a236..2589483a 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -323,7 +323,7 @@ typedef struct CoreData { } Mouse; struct { int pointCount; // Number of touch points active - int pointId[MAX_TOUCH_POINTS]; // Point identifiers + long long pointId[MAX_TOUCH_POINTS]; // Point identifiers Vector2 position[MAX_TOUCH_POINTS]; // Touch position on screen char currentTouchState[MAX_TOUCH_POINTS]; // Registers current touch state char previousTouchState[MAX_TOUCH_POINTS]; // Registers previous touch state @@ -3038,9 +3038,9 @@ Vector2 GetTouchPosition(int index) } // Get touch point identifier for given index -int GetTouchPointId(int index) +long long GetTouchPointId(int index) { - int id = -1; + long long id = -1; if (index < MAX_TOUCH_POINTS) id = CORE.Input.Touch.pointId[index]; diff --git a/src/rgestures.h b/src/rgestures.h index 664a6e1c..9248b362 100644 --- a/src/rgestures.h +++ b/src/rgestures.h @@ -102,7 +102,7 @@ typedef enum { typedef struct { int touchAction; int pointCount; - int pointId[MAX_TOUCH_POINTS]; + long long pointId[MAX_TOUCH_POINTS]; Vector2 position[MAX_TOUCH_POINTS]; } GestureEvent; From 5db5720de980b8b960be712b250009464c13deec Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 24 Mar 2024 06:29:19 +0000 Subject: [PATCH 12/44] Update raylib_api.* by CI --- parser/output/raylib_api.json | 16 +++++++++++----- parser/output/raylib_api.lua | 16 +++++++++++----- parser/output/raylib_api.txt | 17 +++++++++++------ parser/output/raylib_api.xml | 13 +++++++------ 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index ec8d57a8..f90e5d9f 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -335,6 +335,12 @@ "type": "UNKNOWN", "value": "SHADER_LOC_MAP_METALNESS", "description": "" + }, + { + "name": "GetMouseRay", + "type": "UNKNOWN", + "value": "GetScreenToWorldRay", + "description": "Compatibility hack for previous raylib versions" } ], "structs": [ @@ -3873,12 +3879,12 @@ }, { "name": "GetScreenToWorldRay", - "description": "Get a ray trace from mouse position", + "description": "Get a ray trace from screen position (i.e mouse)", "returnType": "Ray", "params": [ { "type": "Vector2", - "name": "mousePosition" + "name": "position" }, { "type": "Camera", @@ -3888,12 +3894,12 @@ }, { "name": "GetScreenToWorldRayEx", - "description": "Get a ray trace from mouse position in a viewport", + "description": "Get a ray trace from screen position (i.e mouse) in a viewport", "returnType": "Ray", "params": [ { "type": "Vector2", - "name": "mousePosition" + "name": "position" }, { "type": "Camera", @@ -5091,7 +5097,7 @@ { "name": "GetTouchPointId", "description": "Get touch point identifier for given index", - "returnType": "int", + "returnType": "long long", "params": [ { "type": "int", diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index 01c1abf3..abc65ec4 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -335,6 +335,12 @@ return { type = "UNKNOWN", value = "SHADER_LOC_MAP_METALNESS", description = "" + }, + { + name = "GetMouseRay", + type = "UNKNOWN", + value = "GetScreenToWorldRay", + description = "Compatibility hack for previous raylib versions" } }, structs = { @@ -3636,19 +3642,19 @@ return { }, { name = "GetScreenToWorldRay", - description = "Get a ray trace from mouse position", + description = "Get a ray trace from screen position (i.e mouse)", returnType = "Ray", params = { - {type = "Vector2", name = "mousePosition"}, + {type = "Vector2", name = "position"}, {type = "Camera", name = "camera"} } }, { name = "GetScreenToWorldRayEx", - description = "Get a ray trace from mouse position in a viewport", + description = "Get a ray trace from screen position (i.e mouse) in a viewport", returnType = "Ray", params = { - {type = "Vector2", name = "mousePosition"}, + {type = "Vector2", name = "position"}, {type = "Camera", name = "camera"}, {type = "float", name = "width"}, {type = "float", name = "height"} @@ -4470,7 +4476,7 @@ return { { name = "GetTouchPointId", description = "Get touch point identifier for given index", - returnType = "int", + returnType = "long long", params = { {type = "int", name = "index"} } diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index d49ac33e..37be0f94 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -1,5 +1,5 @@ -Defines found: 56 +Defines found: 57 Define 001: RAYLIB_H Name: RAYLIB_H @@ -281,6 +281,11 @@ Define 056: SHADER_LOC_MAP_SPECULAR Type: UNKNOWN Value: SHADER_LOC_MAP_METALNESS Description: +Define 057: GetMouseRay + Name: GetMouseRay + Type: UNKNOWN + Value: GetScreenToWorldRay + Description: Compatibility hack for previous raylib versions Structures found: 34 @@ -1424,14 +1429,14 @@ Function 083: UnloadShader() (1 input parameters) Function 084: GetScreenToWorldRay() (2 input parameters) Name: GetScreenToWorldRay Return type: Ray - Description: Get a ray trace from mouse position - Param[1]: mousePosition (type: Vector2) + Description: Get a ray trace from screen position (i.e mouse) + Param[1]: position (type: Vector2) Param[2]: camera (type: Camera) Function 085: GetScreenToWorldRayEx() (4 input parameters) Name: GetScreenToWorldRayEx Return type: Ray - Description: Get a ray trace from mouse position in a viewport - Param[1]: mousePosition (type: Vector2) + Description: Get a ray trace from screen position (i.e mouse) in a viewport + Param[1]: position (type: Vector2) Param[2]: camera (type: Camera) Param[3]: width (type: float) Param[4]: height (type: float) @@ -2001,7 +2006,7 @@ Function 190: GetTouchPosition() (1 input parameters) Param[1]: index (type: int) Function 191: GetTouchPointId() (1 input parameters) Name: GetTouchPointId - Return type: int + Return type: long long Description: Get touch point identifier for given index Param[1]: index (type: int) Function 192: GetTouchPointCount() (0 input parameters) diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index 45697f24..dae5ff9a 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -1,6 +1,6 @@ - + @@ -57,6 +57,7 @@ + @@ -902,12 +903,12 @@ - - + + - - + + @@ -1244,7 +1245,7 @@ - + From c0ac3471f7ff3c80b6a207a6ceeb7d75bb38f0df Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 24 Mar 2024 14:40:35 +0800 Subject: [PATCH 13/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 206d6bc5..73d1efd2 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -727,6 +727,9 @@ static void send_gesture_event(NSSet * touches, int action) } } + if (CORE.Input.Touch.pointCount > 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1; + else CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0; + if(action == TOUCH_ACTION_MOVE){ CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; }else{ From 3a9649d3972cf1b78efd997f8229e4e352061acb Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 25 Mar 2024 01:17:48 +0800 Subject: [PATCH 14/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 73d1efd2..9351da63 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -390,6 +390,12 @@ int SetGamepadMappings(const char *mappings) return 0; } +// Set gamepad vibration +void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor) +{ + TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform"); +} + // Set mouse position XY void SetMousePosition(int x, int y) { From 67fb284c1a90cc3a9b0dbc1183cea6a8de0ae6f2 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 25 Mar 2024 01:40:26 +0800 Subject: [PATCH 15/44] upgrade to `GRAPHICS_API_OPENGL_ES3` --- projects/Xcode15/raylib.xcodeproj/project.pbxproj | 10 ++++++++-- src/platforms/rcore_ios.c | 13 ++++--------- src/rlgl.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/projects/Xcode15/raylib.xcodeproj/project.pbxproj b/projects/Xcode15/raylib.xcodeproj/project.pbxproj index 94f31373..88e1ca4a 100644 --- a/projects/Xcode15/raylib.xcodeproj/project.pbxproj +++ b/projects/Xcode15/raylib.xcodeproj/project.pbxproj @@ -343,8 +343,9 @@ GCC_C_LANGUAGE_STANDARD = gnu17; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", - GRAPHICS_API_OPENGL_ES2, + GRAPHICS_API_OPENGL_ES3, PLATFORM_IOS, + GL_GLEXT_PROTOTYPES, ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; @@ -362,7 +363,9 @@ "$(inherited)", "@executable_path/Frameworks", ); + LIBRARY_SEARCH_PATHS = ""; MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.example.raylib; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -385,8 +388,9 @@ DEVELOPMENT_TEAM = A7A93GC9AY; GCC_C_LANGUAGE_STANDARD = gnu17; GCC_PREPROCESSOR_DEFINITIONS = ( - GRAPHICS_API_OPENGL_ES2, + GRAPHICS_API_OPENGL_ES3, PLATFORM_IOS, + GL_GLEXT_PROTOTYPES, ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; @@ -404,7 +408,9 @@ "$(inherited)", "@executable_path/Frameworks", ); + LIBRARY_SEARCH_PATHS = ""; MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.example.raylib; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 9351da63..98080ce7 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -506,18 +506,11 @@ int InitPlatform(void) EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs) EGL_NONE }; - -// const EGLint contextAttribs[] = -// { -// EGL_CONTEXT_CLIENT_VERSION, 2, -// EGL_NONE -// }; const EGLint contextAttribs[] = { - EGL_CONTEXT_MAJOR_VERSION, 2, - EGL_CONTEXT_MINOR_VERSION, 0, - EGL_NONE, + EGL_CONTEXT_CLIENT_VERSION, 3, + EGL_NONE }; EGLint numConfigs = 0; @@ -584,6 +577,8 @@ int InitPlatform(void) TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); + TRACELOG(LOG_WARNING, " > GL: %s", glGetString(GL_VERSION)); + TRACELOG(LOG_WARNING, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION)); } //---------------------------------------------------------------------------- // Load OpenGL extensions diff --git a/src/rlgl.h b/src/rlgl.h index b13c595f..9221de10 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -816,12 +816,13 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad #endif #if defined(PLATFORM_IOS) - #ifndef GRAPHICS_API_OPENGL_ES2 - #error "GRAPHICS_API_OPENGL_ES2 required on PLATFORM_IOS" + #ifndef GRAPHICS_API_OPENGL_ES3 + #error "GRAPHICS_API_OPENGL_ES3 required on PLATFORM_IOS" #endif #include "libGLESv2/GLES/glext.h" #include "libGLESv2/GLES2/gl2.h" #include "libGLESv2/GLES2/gl2ext.h" // OpenGL ES 2.0 extensions library + #include "libGLESv2/GLES3/gl3.h" #elif defined(GRAPHICS_API_OPENGL_ES3) #include // OpenGL ES 3.0 library #define GL_GLEXT_PROTOTYPES From 0a9ea31a4c58c500446d844e6bd3609ce8f5a292 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 25 Mar 2024 11:33:40 +0800 Subject: [PATCH 16/44] Update rlgl.h --- src/rlgl.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rlgl.h b/src/rlgl.h index 9221de10..f4132884 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -816,9 +816,13 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad #endif #if defined(PLATFORM_IOS) + // These required macros should be defined in Xcode #ifndef GRAPHICS_API_OPENGL_ES3 #error "GRAPHICS_API_OPENGL_ES3 required on PLATFORM_IOS" #endif + #ifndef GL_GLEXT_PROTOTYPES + #error "GL_GLEXT_PROTOTYPES required on PLATFORM_IOS" + #endif #include "libGLESv2/GLES/glext.h" #include "libGLESv2/GLES2/gl2.h" #include "libGLESv2/GLES2/gl2ext.h" // OpenGL ES 2.0 extensions library From cd1b81d67ec8f289c92d72dd867d35d3d19acff9 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 25 Mar 2024 15:43:47 +0800 Subject: [PATCH 17/44] Update project.pbxproj --- projects/Xcode15/raylib.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/Xcode15/raylib.xcodeproj/project.pbxproj b/projects/Xcode15/raylib.xcodeproj/project.pbxproj index 88e1ca4a..a1fdcc57 100644 --- a/projects/Xcode15/raylib.xcodeproj/project.pbxproj +++ b/projects/Xcode15/raylib.xcodeproj/project.pbxproj @@ -363,9 +363,9 @@ "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = ""; + LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)"; MARKETING_VERSION = 1.0; - OTHER_LDFLAGS = ""; + OTHER_LDFLAGS = "-lc++"; PRODUCT_BUNDLE_IDENTIFIER = com.example.raylib; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -408,9 +408,9 @@ "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = ""; + LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)"; MARKETING_VERSION = 1.0; - OTHER_LDFLAGS = ""; + OTHER_LDFLAGS = "-lc++"; PRODUCT_BUNDLE_IDENTIFIER = com.example.raylib; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; From 33ccfd976cbc5c4c89b1f9903fabdc3fe8e639dd Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 25 Mar 2024 21:28:13 +0800 Subject: [PATCH 18/44] Create ios.yml --- .github/workflows/ios.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/ios.yml diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml new file mode 100644 index 00000000..f118418c --- /dev/null +++ b/.github/workflows/ios.yml @@ -0,0 +1,35 @@ +name: iOS + +on: + workflow_dispatch: + push: + paths: + - 'src/**' + - 'examples/**' + - '.github/workflows/android.yml' + pull_request: + paths: + - 'src/**' + - 'examples/**' + - '.github/workflows/android.yml' + release: + types: [published] + +jobs: + build: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Build Xcode15 project + run: | + cd projects/Xcode15 + curl -L https://github.com/raysan5/raylib/files/14743869/libEGL.xcframework.zip --output libEGL.xcframework.zip + curl -L https://github.com/raysan5/raylib/files/14743873/libGLESv2.xcframework.zip --output libGLESv2.xcframework.zip + unzip libEGL.xcframework.zip -d libEGL.xcframework + unzip libGLESv2.xcframework.zip -d libGLESv2.xcframework + rm libEGL.xcframework.zip + rm libGLESv2.xcframework.zip + ls + xcodebuild -project raylib.xcodeproj -scheme raylib -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12,OS=15.0' build + From ed861d0bf8d410a30d25ee64b32bc385dfd6f6b6 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 25 Mar 2024 21:32:41 +0800 Subject: [PATCH 19/44] Update ios.yml Update ios.yml --- .github/workflows/ios.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index f118418c..df8af65c 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -26,10 +26,10 @@ jobs: cd projects/Xcode15 curl -L https://github.com/raysan5/raylib/files/14743869/libEGL.xcframework.zip --output libEGL.xcframework.zip curl -L https://github.com/raysan5/raylib/files/14743873/libGLESv2.xcframework.zip --output libGLESv2.xcframework.zip - unzip libEGL.xcframework.zip -d libEGL.xcframework - unzip libGLESv2.xcframework.zip -d libGLESv2.xcframework + unzip -q libEGL.xcframework.zip -d libEGL.xcframework + unzip -q libGLESv2.xcframework.zip -d libGLESv2.xcframework rm libEGL.xcframework.zip rm libGLESv2.xcframework.zip ls - xcodebuild -project raylib.xcodeproj -scheme raylib -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12,OS=15.0' build + xcodebuild -project raylib.xcodeproj -scheme raylib -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' build From da46011eefcf0c780a7c31102dd5e682b037412b Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 25 Mar 2024 21:36:31 +0800 Subject: [PATCH 20/44] Update ios.yml Update ios.yml --- .github/workflows/ios.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index df8af65c..500d342b 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -26,10 +26,9 @@ jobs: cd projects/Xcode15 curl -L https://github.com/raysan5/raylib/files/14743869/libEGL.xcframework.zip --output libEGL.xcframework.zip curl -L https://github.com/raysan5/raylib/files/14743873/libGLESv2.xcframework.zip --output libGLESv2.xcframework.zip - unzip -q libEGL.xcframework.zip -d libEGL.xcframework - unzip -q libGLESv2.xcframework.zip -d libGLESv2.xcframework + unzip -q libEGL.xcframework.zip -d raylib/Frameworks/libEGL.xcframework + unzip -q libGLESv2.xcframework.zip -d raylib/Frameworks/libGLESv2.xcframework rm libEGL.xcframework.zip rm libGLESv2.xcframework.zip - ls xcodebuild -project raylib.xcodeproj -scheme raylib -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' build From 2e29d3fbdd51e62242bdd5ef2b3db1189563b25a Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 25 Mar 2024 21:38:28 +0800 Subject: [PATCH 21/44] Update ios.yml --- .github/workflows/ios.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 500d342b..71f56838 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -26,6 +26,7 @@ jobs: cd projects/Xcode15 curl -L https://github.com/raysan5/raylib/files/14743869/libEGL.xcframework.zip --output libEGL.xcframework.zip curl -L https://github.com/raysan5/raylib/files/14743873/libGLESv2.xcframework.zip --output libGLESv2.xcframework.zip + mkdir -p raylib/Frameworks unzip -q libEGL.xcframework.zip -d raylib/Frameworks/libEGL.xcframework unzip -q libGLESv2.xcframework.zip -d raylib/Frameworks/libGLESv2.xcframework rm libEGL.xcframework.zip From ee2a30775e46cff6bb388ccef0689b2d7ed21d38 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 13:35:22 +0800 Subject: [PATCH 22/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 98080ce7..daf70198 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -293,7 +293,6 @@ Vector2 GetWindowPosition(void) // Get window scale DPI factor for current monitor Vector2 GetWindowScaleDPI(void) { - TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform"); return (Vector2){ 1.0f, 1.0f }; } @@ -457,11 +456,13 @@ void PollInputEvents(void) // Initialize platform: graphics, inputs and more int InitPlatform(void) { + CORE.Window.display.width = [[UIScreen mainScreen] nativeBounds].size.width; + CORE.Window.display.height = [[UIScreen mainScreen] nativeBounds].size.height; if(CORE.Window.screen.width == 0){ - CORE.Window.screen.width = platform.viewController.view.frame.size.width; + CORE.Window.screen.width = [[UIScreen mainScreen] bounds].size.width; } if(CORE.Window.screen.height == 0){ - CORE.Window.screen.height = platform.viewController.view.frame.size.height; + CORE.Window.screen.height = [[UIScreen mainScreen] bounds].size.height; } long long orientation = [[UIApplication sharedApplication] statusBarOrientation]; @@ -577,8 +578,8 @@ int InitPlatform(void) TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); - TRACELOG(LOG_WARNING, " > GL: %s", glGetString(GL_VERSION)); - TRACELOG(LOG_WARNING, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION)); + TRACELOG(LOG_INFO, " > GL: %s", glGetString(GL_VERSION)); + TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION)); } //---------------------------------------------------------------------------- // Load OpenGL extensions From e6afac85e66fbbc1b97356f2add500a24dbdcce7 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 20:29:58 +0800 Subject: [PATCH 23/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index daf70198..0195387b 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -293,7 +293,9 @@ Vector2 GetWindowPosition(void) // Get window scale DPI factor for current monitor Vector2 GetWindowScaleDPI(void) { - return (Vector2){ 1.0f, 1.0f }; + CGFloat scale = [[UIScreen mainScreen] scale]; + return (Vector2){ scale, scale }; + // return (Vector2){ 1.0f, 1.0f }; } // Set clipboard text content @@ -595,6 +597,13 @@ int InitPlatform(void) //---------------------------------------------------------------------------- // ... //---------------------------------------------------------------------------- + // Initialize OpenGL context (states and resources) + // NOTE: CORE.Window.currentFbo.width and CORE.Window.currentFbo.height not used, just stored as globals in rlgl + rlglInit(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height); + + // Setup default viewport + // NOTE: It updated CORE.Window.render.width and CORE.Window.render.height + SetupViewport(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height); // TODO: Initialize timing system //---------------------------------------------------------------------------- @@ -647,6 +656,7 @@ void ClosePlatform(void) // self.modalPresentationCapturesStatusBarAppearance = true; platform.viewController = self; self.view.multipleTouchEnabled = true; + self.view.contentScaleFactor = [[UIScreen mainScreen] scale]; } - (bool)prefersStatusBarHidden From e5ecddfe0e4df6185e64c3d484d482a15ed230de Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 20:37:44 +0800 Subject: [PATCH 24/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 0195387b..3d3fd5b9 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -301,15 +301,16 @@ Vector2 GetWindowScaleDPI(void) // Set clipboard text content void SetClipboardText(const char *text) { - TRACELOG(LOG_WARNING, "SetClipboardText() not implemented on target platform"); + UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; + pasteboard.string = [NSString stringWithUTF8String:text]; } // Get clipboard text content -// NOTE: returned string is allocated and freed by GLFW const char *GetClipboardText(void) { - TRACELOG(LOG_WARNING, "GetClipboardText() not implemented on target platform"); - return NULL; + UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; + NSString *clipboard = pasteboard.string; + return clipboard.UTF8String; } // Show mouse cursor @@ -372,12 +373,8 @@ double GetTime(void) // Ref: https://github.com/raysan5/raylib/issues/686 void OpenURL(const char *url) { - // Security check to (partially) avoid malicious code on target platform - if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character"); - else - { - TRACELOG(LOG_WARNING, "OpenURL() not implemented on target platform"); - } + NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:url]]; + [[UIApplication sharedApplication] openURL:nsurl options:@{} completionHandler:nil]; } //---------------------------------------------------------------------------------- @@ -578,9 +575,8 @@ int InitPlatform(void) TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); - TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); + TRACELOG(LOG_INFO, " > Render size: %i x %i", GetRenderWidth(), GetRenderHeight()); TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); - TRACELOG(LOG_INFO, " > GL: %s", glGetString(GL_VERSION)); TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION)); } //---------------------------------------------------------------------------- From 86b3ba2b3cf7f3e66fa72031588b7ce7add5756d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 20:44:41 +0800 Subject: [PATCH 25/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 3d3fd5b9..c57979f3 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -443,7 +443,7 @@ void PollInputEvents(void) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0; } - // TODO: Poll input events for iOS + // Poll input events for iOS // https://developer.apple.com/documentation/uikit/touches_presses_and_gestures } @@ -542,7 +542,7 @@ int InitPlatform(void) if (platform.context == EGL_NO_CONTEXT) { TRACELOG(LOG_WARNING, "DISPLAY: Failed to create EGL context"); - return -1; + return false; } // Create an EGL window surface @@ -563,7 +563,7 @@ int InitPlatform(void) if (eglMakeCurrent(platform.device, platform.surface, platform.surface, platform.context) == EGL_FALSE) { TRACELOG(LOG_WARNING, "DISPLAY: Failed to attach EGL rendering context to EGL surface"); - return -1; + return false; } else { @@ -583,15 +583,7 @@ int InitPlatform(void) // Load OpenGL extensions // NOTE: GL procedures address loader is required to load extensions rlLoadExtensions(eglGetProcAddress); - CORE.Window.ready = true; - - // TODO: Initialize input events system - // It could imply keyboard, mouse, gamepad, touch... - // Depending on the platform libraries/SDK it could use a callback mechanism - // For system events and inputs evens polling on a per-frame basis, use PollInputEvents() - //---------------------------------------------------------------------------- - // ... //---------------------------------------------------------------------------- // Initialize OpenGL context (states and resources) // NOTE: CORE.Window.currentFbo.width and CORE.Window.currentFbo.height not used, just stored as globals in rlgl @@ -600,20 +592,10 @@ int InitPlatform(void) // Setup default viewport // NOTE: It updated CORE.Window.render.width and CORE.Window.render.height SetupViewport(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height); - - // TODO: Initialize timing system - //---------------------------------------------------------------------------- InitTimer(); - //---------------------------------------------------------------------------- - - // TODO: Initialize storage system - //---------------------------------------------------------------------------- CORE.Storage.basePath = GetWorkingDirectory(); - //---------------------------------------------------------------------------- - TRACELOG(LOG_INFO, "PLATFORM: IOS: Initialized successfully"); - - return 0; + return true; } // Close platform From c12462397cc6ff1f6b9475467e64f471df191bf6 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 20:59:55 +0800 Subject: [PATCH 26/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index c57979f3..d2c9a967 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -223,36 +223,31 @@ void *GetWindowHandle(void) // Get number of monitors int GetMonitorCount(void) { - TRACELOG(LOG_WARNING, "GetMonitorCount() not implemented on target platform"); return 1; } // Get number of monitors int GetCurrentMonitor(void) { - TRACELOG(LOG_WARNING, "GetCurrentMonitor() not implemented on target platform"); return 0; } // Get selected monitor position Vector2 GetMonitorPosition(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorPosition() not implemented on target platform"); return (Vector2){ 0, 0 }; } // Get selected monitor width (currently used by monitor) int GetMonitorWidth(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform"); - return 0; + return CORE.Window.screen.width; } // Get selected monitor height (currently used by monitor) int GetMonitorHeight(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform"); - return 0; + return CORE.Window.screen.height; } // Get selected monitor physical width in millimetres From f3c4d49a3437ff5c781df0871e2460c0bd1d8472 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 21:09:26 +0800 Subject: [PATCH 27/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index d2c9a967..fea3bfd1 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -459,23 +459,6 @@ int InitPlatform(void) CORE.Window.screen.height = [[UIScreen mainScreen] bounds].size.height; } - long long orientation = [[UIApplication sharedApplication] statusBarOrientation]; - if(orientation == UIInterfaceOrientationPortrait){ - TRACELOG(LOG_INFO, "IOS: Window orientation set as Portrait"); - }else if(orientation == UIInterfaceOrientationPortraitUpsideDown){ - TRACELOG(LOG_INFO, "IOS: Window orientation set as PortraitUpsideDown"); - }else if(orientation == UIInterfaceOrientationLandscapeLeft){ - TRACELOG(LOG_INFO, "IOS: Window orientation set as LandscapeLeft"); - }else if(orientation == UIInterfaceOrientationLandscapeRight){ - TRACELOG(LOG_INFO, "IOS: Window orientation set as LandscapeRight"); - } - - // TODO: Initialize graphic device: display/window - // It usually requires setting up the platform display system configuration - // and connexion with the GPU through some system graphic API - // raylib uses OpenGL so, platform should create that kind of connection - // Below example illustrates that process using EGL library - //---------------------------------------------------------------------------- CORE.Window.fullscreen = true; CORE.Window.flags |= FLAG_FULLSCREEN_MODE; @@ -573,6 +556,19 @@ int InitPlatform(void) TRACELOG(LOG_INFO, " > Render size: %i x %i", GetRenderWidth(), GetRenderHeight()); TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION)); + + long long orientation = [[UIApplication sharedApplication] statusBarOrientation]; + if(orientation == UIInterfaceOrientationPortrait){ + TRACELOG(LOG_INFO, " > Orientation: Portrait"); + }else if(orientation == UIInterfaceOrientationPortraitUpsideDown){ + TRACELOG(LOG_INFO, " > Orientation: PortraitUpsideDown"); + }else if(orientation == UIInterfaceOrientationLandscapeLeft){ + TRACELOG(LOG_INFO, " > Orientation: LandscapeLeft"); + }else if(orientation == UIInterfaceOrientationLandscapeRight){ + TRACELOG(LOG_INFO, " > Orientation: LandscapeRight"); + }else{ + TRACELOG(LOG_INFO, " > Orientation: Unknown"); + } } //---------------------------------------------------------------------------- // Load OpenGL extensions From d1a8b86148b6c0980c3e5250bf723c5641a71e7d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 21:16:15 +0800 Subject: [PATCH 28/44] Revert "change `pointId[]` to `long long`" This reverts commit a552997745160ac47d97998ad7feae176556e823. --- src/raylib.h | 2 +- src/rcore.c | 6 +++--- src/rgestures.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index a3e2583e..1a15e124 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1195,7 +1195,7 @@ RLAPI void SetMouseCursor(int cursor); // Set mouse curso RLAPI int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size) RLAPI int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size) RLAPI Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size) -RLAPI long long GetTouchPointId(int index); // Get touch point identifier for given index +RLAPI int GetTouchPointId(int index); // Get touch point identifier for given index RLAPI int GetTouchPointCount(void); // Get number of touch points //------------------------------------------------------------------------------------ diff --git a/src/rcore.c b/src/rcore.c index 2589483a..7c39a236 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -323,7 +323,7 @@ typedef struct CoreData { } Mouse; struct { int pointCount; // Number of touch points active - long long pointId[MAX_TOUCH_POINTS]; // Point identifiers + int pointId[MAX_TOUCH_POINTS]; // Point identifiers Vector2 position[MAX_TOUCH_POINTS]; // Touch position on screen char currentTouchState[MAX_TOUCH_POINTS]; // Registers current touch state char previousTouchState[MAX_TOUCH_POINTS]; // Registers previous touch state @@ -3038,9 +3038,9 @@ Vector2 GetTouchPosition(int index) } // Get touch point identifier for given index -long long GetTouchPointId(int index) +int GetTouchPointId(int index) { - long long id = -1; + int id = -1; if (index < MAX_TOUCH_POINTS) id = CORE.Input.Touch.pointId[index]; diff --git a/src/rgestures.h b/src/rgestures.h index 9248b362..664a6e1c 100644 --- a/src/rgestures.h +++ b/src/rgestures.h @@ -102,7 +102,7 @@ typedef enum { typedef struct { int touchAction; int pointCount; - long long pointId[MAX_TOUCH_POINTS]; + int pointId[MAX_TOUCH_POINTS]; Vector2 position[MAX_TOUCH_POINTS]; } GestureEvent; From faaa6230a1999b1a9d2c3e1d6a49145c1e7dbb00 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 21:17:07 +0800 Subject: [PATCH 29/44] revert long long change --- src/platforms/rcore_ios.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index fea3bfd1..e09ee635 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -644,6 +644,15 @@ void ClosePlatform(void) return false; } +static int map_point_id(UITouch* touch){ + int value = (int)(long long)touch; + // handle collisions + while(array_index_of(value, CORE.Input.Touch.pointId, MAX_TOUCH_POINTS) >= 0){ + value++; + } + return value; +} + static void sync_all_touches(UIEvent* event) { CORE.Input.Touch.pointCount = (int)event.allTouches.count; @@ -652,14 +661,14 @@ static void sync_all_touches(UIEvent* event) { CGPoint location = [touch locationInView:platform.viewController.view]; CORE.Input.Touch.position[i] = (Vector2){ location.x, location.y }; - CORE.Input.Touch.pointId[i] = (long long)touch; + CORE.Input.Touch.pointId[i] = map_point_id(touch); i++; if(i >= MAX_TOUCH_POINTS) break; } // TODO: Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height } -static int array_index_of(long long needle, long long *haystack, int size) +static int array_index_of(int needle, int *haystack, int size) { for (int i = 0; i < size; i++) if(haystack[i] == needle) return i; return -1; @@ -693,7 +702,7 @@ static void send_gesture_event(NSSet * touches, int action) { int size = CORE.Input.Touch.pointCount; if(size > MAX_TOUCH_POINTS) size = MAX_TOUCH_POINTS; - int i = array_index_of((long long)touch, CORE.Input.Touch.pointId, size); + int i = array_index_of(map_point_id(touch), CORE.Input.Touch.pointId, size); if(i >= 0){ // remove i-th touch point for (int j = i; j < size - 1; j++) From 4a7b6666c82377eeef43ea8ecc5da1e4f473a393 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 27 Mar 2024 13:17:23 +0000 Subject: [PATCH 30/44] Update raylib_api.* by CI --- parser/output/raylib_api.json | 2 +- parser/output/raylib_api.lua | 2 +- parser/output/raylib_api.txt | 2 +- parser/output/raylib_api.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index f90e5d9f..427e0377 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -5097,7 +5097,7 @@ { "name": "GetTouchPointId", "description": "Get touch point identifier for given index", - "returnType": "long long", + "returnType": "int", "params": [ { "type": "int", diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index abc65ec4..20315afd 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -4476,7 +4476,7 @@ return { { name = "GetTouchPointId", description = "Get touch point identifier for given index", - returnType = "long long", + returnType = "int", params = { {type = "int", name = "index"} } diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index 37be0f94..6a1c17c0 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -2006,7 +2006,7 @@ Function 190: GetTouchPosition() (1 input parameters) Param[1]: index (type: int) Function 191: GetTouchPointId() (1 input parameters) Name: GetTouchPointId - Return type: long long + Return type: int Description: Get touch point identifier for given index Param[1]: index (type: int) Function 192: GetTouchPointCount() (0 input parameters) diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index dae5ff9a..c34c4c5a 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -1245,7 +1245,7 @@ - + From bc34ea6faab5bed6d2a7ef1293d1ad8f869306e0 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 21:55:50 +0800 Subject: [PATCH 31/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index e09ee635..24598c96 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -73,7 +73,7 @@ extern void ios_destroy(); //---------------------------------------------------------------------------------- typedef struct { GameViewController *viewController; // Root view controller - + // Display data EGLDisplay device; // Native display device (physical screen connection) EGLSurface surface; // Surface to draw on, framebuffers (connected to context) @@ -91,6 +91,33 @@ static PlatformData platform = { 0 }; // Platform specific data //---------------------------------------------------------------------------------- // Module Internal Functions Declaration //---------------------------------------------------------------------------------- +static int map_point_id(UITouch *touch){ + static UITouch* touchs[MAX_TOUCH_POINTS] = { 0 }; + for(int i = 0; i < MAX_TOUCH_POINTS; i++){ + if(touchs[i] == touch) return i + 1; + } + // clear unused touch pairs before insert + for(int i = 0; i < MAX_TOUCH_POINTS; i++){ + if(touchs[i] == NULL) continue; + bool found = false; + for(int j = 0; j < MAX_TOUCH_POINTS; j++){ + if(CORE.Input.Touch.pointId[j] == i + 1){ + found = true; + break; + } + } + if(!found) touchs[i] = NULL; + } + for(int i = 0; i < MAX_TOUCH_POINTS; i++){ + if(touchs[i] == NULL){ + touchs[i] = touch; + return i + 1; + } + } + TRACELOG(LOG_ERROR, "Touch point id overflow. This may be a bug!"); + return 0; +} + int InitPlatform(void); // Initialize platform (graphics, inputs and more) //---------------------------------------------------------------------------------- @@ -644,15 +671,6 @@ void ClosePlatform(void) return false; } -static int map_point_id(UITouch* touch){ - int value = (int)(long long)touch; - // handle collisions - while(array_index_of(value, CORE.Input.Touch.pointId, MAX_TOUCH_POINTS) >= 0){ - value++; - } - return value; -} - static void sync_all_touches(UIEvent* event) { CORE.Input.Touch.pointCount = (int)event.allTouches.count; From 3c129644e5986a96a303e4aca06c9ab65272ae92 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 22:09:00 +0800 Subject: [PATCH 32/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 24598c96..5628a211 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -45,10 +45,7 @@ * 3. This notice may not be removed or altered from any source distribution. * **********************************************************************************************/ - -// TODO: Include the platform specific libraries #include "libEGL/libEGL.h" -#include // iOS only supports callbacks // We are not able to give users full control of the game loop @@ -120,15 +117,6 @@ static int map_point_id(UITouch *touch){ int InitPlatform(void); // Initialize platform (graphics, inputs and more) -//---------------------------------------------------------------------------------- -// Module Functions Declaration -//---------------------------------------------------------------------------------- -// NOTE: Functions declaration is provided by raylib.h - -//---------------------------------------------------------------------------------- -// Module Functions Definition: Window and Graphics Device -//---------------------------------------------------------------------------------- - // Check if application should close bool WindowShouldClose(void) { @@ -253,7 +241,7 @@ int GetMonitorCount(void) return 1; } -// Get number of monitors +// Get current monitor id int GetCurrentMonitor(void) { return 0; @@ -317,7 +305,6 @@ Vector2 GetWindowScaleDPI(void) { CGFloat scale = [[UIScreen mainScreen] scale]; return (Vector2){ scale, scale }; - // return (Vector2){ 1.0f, 1.0f }; } // Set clipboard text content From b69cee573925da15b7c2a8d70951f38e26c9d648 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Mar 2024 10:39:45 +0800 Subject: [PATCH 33/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 5628a211..cf2b02dd 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -456,6 +456,11 @@ void PollInputEvents(void) // https://developer.apple.com/documentation/uikit/touches_presses_and_gestures } +static void swap_uint(unsigned int* a, unsigned int * b){ + unsigned tmp = *a; + *a = *b; + *b = tmp; +} //---------------------------------------------------------------------------------- // Module Internal Functions Definition @@ -464,15 +469,6 @@ void PollInputEvents(void) // Initialize platform: graphics, inputs and more int InitPlatform(void) { - CORE.Window.display.width = [[UIScreen mainScreen] nativeBounds].size.width; - CORE.Window.display.height = [[UIScreen mainScreen] nativeBounds].size.height; - if(CORE.Window.screen.width == 0){ - CORE.Window.screen.width = [[UIScreen mainScreen] bounds].size.width; - } - if(CORE.Window.screen.height == 0){ - CORE.Window.screen.height = [[UIScreen mainScreen] bounds].size.height; - } - CORE.Window.fullscreen = true; CORE.Window.flags |= FLAG_FULLSCREEN_MODE; @@ -559,30 +555,42 @@ int InitPlatform(void) } else { + CORE.Window.display.width = [[UIScreen mainScreen] nativeBounds].size.width; + CORE.Window.display.height = [[UIScreen mainScreen] nativeBounds].size.height; + if(CORE.Window.screen.width == 0){ + CORE.Window.screen.width = [[UIScreen mainScreen] bounds].size.width; + } + if(CORE.Window.screen.height == 0){ + CORE.Window.screen.height = [[UIScreen mainScreen] bounds].size.height; + } + CORE.Window.render.width = CORE.Window.screen.width; CORE.Window.render.height = CORE.Window.screen.height; CORE.Window.currentFbo.width = CORE.Window.render.width; CORE.Window.currentFbo.height = CORE.Window.render.height; TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); - TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); - TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); - TRACELOG(LOG_INFO, " > Render size: %i x %i", GetRenderWidth(), GetRenderHeight()); - TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); - TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION)); long long orientation = [[UIApplication sharedApplication] statusBarOrientation]; if(orientation == UIInterfaceOrientationPortrait){ - TRACELOG(LOG_INFO, " > Orientation: Portrait"); + TRACELOG(LOG_INFO, " > Orientation: Portrait"); }else if(orientation == UIInterfaceOrientationPortraitUpsideDown){ - TRACELOG(LOG_INFO, " > Orientation: PortraitUpsideDown"); + TRACELOG(LOG_INFO, " > Orientation: PortraitUpsideDown"); }else if(orientation == UIInterfaceOrientationLandscapeLeft){ - TRACELOG(LOG_INFO, " > Orientation: LandscapeLeft"); + TRACELOG(LOG_INFO, " > Orientation: LandscapeLeft"); + swap_uint(&CORE.Window.display.width, &CORE.Window.display.height); }else if(orientation == UIInterfaceOrientationLandscapeRight){ - TRACELOG(LOG_INFO, " > Orientation: LandscapeRight"); + TRACELOG(LOG_INFO, " > Orientation: LandscapeRight"); + swap_uint(&CORE.Window.display.width, &CORE.Window.display.height); }else{ - TRACELOG(LOG_INFO, " > Orientation: Unknown"); + TRACELOG(LOG_ERROR, " > Orientation: Unknown"); } + + TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); + TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); + TRACELOG(LOG_INFO, " > Render size: %i x %i", GetRenderWidth(), GetRenderHeight()); + TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); + TRACELOG(LOG_INFO, " > EGL: %s", eglQueryString(platform.device, EGL_VERSION)); } //---------------------------------------------------------------------------- // Load OpenGL extensions From 524181918e97dd14a69e6c72cc1d51c66ce4e9f5 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Mar 2024 10:52:58 +0800 Subject: [PATCH 34/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index cf2b02dd..45692043 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -256,13 +256,13 @@ Vector2 GetMonitorPosition(int monitor) // Get selected monitor width (currently used by monitor) int GetMonitorWidth(int monitor) { - return CORE.Window.screen.width; + return CORE.Window.display.width; } // Get selected monitor height (currently used by monitor) int GetMonitorHeight(int monitor) { - return CORE.Window.screen.height; + return CORE.Window.display.height; } // Get selected monitor physical width in millimetres From d10d888f226e4deb689c347a4e3a9597b6fed43b Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Mar 2024 16:51:00 +0800 Subject: [PATCH 35/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 45692043..cf2b02dd 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -256,13 +256,13 @@ Vector2 GetMonitorPosition(int monitor) // Get selected monitor width (currently used by monitor) int GetMonitorWidth(int monitor) { - return CORE.Window.display.width; + return CORE.Window.screen.width; } // Get selected monitor height (currently used by monitor) int GetMonitorHeight(int monitor) { - return CORE.Window.display.height; + return CORE.Window.screen.height; } // Get selected monitor physical width in millimetres From 8fbec6f0001f958fee13c227eac36e038faf04bd Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 3 Apr 2024 15:14:13 +0800 Subject: [PATCH 36/44] Revert "Update raylib_api.* by CI" This reverts commit 4a7b6666c82377eeef43ea8ecc5da1e4f473a393. --- parser/output/raylib_api.json | 2 +- parser/output/raylib_api.lua | 2 +- parser/output/raylib_api.txt | 2 +- parser/output/raylib_api.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index 427e0377..f90e5d9f 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -5097,7 +5097,7 @@ { "name": "GetTouchPointId", "description": "Get touch point identifier for given index", - "returnType": "int", + "returnType": "long long", "params": [ { "type": "int", diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index 20315afd..abc65ec4 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -4476,7 +4476,7 @@ return { { name = "GetTouchPointId", description = "Get touch point identifier for given index", - returnType = "int", + returnType = "long long", params = { {type = "int", name = "index"} } diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index 6a1c17c0..37be0f94 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -2006,7 +2006,7 @@ Function 190: GetTouchPosition() (1 input parameters) Param[1]: index (type: int) Function 191: GetTouchPointId() (1 input parameters) Name: GetTouchPointId - Return type: int + Return type: long long Description: Get touch point identifier for given index Param[1]: index (type: int) Function 192: GetTouchPointCount() (0 input parameters) diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index c34c4c5a..dae5ff9a 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -1245,7 +1245,7 @@ - + From 7f9400c9898f6a8245eb1ed44de521d2591d1352 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 3 Apr 2024 15:14:17 +0800 Subject: [PATCH 37/44] Revert "Update raylib_api.* by CI" This reverts commit 5db5720de980b8b960be712b250009464c13deec. --- parser/output/raylib_api.json | 16 +++++----------- parser/output/raylib_api.lua | 16 +++++----------- parser/output/raylib_api.txt | 17 ++++++----------- parser/output/raylib_api.xml | 13 ++++++------- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index f90e5d9f..ec8d57a8 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -335,12 +335,6 @@ "type": "UNKNOWN", "value": "SHADER_LOC_MAP_METALNESS", "description": "" - }, - { - "name": "GetMouseRay", - "type": "UNKNOWN", - "value": "GetScreenToWorldRay", - "description": "Compatibility hack for previous raylib versions" } ], "structs": [ @@ -3879,12 +3873,12 @@ }, { "name": "GetScreenToWorldRay", - "description": "Get a ray trace from screen position (i.e mouse)", + "description": "Get a ray trace from mouse position", "returnType": "Ray", "params": [ { "type": "Vector2", - "name": "position" + "name": "mousePosition" }, { "type": "Camera", @@ -3894,12 +3888,12 @@ }, { "name": "GetScreenToWorldRayEx", - "description": "Get a ray trace from screen position (i.e mouse) in a viewport", + "description": "Get a ray trace from mouse position in a viewport", "returnType": "Ray", "params": [ { "type": "Vector2", - "name": "position" + "name": "mousePosition" }, { "type": "Camera", @@ -5097,7 +5091,7 @@ { "name": "GetTouchPointId", "description": "Get touch point identifier for given index", - "returnType": "long long", + "returnType": "int", "params": [ { "type": "int", diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index abc65ec4..01c1abf3 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -335,12 +335,6 @@ return { type = "UNKNOWN", value = "SHADER_LOC_MAP_METALNESS", description = "" - }, - { - name = "GetMouseRay", - type = "UNKNOWN", - value = "GetScreenToWorldRay", - description = "Compatibility hack for previous raylib versions" } }, structs = { @@ -3642,19 +3636,19 @@ return { }, { name = "GetScreenToWorldRay", - description = "Get a ray trace from screen position (i.e mouse)", + description = "Get a ray trace from mouse position", returnType = "Ray", params = { - {type = "Vector2", name = "position"}, + {type = "Vector2", name = "mousePosition"}, {type = "Camera", name = "camera"} } }, { name = "GetScreenToWorldRayEx", - description = "Get a ray trace from screen position (i.e mouse) in a viewport", + description = "Get a ray trace from mouse position in a viewport", returnType = "Ray", params = { - {type = "Vector2", name = "position"}, + {type = "Vector2", name = "mousePosition"}, {type = "Camera", name = "camera"}, {type = "float", name = "width"}, {type = "float", name = "height"} @@ -4476,7 +4470,7 @@ return { { name = "GetTouchPointId", description = "Get touch point identifier for given index", - returnType = "long long", + returnType = "int", params = { {type = "int", name = "index"} } diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index 37be0f94..d49ac33e 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -1,5 +1,5 @@ -Defines found: 57 +Defines found: 56 Define 001: RAYLIB_H Name: RAYLIB_H @@ -281,11 +281,6 @@ Define 056: SHADER_LOC_MAP_SPECULAR Type: UNKNOWN Value: SHADER_LOC_MAP_METALNESS Description: -Define 057: GetMouseRay - Name: GetMouseRay - Type: UNKNOWN - Value: GetScreenToWorldRay - Description: Compatibility hack for previous raylib versions Structures found: 34 @@ -1429,14 +1424,14 @@ Function 083: UnloadShader() (1 input parameters) Function 084: GetScreenToWorldRay() (2 input parameters) Name: GetScreenToWorldRay Return type: Ray - Description: Get a ray trace from screen position (i.e mouse) - Param[1]: position (type: Vector2) + Description: Get a ray trace from mouse position + Param[1]: mousePosition (type: Vector2) Param[2]: camera (type: Camera) Function 085: GetScreenToWorldRayEx() (4 input parameters) Name: GetScreenToWorldRayEx Return type: Ray - Description: Get a ray trace from screen position (i.e mouse) in a viewport - Param[1]: position (type: Vector2) + Description: Get a ray trace from mouse position in a viewport + Param[1]: mousePosition (type: Vector2) Param[2]: camera (type: Camera) Param[3]: width (type: float) Param[4]: height (type: float) @@ -2006,7 +2001,7 @@ Function 190: GetTouchPosition() (1 input parameters) Param[1]: index (type: int) Function 191: GetTouchPointId() (1 input parameters) Name: GetTouchPointId - Return type: long long + Return type: int Description: Get touch point identifier for given index Param[1]: index (type: int) Function 192: GetTouchPointCount() (0 input parameters) diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index dae5ff9a..45697f24 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -1,6 +1,6 @@ - + @@ -57,7 +57,6 @@ - @@ -903,12 +902,12 @@ - - + + - - + + @@ -1245,7 +1244,7 @@ - + From cd8f5f9412ca66634f41e17c2348ad48aa96b6f3 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 4 Apr 2024 16:10:36 +0800 Subject: [PATCH 38/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 55 +++++++++------------------------------ 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index cf2b02dd..0f06a589 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -456,12 +456,6 @@ void PollInputEvents(void) // https://developer.apple.com/documentation/uikit/touches_presses_and_gestures } -static void swap_uint(unsigned int* a, unsigned int * b){ - unsigned tmp = *a; - *a = *b; - *b = tmp; -} - //---------------------------------------------------------------------------------- // Module Internal Functions Definition //---------------------------------------------------------------------------------- @@ -555,37 +549,12 @@ int InitPlatform(void) } else { - CORE.Window.display.width = [[UIScreen mainScreen] nativeBounds].size.width; - CORE.Window.display.height = [[UIScreen mainScreen] nativeBounds].size.height; - if(CORE.Window.screen.width == 0){ - CORE.Window.screen.width = [[UIScreen mainScreen] bounds].size.width; - } - if(CORE.Window.screen.height == 0){ - CORE.Window.screen.height = [[UIScreen mainScreen] bounds].size.height; - } - CORE.Window.render.width = CORE.Window.screen.width; CORE.Window.render.height = CORE.Window.screen.height; CORE.Window.currentFbo.width = CORE.Window.render.width; CORE.Window.currentFbo.height = CORE.Window.render.height; TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); - - long long orientation = [[UIApplication sharedApplication] statusBarOrientation]; - if(orientation == UIInterfaceOrientationPortrait){ - TRACELOG(LOG_INFO, " > Orientation: Portrait"); - }else if(orientation == UIInterfaceOrientationPortraitUpsideDown){ - TRACELOG(LOG_INFO, " > Orientation: PortraitUpsideDown"); - }else if(orientation == UIInterfaceOrientationLandscapeLeft){ - TRACELOG(LOG_INFO, " > Orientation: LandscapeLeft"); - swap_uint(&CORE.Window.display.width, &CORE.Window.display.height); - }else if(orientation == UIInterfaceOrientationLandscapeRight){ - TRACELOG(LOG_INFO, " > Orientation: LandscapeRight"); - swap_uint(&CORE.Window.display.width, &CORE.Window.display.height); - }else{ - TRACELOG(LOG_ERROR, " > Orientation: Unknown"); - } - TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); TRACELOG(LOG_INFO, " > Render size: %i x %i", GetRenderWidth(), GetRenderHeight()); @@ -666,7 +635,7 @@ void ClosePlatform(void) return false; } -static void sync_all_touches(UIEvent* event) +static void SyncAllTouches(UIEvent* event) { CORE.Input.Touch.pointCount = (int)event.allTouches.count; int i = 0; @@ -681,13 +650,13 @@ static void sync_all_touches(UIEvent* event) // TODO: Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height } -static int array_index_of(int needle, int *haystack, int size) +static int IndexOf(int needle, int *haystack, int size) { for (int i = 0; i < size; i++) if(haystack[i] == needle) return i; return -1; } -static void send_gesture_event(NSSet * touches, int action) +static void SendGestureEvent(NSSet * touches, int action) { #if defined(SUPPORT_GESTURES_SYSTEM) GestureEvent gestureEvent = { 0 }; @@ -715,7 +684,7 @@ static void send_gesture_event(NSSet * touches, int action) { int size = CORE.Input.Touch.pointCount; if(size > MAX_TOUCH_POINTS) size = MAX_TOUCH_POINTS; - int i = array_index_of(map_point_id(touch), CORE.Input.Touch.pointId, size); + int i = IndexOf(map_point_id(touch), CORE.Input.Touch.pointId, size); if(i >= 0){ // remove i-th touch point for (int j = i; j < size - 1; j++) @@ -747,24 +716,24 @@ static void send_gesture_event(NSSet * touches, int action) // touch callbacks - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - sync_all_touches(event); - send_gesture_event(touches, TOUCH_ACTION_DOWN); + SyncAllTouches(event); + SendGestureEvent(touches, TOUCH_ACTION_DOWN); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - sync_all_touches(event); - send_gesture_event(touches, TOUCH_ACTION_UP); + SyncAllTouches(event); + SendGestureEvent(touches, TOUCH_ACTION_UP); // post sync needed } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - sync_all_touches(event); - send_gesture_event(touches, TOUCH_ACTION_MOVE); + SyncAllTouches(event); + SendGestureEvent(touches, TOUCH_ACTION_MOVE); } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - sync_all_touches(event); - send_gesture_event(touches, TOUCH_ACTION_CANCEL); + SyncAllTouches(event); + SendGestureEvent(touches, TOUCH_ACTION_CANCEL); } @end From c5c41f9e4762e835958f60e5e16a2aa556fb5ecb Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 4 Apr 2024 16:12:05 +0800 Subject: [PATCH 39/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 0f06a589..59c5437c 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -88,7 +88,7 @@ static PlatformData platform = { 0 }; // Platform specific data //---------------------------------------------------------------------------------- // Module Internal Functions Declaration //---------------------------------------------------------------------------------- -static int map_point_id(UITouch *touch){ +static int MapPointId(UITouch *touch){ static UITouch* touchs[MAX_TOUCH_POINTS] = { 0 }; for(int i = 0; i < MAX_TOUCH_POINTS; i++){ if(touchs[i] == touch) return i + 1; @@ -643,7 +643,7 @@ static void SyncAllTouches(UIEvent* event) { CGPoint location = [touch locationInView:platform.viewController.view]; CORE.Input.Touch.position[i] = (Vector2){ location.x, location.y }; - CORE.Input.Touch.pointId[i] = map_point_id(touch); + CORE.Input.Touch.pointId[i] = MapPointId(touch); i++; if(i >= MAX_TOUCH_POINTS) break; } @@ -684,7 +684,7 @@ static void SendGestureEvent(NSSet * touches, int action) { int size = CORE.Input.Touch.pointCount; if(size > MAX_TOUCH_POINTS) size = MAX_TOUCH_POINTS; - int i = IndexOf(map_point_id(touch), CORE.Input.Touch.pointId, size); + int i = IndexOf(MapPointId(touch), CORE.Input.Touch.pointId, size); if(i >= 0){ // remove i-th touch point for (int j = i; j < size - 1; j++) From c4a42a3ad31fa749e9e18c3c742721c3413ee1a7 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 6 Apr 2024 23:19:47 +0800 Subject: [PATCH 40/44] Update rcore_android.c --- src/platforms/rcore_android.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 23b8f436..6ee7b5d5 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -426,36 +426,31 @@ void *GetWindowHandle(void) // Get number of monitors int GetMonitorCount(void) { - TRACELOG(LOG_WARNING, "GetMonitorCount() not implemented on target platform"); return 1; } // Get number of monitors int GetCurrentMonitor(void) { - TRACELOG(LOG_WARNING, "GetCurrentMonitor() not implemented on target platform"); return 0; } // Get selected monitor position Vector2 GetMonitorPosition(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorPosition() not implemented on target platform"); return (Vector2){ 0, 0 }; } // Get selected monitor width (currently used by monitor) int GetMonitorWidth(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform"); - return 0; + return CORE.Window.screen.width; } // Get selected monitor height (currently used by monitor) int GetMonitorHeight(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform"); - return 0; + return CORE.Window.screen.height; } // Get selected monitor physical width in millimetres From 918c394331c1883dd9f90a839e279029bf9557ef Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 7 Apr 2024 01:13:22 +0800 Subject: [PATCH 41/44] Update rcore_android.c --- src/platforms/rcore_android.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 6ee7b5d5..1842fb17 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -491,7 +491,6 @@ Vector2 GetWindowPosition(void) // Get window scale DPI factor for current monitor Vector2 GetWindowScaleDPI(void) { - TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform"); return (Vector2){ 1.0f, 1.0f }; } From d68b8eb1131f89510e86d7b30cb935fe21c538bf Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 11 Apr 2024 12:13:44 +0800 Subject: [PATCH 42/44] Update main.c --- projects/Xcode15/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/Xcode15/main.c b/projects/Xcode15/main.c index 7fa60769..f6680f09 100644 --- a/projects/Xcode15/main.c +++ b/projects/Xcode15/main.c @@ -10,6 +10,7 @@ * Copyright (c) 2016-2024 Ramon Santamaria (@raysan5) * ********************************************************************************************/ +#ifndef RL_IOS_NO_EXAMPLE #include "raylib.h" @@ -118,3 +119,5 @@ void ios_update() void ios_destroy(){ CloseWindow(); // Close window and OpenGL context } + +#endif From a3873bf759eeef1be80f08f82eaed61c27607e59 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 11 Apr 2024 13:00:06 +0800 Subject: [PATCH 43/44] Update project.pbxproj --- projects/Xcode15/raylib.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/Xcode15/raylib.xcodeproj/project.pbxproj b/projects/Xcode15/raylib.xcodeproj/project.pbxproj index a1fdcc57..8f2b0d12 100644 --- a/projects/Xcode15/raylib.xcodeproj/project.pbxproj +++ b/projects/Xcode15/raylib.xcodeproj/project.pbxproj @@ -347,7 +347,7 @@ PLATFORM_IOS, GL_GLEXT_PROTOTYPES, ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = ""; @@ -392,7 +392,7 @@ PLATFORM_IOS, GL_GLEXT_PROTOTYPES, ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_UNINITIALIZED_AUTOS = YES; GENERATE_INFOPLIST_FILE = YES; HEADER_SEARCH_PATHS = ""; From 1de43bfb49dd8b17066fc3f5f86e6d7488a92465 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 12 Apr 2024 19:11:07 +0800 Subject: [PATCH 44/44] Update rcore_ios.c --- src/platforms/rcore_ios.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index 59c5437c..c067bfdc 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -549,6 +549,15 @@ int InitPlatform(void) } else { + CORE.Window.display.width = [[UIScreen mainScreen] nativeBounds].size.width; + CORE.Window.display.height = [[UIScreen mainScreen] nativeBounds].size.height; + if(CORE.Window.screen.width == 0){ + CORE.Window.screen.width = [[UIScreen mainScreen] bounds].size.width; + } + if(CORE.Window.screen.height == 0){ + CORE.Window.screen.height = [[UIScreen mainScreen] bounds].size.height; + } + CORE.Window.render.width = CORE.Window.screen.width; CORE.Window.render.height = CORE.Window.screen.height; CORE.Window.currentFbo.width = CORE.Window.render.width;