What do I fill in as Swapchain format in OpenGL?

(I wasnt allowed to include links, so I have to try to explain without them):

I am converting:

from D3D11 to OpenGL to use in my own project.

When filling in the XrSwapchainCreateInfo at line 363 he puts a value for format, DXGI_FORMAT_R8G8B8A8_UNORM which equals to 28 according to DXGI_FORMAT enumerations.

If I am using OpenGL, what do I put in here? I cant use GL enums because they dont return int64_t values. I have also tried to use their corresponding OpenGL bindings values, but I always get XrResult = -26 (XR_ERROR_SWAPCHAIN_FORMAT_UNSUPPORTED)

For example, I tried both 6408 (GL_RGBA) and 3553 (GL_TEXTURE_2D).

What number does it expect here with OpenGL? And what are my choices?

Here on linux with the glvnd OpenGL implementation, the texture formats are simple defines like

#define GL_SRGB8_ALPHA8                   0x8C43

You should call xrEnumerateSwapchainFormats and pick the first format in the list that your app knows how to deal with.

The spec also has some example format names/defines: The OpenXR™ Specification

If your OpenGL implementation has the exact values as enum values instead of defines, just cast them I guess.

That’s new user spam prevention. Keep reading+posting and you’ll be allowed to post links in no time.

That reasoning doesn’t follow. This type just needs to encompass format types across all supported graphics APIs.

As haagch indicated, in OpenGL these are OpenGL internal formats (sometimes referred to as OpenGL texel formats). Following the man pages points this out.

For instance:

says:

And if you daisy-chain over to that link, you find:

Thanks alot for the answers guys. I actually tried XrEnumerateSwapchainFormats yesterday, but didnt get anything back. I probably wrote something wrong :sweat_smile:

But your answers confirmed I must have been doing something wrong, and by reimplementing the enumerate function call I got my formats :partying_face:

In case anyone else reads this post for information, here is my code:

//GET SUPPORTED SWAPCHAIN TEXTURE FORMATS
	uint32_t scf_count = 0;
	xrEnumerateSwapchainFormats(xr_session, 0, &scf_count, nullptr);
	std::vector<int64_t> scformats(scf_count, 0);
	xrEnumerateSwapchainFormats(xr_session, scf_count, &scf_count, scformats.data());

	globjects::debug() << "Swapchain Formats:";
	for (size_t i = 0; i < scformats.size(); i++) {
		globjects::debug() << scformats[i];
	}

The debug print you might want to change offcourse, depending on your method.

Thanks guys!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.