-
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
[Android] [gui] Add initial support of Android in GGUI #3845
Conversation
✔️ Deploy Preview for jovial-fermat-aa59dc canceled. 🔨 Explore the source changes: 86c8047 🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/61c201d25fbab300088e18b0 |
This is an initial draft to allow using GGUI on Android, I'm not an entire fan of the changes in GGUI to run with Android but this is the simple transition I could do without impacting too much the code right now, the main issue is that GLFW code is a bit everywhere :). Here is a quick example on how to use it for Android as well: https://github.com/ghuau-innopeak/taichi-aot-tests/blob/main/android/app/src/main/cpp/main.cpp (it's test code... :)) |
eb6cbdb
to
ee4a500
Compare
ee4a500
to
1f81481
Compare
This is amazing! |
@@ -144,7 +154,7 @@ void Renderable::create_graphics_pipeline() { | |||
void Renderable::create_vertex_buffer() { | |||
size_t buffer_size = sizeof(Vertex) * config_.max_vertices_count; | |||
|
|||
Device::AllocParams vb_params{buffer_size, false, false, | |||
Device::AllocParams vb_params{buffer_size, true, true, |
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.
May I ask why this is needed for Android?
If this is really necessary, then we should guard it with #if ANDROID
so that it doesn't hurt the performance of GGUI on other platforms.
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.
This is not needed, this is something I forget to revert during my testing... good catch! :D, it should be fixed.
#ifdef ANDROID | ||
#include <android/native_window.h> | ||
typedef ANativeWindow TaichiWindow; | ||
#else | ||
typedef GLFWwindow TaichiWindow; | ||
#endif |
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.
tiny nit, let's use using A = B
instead of typedef B A
, and maybe put TaichiWindow
inside taichi::ui
?
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.
Done! My habits of C developer :), I left the #include
outside as well to avoid having all the functions from this header inside the Taichi namespace, I think I could have used namespace { #include <android/native_window.h> }
instead to avoid the extra ifdef ANDROID
but not sure what is preferred here.
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.
I think this is fine.
cd66776
to
c45a6fa
Compare
c45a6fa
to
86c8047
Compare
@AmesingFlank Perfect :), I added a comment in the struct to clarify the usage of both fields. |
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.
LGTM! Looking forward to seeing a demo on Android :D
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.
LGTM
Related issue = #3679