8000 Android platform support (rebased on 3.5) by kunitoki · Pull Request #2654 · glfw/glfw · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Android platform support (rebased on 3.5) #2654

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kunitoki
Copy link
@kunitoki kunitoki commented Dec 1, 2024

Let's move forward android support in glfw, can be done.

image

It's currently working nicely on YUP using GLES3.0 and the Rive Renderer (kunitoki/yup#29)

@kunitoki kunitoki requested a review from elmindreda as a code owner December 1, 2024 15:12
@kunitoki kunitoki changed the title Android platform support Android platform support (rebased on 3.5) Dec 1, 2024

struct android_app* _globalAndroidApp = NULL;

extern int main();
Copy link
Author
@kunitoki kunitoki Dec 3, 2024

Choose a reason for hiding this comment

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

This is something non standard and would need to be added to the documentation. We have 2 options:

  • The void android_main(struct android_app* app) implementation is provided by glfw and will need to forward the real main implementation to the hosting app together with the struct android_app* (here using the GLFWAPI struct android_app* glfwGetAndroidApp(GLFWwindow* window); which should also be made global, not specific to a window).
  • The hosting app will provide the void android_main(struct android_app* app) and the struct android_app* is forwarded to glfw with a custom method. This will still allow the hosting app to be more standalone and work even without having glfw in the first place.

Comment on lines +59 to +64
case APP_CMD_INIT_WINDOW:
break;

case APP_CMD_TERM_WINDOW:
//_glfwInputWindowCloseRequest(_glfw.windowListHead);
break;
Copy link
Author
@kunitoki kunitoki Dec 3, 2024

Choose a reason for hiding this comment

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

When device is rotated or app is put to sleep (background) we receive TERM_WINDOW, and when the app is again usable and foreground, we receive INIT_WINDOW. Receiving again init window will do nothing here, and we should instead setup the context in the new native window which has changed in the android_app struct.

Comment on lines 8000 +45 to +51
case APP_CMD_RESUME:
//_glfwInputWindowIconify(_glfw.windowListHead, GLFW_FALSE);
break;

case APP_CMD_PAUSE:
//_glfwInputWindowIconify(_glfw.windowListHead, GLFW_TRUE);
break;
Copy link
Author

Choose a reason for hiding this comment

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

Not sure about these, but we could find a better way to notify a glfw window about being paused and resumed.

@kunitoki kunitoki force-pushed the dev/android_support branch from 45ea2f5 to de06756 Compare December 3, 2024 16:07
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////

GLFWbool _glfwCreateWindowAndroid(_GLFWwindow* window,
Copy link
Author

Choose a reason for hiding this comment

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

Calling this more than once should produce an error.

Copy link
Author

Choose a reason for hiding this comment

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

Or we could use ASurfaceControl for each window and use the compositor from SurfaceFlinger to composite multiple windows.

@Jack253-png
Copy link

How to set orientation for this glfw window?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0