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

mobile/XrApp.cpp and desktop/XrApp.cpp are largely redundant and should be combined into a single /src/XrApp #94

Closed
BattleAxeVR opened this issue Mar 20, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@BattleAxeVR
Copy link
Contributor

Per subject, the OpenXR client C++ source code should be largely platform-agnostic.

As I've been adding features like Touch controller bindings, body tracking, eye-tracking. I realized there is a lot of duplicate work needed to get it to work on PC and reach parity on mobile. If a feature doesn't work on PC (or vice versa), the instance extension simply won't be enumerated during initialization and the runtime support booleans would remain false.

As we all know. Code duplication is bad, leads to bugs, mismatches, maintenance overhead.

I recommend looking at OpenXR SDK Source's "hello_xr", which uses a single CPP file implementation for all platforms. Platform-specific stuff belongs in their respective abstraction layers, or at most, an ifdef or two.

I don't want to have to duplicate controller bindings that should be exactly the same. Over time XrApp will get larger and larger and the amount of duplicated code (+potential bugs) would increase. Having to add the same code to each XrApp.cpp is already costing me time so it's best if it's moved sooner than later.

Thanks.

@BattleAxeVR
Copy link
Contributor Author

Alternative: one could also potentially make an XrAppBase.h / .cpp and then inherit to XrAppMobile, XrAppDesktop with a few virtuals, but I think that may be a bit too much overhead than simply one or two platform ifdefs in a single XrApp.cpp file with no base class.

OTOH making a base class is a good way to allow even XrAppMobile or XrAppDesktop to be inherited / subclassed for other projects (like mine) to customize. Either way works for me, I just don't like having to duplicate work or copy-paste and then fix all the same issues in two places, potentially forgetting some, or having a space out of place.

@corporateshark corporateshark added the enhancement New feature or request label Mar 28, 2024
@rokuz rokuz self-assigned this May 29, 2024
@rokuz
Copy link

rokuz commented May 31, 2024

Should be fixed, no more desktop folder

@rokuz rokuz closed this as completed May 31, 2024
@BattleAxeVR
Copy link
Contributor Author

Thanks so much, merged it already, looks good.

Now I can make a PR with the Simple / Touch / Touch Pro / Pico Neo 3&4 and HTC Focus 3 / XR Elite controller bindings I have in my branch. To make it a worthwhile PR for everyone I suppose I'll draw some extra cubes for the controller poses in the basic HelloWorld XR sample, if that works for you, or I can make a new sample but that's additional maintenance overhead with all the other refactoring you guys are going.

@rokuz which do you prefer? Reuse same basic sample to draw controller poses, or make a new one? Either is fine.

@rokuz
Copy link

rokuz commented May 31, 2024

Thank you for your contribution!

New sample would be better IMO.
Also please note, refactoring is not finished yet, probably it's worth wait for a week, but up to you

@BattleAxeVR
Copy link
Contributor Author

Sure thing! I'll wait till you're done.

@rokuz
Copy link

rokuz commented Jun 5, 2024

@BattleAxeVR Thanks for waiting. The refactoring has been landed

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

No branches or pull requests

3 participants