What you made (and not only what I quoted) is non-sense for loading NPOT textures… if I understand correctly that you want to load NPOT textures, don’t you ?
So a bit of knowledge about what you’re programming could help you more than several guesses about GL errors/misunderstandings…
Hope that helps.
Edit:
I personally never have used NPOT textures, so maybe a scale is necessary, so forgive me if that’s needed…
The fact that he wants to load a NPOT texture but that he scales it into a POT texture. That was what I said in my last post.
He just said he wants to load a NPOT texture not to scale a NPOT image into a POT texture.
What I simply need is to load textures with sizes other than powers of 2. For example, 130x130, 167x167, 130x260 etc. I know that glTexImage2D accepts only powers of 2 and when I use gluBuild2DMipmaps or gluScaleImage, the textures are distorted (strange shapes, colors).
your approach should work, in my opinion. maybe it would help if you could upload the image itself and a screenshot of the distorted image, as interface suggested.
btw, have you tried to display the original image with glDrawPixels? that way you could check if the image has been correctly loaded.
I solved the problem by resizing the raw image to the nearest power of 2 by a third party library before loading the texture. Now they are displayed properly. Thanks all for the recommendations.
Moreover, gluBuild2DMipmaps should take any texture size, and will rescale it to nearest power of 2. If you get distorsion, it is probable that you messed up something… for example, you should not mess up with changin nHeight, nWidth if you use gluBuild2DMipmaps.
ZBuffer is correct. gluBuild2DMipmaps() converts the picture to a power of 2 texture if necessary.
I have used from none power of 2 textures in some of my applications. But it’s better that we rescale the image out of our program–As Jide already said.
-Ehsan-