It seems that OpenGL can take only texture images of the 2^kx2^k format. Can this be changed? If no, is there some code of work-arounds for this problem?
Yes it cans but I don’t know how to do it.
Your statement is not totally correct : OpenGL handles textures of size 2^m x 2^n (which means a rectangle) ! When you say 2^k x 2^k, you define a square…
Then, if you want to use a texture that does have that type or dimension, there are two options :
1 - Scale you texture (you can use a linear scaling for a start ; pretty easy to code) so that it fits in a 2^m x 2^n bitmap.
2 - Just create a texture of size 2^m x 2^n and copy your texture at (0,0) in the new one… That can be compare to watching an image in a bigger window (part of the window is useless !). The problem with this method is that you then have to tweak your texture coordinates i.e. the bottom right of your texture is not (1,1) but (0.xx,0.yy) !
Here is part of a code I used which implements the first method :
tUsedHeight and tUsedWidth are the real dimensions of your texture. tImage is an array of GLubyte that contains the actual pixels…
unsigned char* adjustedImage;
adjustedImage = new unsigned char[tWidthtHeight4];
delete  tImage;
That’s a crappy scaling algorithm but it works !
Thanks, but I’ll use the second method because I have some scientific applications in mind. First one has a double interpolation.