ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.07k stars 1.28k forks source link

IVROverlay::SetOverlayTexture not working #109

Open jamesu opened 8 years ago

jamesu commented 8 years ago

I'm attempting to create an overlay based on a D3D11 texture using the IVROverlay::SetOverlayTexture method, however I don't appear to be having much luck here.

If I use an RGB texture, I just get a black rectangle. If I use an RGBA texture, I don't appear to get anything displayed. Any other format (such as a compressed texture format) seems to give me the vr::VROverlayError_InvalidTexture error

If I instead use the IVROverlay::SetOverlayFromFile method, the textures load. Since i'm intending the overlay to be a GUI however, this isn't really too practical (nor is IVROverlay::SetOverlayRaw).

The code I am using (which uses the texture abstraction in the engine i'm using - texture loading code for ref is at https://github.com/GarageGames/Torque3D/blob/development/Engine/source/gfx/D3D11/gfxD3D11TextureManager.cpp#L46 ) to set the texture is as follows:

vr::Texture_t tex;
mStagingTexture.set("core/art/particles/fire", &GFXDefaultStaticDiffuseProfile, "...");
tex = { (void*)static_cast<GFXD3D11TextureObject*>(mStagingTexture.getPointer())->getResource(), vr::API_DirectX, vr::ColorSpace_Auto };
vr::EVROverlayError err = vr::VROverlay()->SetOverlayTexture(mOverlayHandle, &tex);

"getResource()" in this case returns the ID3D11Resource* of the texture. I am also calling IVROverlay::ShowOverlay before this (there seems to be no difference calling it after either).

The texture format used is either DXGI_FORMAT_B8G8R8X8_UNORM or DXGI_FORMAT_B8G8R8A8_UNORM depending if an RGB or RGBA texture is used.

Any assistance in figuring out what i'm doing wrong here would be much appreciated.

jamesu commented 8 years ago

Investigated this a little further, it seems if instead I use DXGI_FORMAT_R8G8B8A8_UNORM it works, so it looks like openvr is simply really fussy over the texture format in this case - a fact which does not appear to be documented in any form.