1

I've been trying to submit a texture to the HTC Vive using the compositor. I keep getting 105 errors which is "TextureUsesUnsupportedFormat". The Texture is a bmp image 24 bit Depth. I've looked at the hellovr sample and still a bit confused. I also saw that the Vive requires a RGBA8 format for the texture but not sure how to actually make one. I am trying to get the texture to fill up each Eye port.

What am I doing wrong?

Here's my Code to retrieve the Texture and texture id:

Loading_Surf = SDL_LoadBMP("Test.bmp");
Background_Tx = SDL_CreateTextureFromSurface(renderer, Loading_Surf);


if (!Loading_Surf) {

    return 0;
}

glGenTextures(1, &textureid);

glBindTexture(GL_TEXTURE_2D, textureid);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, Loading_Surf->w, Loading_Surf->h, 0, mode, GL_UNSIGNED_BYTE, Loading_Surf->pixels);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

SDL_FreeSurface(Loading_Surf);

SDL_RenderCopy(renderer, Background_Tx, NULL, NULL);
SDL_RenderPresent(renderer);
return textureid;

Submitting to Vive Code:

vr::Texture_t l_Eye = { (void*)frameID, vr::API_OpenGL, vr::ColorSpace_Gamma };
std::cout << vr::VRCompositor()->WaitGetPoses(ViveTracked, vr::k_unMaxTrackedDeviceCount, NULL, 0);
error = vr::VRCompositor()->Submit(vr::Eye_Left, &l_Eye);
4

2 回答 2

1

您可能需要先创建一个具有正确 RGBA8 格式的表面,如本答案所述:https ://gamedev.stackexchange.com/a/109067/6920

使用您想要的确切图像格式创建一个临时表面 (SDL_CreateRGBSurface),然后将 Loading_Surf 复制到该临时表面 (SDL_BlitSurface)

于 2017-01-10T17:51:24.500 回答
0

RGBA8需要 32 位。您的位图只有 24 位。好像alpha频道不见了。

尝试将其复制到一个更大的容器中,4x8-bit每个像素 = 32 位(在 c++ 中,您可以使用char或使用某些图像库)。

RGB8或者,如果存在类似的东西(使用 OpenGL),您会想办法为您的设备提供纹理。

这可以帮助您https://www.khronos.org/opengl/wiki/Texture

于 2017-01-10T17:49:50.650 回答