Loading Images to GPU which are not in power of 2

Started by
5 comments, last by 21st Century Moose 7 years, 2 months ago

I want to work with a Kinect Camera. So I have got a sequence of images of resolution 512*424 for the Kinect from Xbox One. Now I want to load these Images and interpret the depth maps as point clouds and align the color from the rib images, for model reconstruction.

For the moment I just load up the image to the GPU and want to render it to the screen, but the screen stays black. I pretty sure it is because the width and hight are not in a power of 2 and I heard OpenGL has problems doing this.

Now the question is, is there a way to let OpenGL know, that this is a image, that doesn't have that power of 2 and it just allows it? Or do I have to change the image is a resolution so it get's to the power of 2? And if I have to change it, how can I actually change it, without adding, new information to it?

Advertisement

If you have at least OpenGL 2.0, then you have NPOTs. This should also be transparent.

If not, then I highly suggest you to upgrade your driver/hardware as far as possible.

You might also be interested in texture rectangles.

Can you let us know how you deal with these images (do you use them as textures as I implicitly believed, do you use them with FBOs ?) ?

I use them as a texture. The idea is to load images to the GPU as a texture. Than to run algorithms on them, for updating the reconstruction, by rendering passes and that is done with FBO's. But it is actually important to have that images as a texture.

GL_ARB_texture_non_power_of_two is absolutely standard on all hardware since at least the past 10 years. This gives full non-conditional non-power-of-two support with mipmap, filtering and wrap modes available.

Hardware older than that, you may get the occasional case of it not being available, or even cases of it being available but dropping you back to software emulated paths in the driver.

A rule of thumb: if it only supports GL 2.0 or 2.1 assume that it's software emulated; if it supports 3.0 or higher you can rely on it being available in hardware.

GL_ARB_texture_rectangle is an older extension which may be available on pre-GL 2.0 hardware, and which gives conditional non-power-of-two support: no filtering, no mipmaps, no wrap modes. A GL-specific quirk is that they also use non-normalized texture coords. You probably don't want to use this extension, even if non-power-of-two support is not otherwise available.

As an alternative you could pad your texture dimensions. In your case you would create a 512x512 texture with NULL data (which will create the texture object and is legal as of GL 1.2), then use glTexSubImage to load data to it. Adjust your texcoords so that s goes from 0 to 1 and t from 0 to 424/512.

However, I don't think any of this is your problem. As has been said, the likelihood is that your GPU (and it would help if you said which GPU you have) actually does have non-power-of-two support. I consider it more probable that you have a different issue elsewhere, with attempting to use an incomplete texture being what I consider most likely.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

I can not say if that was the problem, but I made the 512x512 texture and filled it with zeros, and not it works. Thanks a lot

I can not say if that was the problem, but I made the 512x512 texture and filled it with zeros, and not it works. Thanks a lot

So it works ?

The "solution" you choose looks to me like a tree hiding a forest. What mhagain said is that you can fallback to this if you are really stuck with your hardware/driver being prior to OpenGL 2.0, instead of using the texture rectangle like I proposed since texture rectangles use a different way to deal with texture coordinates and that it lacks some useful things like filtering.

But this is not a solution as if OpenGL has issues with NPOT textures. Since it doesn't since 15 years or more (just like Direct3D I assume).

I can not say if that was the problem, but I made the 512x512 texture and filled it with zeros, and not it works. Thanks a lot

Can you confirm what your GPU is please?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement