Skip to content

OpenXR only visuals headset #2620

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 40 commits into
base: main
Choose a base branch
from
Open

OpenXR only visuals headset #2620

wants to merge 40 commits into from

Conversation

nishbo
Copy link

@nishbo nishbo commented May 11, 2025

Disabled by default. For description, see README. RFC

void SimulateXr::init() {
// Needed for textures
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
mju_warning("Failed to initialize OpenGL context for OpenXR.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we can't init we should probably error?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, changed this. Many of the other warnings can be useful because the whole system will still launch, just without the XR

if (strcmp(requestLayer.c_str(), layerProperty.layerName) != 0) {
continue;
} else {
m_activeAPILayers.push_back(requestLayer.c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like we add if requestLayer equals layerProperty, which is different to the comment on the requestLayer for loop?

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, it is a bit confusing, also due to the fact that m_apiLayers stays empty. I took most of this chunk from the openxr example, where it is not used, too. I think it can be used when integrating with more modern OpenGL versions or for some other functionality if there is desire.

if (xrEnumerateApiLayerProperties(apiLayerCount, &apiLayerCount,
apiLayerProperties.data()) < 0) {
mju_warning("Failed to enumerate ApiLayerProperties.");
return -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Enums for these returns would improve readability

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, we can introduce an error enum or class here, never got my hands on reading up what is the google styleguide for those.

std::end(supportSwapchainFormats));
if (swapchainFormatIt == formats.end()) {
mju_warning("ERROR: Unable to find supported Color Swapchain Format");
return 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this returning success when failure is intended?

Copy link
Author

Choose a reason for hiding this comment

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

It is never really checked directly if it is successful, but the next xrCreateSwapchain with format set to 0 fails, which will highlight the previous failure at finding the format. I guess it could throw an error earlier, too.

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