Reputation: 13
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);
Upvotes: 1
Views: 1871
Reputation: 9528
You might need to create a surface with the correct RGBA8 format first, as mentioned in this answer: https://gamedev.stackexchange.com/a/109067/6920
Create a temporary surface (SDL_CreateRGBSurface) with the exact image format you want, then copy Loading_Surf onto that temporary surface (SDL_BlitSurface)
Upvotes: 1
Reputation: 1258
RGBA8
requires 32-bits. Your bitmap has only 24-bits. Seems like the alpha
channels is missing.
Try to copy it into a bigger container that has 4x8-bit
= 32-bit per pixel (in c++ you can use char
or you make use of some image library).
Or you figure out to feed your device with RGB8
texture if something like that exists (play around with OpenGL).
This helps you https://www.khronos.org/opengl/wiki/Texture
Upvotes: 0