【问题标题】:How to submit textures to the HTC Vive?如何向 HTC Vive 提交纹理?
【发布时间】:2017-01-10 13:49:04
【问题描述】:

我一直在尝试使用合成器向 HTC Vive 提交纹理。我不断收到 105 个错误,即“TextureUsesUnsupportedFormat”。纹理是 24 位深度的 bmp 图像。我看过 hellovr 样本,但仍然有点困惑。我还看到 Vive 需要 RGBA8 格式的纹理,但不确定如何实际制作。我正在尝试让纹理填满每个眼孔。

我做错了什么?

这是我检索纹理和纹理 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;

提交给 Vive 代码:

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);

【问题讨论】:

    标签: opengl openvr htc-vive


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

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

      或者,如果存在类似的东西,你会想办法用RGB8 纹理来喂你的设备(玩弄 OpenGL)。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多