I drew some icons to use on orthographic projection and instead of loading each icon file individually as a texture I thought of putting them all together in one single file. Now I have a file 72x36 which is not a power of two. This texture is divide in two icons, both with 36px wide.
I didn't remember about this restriction when designing the texture but I eventually noticed it when the texture didn't load because I have an if statement checking if the texture is a power of two, if it's not, than the texture is not loaded. I commented that code to see if the texture loaded anyway and it did. The texture was loaded and properly applied to the area I wanted.
To draw the first icon I do this:
glBindTexture(GL_TEXTURE_2D, gameTextures.hudKeys);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(0, 36);
glTexCoord2f(0.5, 0); glVertex2f(36, 36);
glTexCoord2f(0.5, 1); glVertex2f(36, 0);
glTexCoord2f(0, 1); glVertex2f(0, 0);
glEnd();
And for the second this:
glBindTexture(GL_TEXTURE_2D, gameTextures.hudKeys);
glBegin(GL_QUADS);
glTexCoord2f(0.5, 0); glVertex2f(0, 36);
glTexCoord2f(1, 0); glVertex2f(36, 36);
glTexCoord2f(1, 1); glVertex2f(36, 0);
glTexCoord2f(0.5, 1); glVertex2f(0, 0);
glEnd();
Which is easy to understand, I only use half of the texture depending on which icon I want.
I don't want my icons to be distorted or stretched, the icons were designed with 36x36 in mind. If I use a power of 2 texture, for instance 128x64 (that's the lowest possible to fit a 72x36 texture), how do I properly map the 36x36 texture area I want to the quad?
Or maybe I can keep doing using this NPOT texture or should I still really create a power of 2 texture? How to fix the problem above then?