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

How do I... #16

Open
pachuco opened this issue Mar 25, 2024 · 3 comments
Open

How do I... #16

pachuco opened this issue Mar 25, 2024 · 3 comments

Comments

@pachuco
Copy link

pachuco commented Mar 25, 2024

What is the lifecycle of a buffer and how do I change the buffer in case of screen orientation change(treating it like "windows has changed size, new buffer needed" on desktop)? tgui_create_image_view(), is this even the right type of view I need?

Basically I want to create bitmap gui that always occupies full screen and handles rotation.

https://gist.github.com/pachuco/4c769f1a55d1745fd38b76ea445ed3cc/fd91f9747c7694ef19c01ce1b9faaa8d103c0e83
This is my code so far. Feel free to poke at other deficiencies.

@tareksander
Copy link
Owner

If you want to draw using the CPU, this is the right approach. The TGUI_EVENT_CONFIG event can give you the current Activity size, you can request the initial size with tgui_activity_get_configuration. Buffers are created with tgui_add_buffer and have to be deleted with tgui_delete_buffer, otherwise you'll leak memory. To change the buffer you'd create a new buffer with the right size, set the ImageView to display that buffer, refresh the ImageView, and finally delete the old buffer.

If you want me to review more of your code, you should use less swearwords for variables.

@pachuco
Copy link
Author

pachuco commented Mar 26, 2024

https://gist.github.com/pachuco/4c769f1a55d1745fd38b76ea445ed3cc/a32a529b49dcef579641701c5b90e0b64a4e6a9b
Ok, now I'm cooking with gas!
There is now issue where turning the phone will sometimes not update dimensions accordingly(buffer displayed as mailboxed image).
Maybe I should be using surface view instead?

If you want me to review more of your code, you should use less swearwords for variables.
Since I am in position of beggar and not chooser, it's a fair trade. I cleaned the code.
Haha, you should see VibeJive project on my git for cringe-inducing 2010-era namings!

If I clean it up sufficienly, maybe I can submit it later as PR, before taking code in my direction.

@tareksander
Copy link
Owner

Do the config events with the correct dimensions arrive?

SurfaceView is for Android 8.0+, and you can use it with CPU rendering, though the intended use case is GPU rendering.

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

No branches or pull requests

2 participants