-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rcore] Porting raylib to iOS and implement rcore_ios.c
#3880
Open
blueloveTH
wants to merge
44
commits into
raysan5:master
Choose a base branch
from
blueloveTH:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,432
−9
Open
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
d0a13c6
init
blueloveTH 0caa413
create XCode15 project targeting iOS
blueloveTH b3b2d50
Update rcore_ios.c
blueloveTH dfc6dc2
some update
blueloveTH d1ffab4
the first working version
blueloveTH cae863a
some fix
blueloveTH 2900607
prepare to add touch callbacks
blueloveTH 74da3b7
Update rcore_ios.c
blueloveTH 9f7dec6
support more touches
blueloveTH c66c9e9
some fix
blueloveTH a552997
change `pointId[]` to `long long`
blueloveTH 5db5720
Update raylib_api.* by CI
github-actions[bot] c0ac347
Update rcore_ios.c
blueloveTH 3a9649d
Update rcore_ios.c
blueloveTH 67fb284
upgrade to `GRAPHICS_API_OPENGL_ES3`
blueloveTH 0a9ea31
Update rlgl.h
blueloveTH cd1b81d
Update project.pbxproj
blueloveTH 33ccfd9
Create ios.yml
blueloveTH ed861d0
Update ios.yml
blueloveTH da46011
Update ios.yml
blueloveTH 2e29d3f
Update ios.yml
blueloveTH ee2a307
Update rcore_ios.c
blueloveTH e6afac8
Update rcore_ios.c
blueloveTH e5ecddf
Update rcore_ios.c
blueloveTH 86b3ba2
Update rcore_ios.c
blueloveTH c124623
Update rcore_ios.c
blueloveTH f3c4d49
Update rcore_ios.c
blueloveTH d1a8b86
Revert "change `pointId[]` to `long long`"
blueloveTH faaa623
revert long long change
blueloveTH 4a7b666
Update raylib_api.* by CI
github-actions[bot] bc34ea6
Update rcore_ios.c
blueloveTH 3c12964
Update rcore_ios.c
blueloveTH b69cee5
Update rcore_ios.c
blueloveTH 5241819
Update rcore_ios.c
blueloveTH d10d888
Update rcore_ios.c
blueloveTH 8fbec6f
Revert "Update raylib_api.* by CI"
blueloveTH 7f9400c
Revert "Update raylib_api.* by CI"
blueloveTH cd8f5f9
Update rcore_ios.c
blueloveTH c5c41f9
Update rcore_ios.c
blueloveTH c4a42a3
Update rcore_android.c
blueloveTH 918c394
Update rcore_android.c
blueloveTH d68b8eb
Update main.c
blueloveTH a3873bf
Update project.pbxproj
blueloveTH 1de43bf
Update rcore_ios.c
blueloveTH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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 | ||
rm libGLESv2.xcframework.zip | ||
xcodebuild -project raylib.xcodeproj -scheme raylib -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/******************************************************************************************* | ||
* | ||
* raylib [core] example - Input Gestures Detection | ||
* | ||
* 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) 2016-2024 Ramon Santamaria (@raysan5) | ||
* | ||
********************************************************************************************/ | ||
#ifndef RL_IOS_NO_EXAMPLE | ||
|
||
#include "raylib.h" | ||
|
||
int MAX_GESTURE_STRINGS = 20; | ||
int screenWidth = 0; | ||
int screenHeight = 0; | ||
Vector2 touchPosition; | ||
Rectangle touchArea; | ||
int gesturesCount = 0; | ||
char gestureStrings[100][32]; | ||
int currentGesture = GESTURE_NONE; | ||
int lastGesture = GESTURE_NONE; | ||
|
||
void ios_ready(){ | ||
InitWindow(0, 0, "raylib [core] example - input gestures"); | ||
|
||
screenWidth = GetScreenWidth(); | ||
screenHeight = GetScreenHeight(); | ||
|
||
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() | ||
{ | ||
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)) | ||
{ | ||
if (currentGesture != lastGesture) | ||
{ | ||
// Store gesture string | ||
switch (currentGesture) | ||
{ | ||
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; | ||
} | ||
} | ||
} | ||
|
||
// Draw | ||
//---------------------------------------------------------------------------------- | ||
BeginDrawing(); | ||
|
||
ClearBackground(RAYWHITE); | ||
|
||
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++) | ||
{ | ||
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); | ||
} | ||
EndDrawing(); | ||
} | ||
|
||
void ios_destroy(){ | ||
CloseWindow(); // Close window and OpenGL context | ||
} | ||
|
||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are those files located? It looks a bit dodgy... isn't there a better approach?