Skip to content
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

iOS port fixes and Xcode project improvements #2259

Merged

Conversation

edmundito
Copy link
Contributor

@edmundito edmundito commented Dec 10, 2023

Resolves #1505

This includes some changes in the iOS port to make it fully compatible with SDL and bring it up to par to where it was before, and added some minor improvements to the Xcode project.

iOS Port improvements

  • Added configure calls to the GL driver to set the GL RGB bits to 8 8 8, so that the SDL ios OpenGL view set the color format to kEAGLColorFormatRGBA8
    https://github.com/libsdl-org/SDL/blob/release-2.28.5/src/video/uikit/SDL_uikitopenglview.m#L98-L102
  • Fix type warnings in the iOS platform driver cpp
  • Update iOS platform driver to show iOS alert through SDL
  • Update delay call in the iOS platform driver to use SDL_delay
  • Update agstouch plugin to show, hide, and check status of virtual keyboard by using SDL calls

Xcode improvements

  • Split the targets into three parts: One for the third party libs, one for AGS as an engine, and one for the game application
  • Remove files in Xcode project that were removed in master
  • Update iOS XCode file settings for ali3dogl and acplios to indent with 2 spaces (because that's how they are right now)

Target splitting

The Xcode project now builds into three parts, which simplifies a lot of things:
Captura de pantalla 2023-12-10 a la(s) 1 55 17 p m

  • AGS_ThirdParty_iOS builds all the external libraries from libsrc (excluding SDL) into a static library (.a) file
  • AGS_iOS is an binary framework containing the Common, Engine, and Plugins
  • AGS Game is the actual aplication itself. It only builds the files added to the game and references the two libraries above and the SDL framework, and serves as an example setup for an Xcode project

This change will developers porting to iOS to be able to export the AGS and SDL into their own Xcode project, instead of having to fork the whole source code per game.

}

void AGSIOS::Delay(int millis) {
usleep(millis);
Copy link
Contributor Author

@edmundito edmundito Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this was incorrect the whole time because usleep accepts seconds and not milliseconds, so a conversion was needed. The SDL Implementation uses the best option for the platform and takes milliseconds as the input.

@edmundito edmundito marked this pull request as draft December 10, 2023 18:40
@edmundito edmundito force-pushed the edmundito/ios-port-3.6.x branch from 537efe6 to 6018cca Compare December 10, 2023 18:41
@edmundito edmundito marked this pull request as ready for review December 10, 2023 19:03
@edmundito
Copy link
Contributor Author

This should be ready for review after speaking with @ericoporto and realizing there were a few changes that needed to be pulled in. Tested locally with a real AGS game to ensure that it builds and runs properly. Only tested the simulator build.

@ivan-mogilko ivan-mogilko added system: ios backend: sdl2 related to sdl2 library labels Dec 10, 2023

// Debug::Printf(kDbgMsg_Info, text);

Debug::Printf(kDbgMsg_Warn, displbuf);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The safer form would be similar to one previously used with printf:
Debug::Printf(kDbgMsg_Warn, "%s", displbuf);
This is in case input contained formatting tokens.

@ivan-mogilko
Copy link
Contributor

Question: why does iOS port need the search for games? Is not it supposed to receive game location passed into cmd args similar to Android?

@ericoporto
Copy link
Member

Question: why does iOS port need the search for games? Is not it supposed to receive game location passed into cmd args similar to Android?

Guess that is on me, it's true, this is a possibility, I think in Android I had a better understanding of Java and the system to wire-up the things that make that work - note you never set the name of the game manually in the Android single game project and it still manages to make it work!

In iOS we have the world of ObjectiveC, the Xcode project and things like that, I didn't had a good enough understanding of it to figure a way to make it pass the internal path of the game without one have it hardcoded in acplios itself (like game.ags or similar), but leaving AGS to discover the ags game file in the bundle does work - and one doesn't have to rename their game to game.ags or adjust the code.

@edmundito
Copy link
Contributor Author

Pushed a couple of changes:

  • Fix for @ivan-mogilko 's feedback on Debug::Printf
  • Moved building the libsrc c files in Engine and Core from the AGS_iOS framework to AGS_ThirdParty_iOS lib

@edmundito
Copy link
Contributor Author

Pushed a couple of more changes after testing on device:

  1. Remove the default bundle identifier because setting it to something specific may register with Apple causing conflicts. Developers should define an identifier for their domain before testing.
  2. Added the allow highdpi flag (suggestion by @ericoporto) after testing the high-dpi game Stranger in Utopia

@edmundito edmundito force-pushed the edmundito/ios-port-3.6.x branch from b6547d4 to 2e757a1 Compare December 10, 2023 22:11
@ivan-mogilko
Copy link
Contributor

In iOS we have the world of ObjectiveC, the Xcode project and things like that, I didn't had a good enough understanding of it to figure a way to make it pass the internal path of the game without one have it hardcoded in acplios itself (like game.ags or similar), but leaving AGS to discover the ags game file in the bundle does work - and one doesn't have to rename their game to game.ags or adjust the code.

Could you please add a TODO comment somewhere around that code, explaining this case?

@ericoporto
Copy link
Member

I will write this in better details and add as a TO-DO in either the Readme or in acplios.

@ivan-mogilko ivan-mogilko merged commit 5c33201 into adventuregamestudio:master Dec 14, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: sdl2 related to sdl2 library system: ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port AGS 3.6.0 to iOS (SDL2 backend)
3 participants