c++ texture problem

in my game, almost all of the textures are skewed and some of them are B/W. The code for loading the textures is fine and the following is the code to draw the objects:

glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 0.0f); glVertex3f(bounds[d][0][0] * levelscale, top[d], bounds[d][0][1] * levelscale);
glTexCoord2f(0.0f, repeat[d]); glVertex3f(bounds[d][0][0] * levelscale, bottom[d], bounds[d][0][1] * levelscale);
glTexCoord2f(repeat[d], repeat[d]); glVertex3f(bounds[d][1][0] * levelscale, bottom[d], bounds[d][0][1] * levelscale);
glTexCoord2f(repeat[d], 0.0f); glVertex3f(bounds[d][1][0] * levelscale, top[d], bounds[d][0][1] * levelscale);
glEnd();
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 0.0f); glVertex3f(bounds[d][1][0] * levelscale, top[d], bounds[d][1][1] * levelscale);
glTexCoord2f(0.0f, repeat[d]); glVertex3f(bounds[d][1][0] * levelscale, bottom[d], bounds[d][1][1] * levelscale);
glTexCoord2f(repeat[d], repeat[d]); glVertex3f(bounds[d][0][0] * levelscale, bottom[d], bounds[d][1][1] * levelscale);
glTexCoord2f(repeat[d], 0.0f); glVertex3f(bounds[d][0][0] * levelscale, top[d], bounds[d][1][1] * levelscale);
glEnd();
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 0.0f); glVertex3f(bounds[d][0][0] * levelscale, top[d], bounds[d][0][1] * levelscale);
glTexCoord2f(0.0f, repeat[d]); glVertex3f(bounds[d][0][0] * levelscale, bottom[d], bounds[d][0][1] * levelscale);
glTexCoord2f(repeat[d], repeat[d]); glVertex3f(bounds[d][0][0] * levelscale, bottom[d], bounds[d][1][1] * levelscale);
glTexCoord2f(repeat[d], 0.0f); glVertex3f(bounds[d][0][0] * levelscale, top[d], bounds[d][1][1] * levelscale);
glEnd();
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 0.0f); glVertex3f(bounds[d][1][0] * levelscale, top[d], bounds[d][1][1] * levelscale);
glTexCoord2f(0.0f, repeat[d]); glVertex3f(bounds[d][1][0] * levelscale, bottom[d], bounds[d][1][1] * levelscale);
glTexCoord2f(repeat[d], repeat[d]); glVertex3f(bounds[d][1][0] * levelscale, bottom[d], bounds[d][0][1] * levelscale);
glTexCoord2f(repeat[d], 0.0f); glVertex3f(bounds[d][1][0] * levelscale, top[d], bounds[d][0][1] * levelscale);
glEnd();

repeat[] is an integer

Try using glintercept (http://glintercept.nutty.org/) - it will make a text file with all values that you passed to glTexCoord2f and glVertex3f. Really nice tool - just copy OpenGL32.dll to your game folder and take a look into gliConfig.ini.
If you want to run without glIntercept you can just rename that OpenGL32.dll file to something else until you need it again.

is it possible that the textures have a width/height which is not dividable by 8?

Why are you using GL_POLYGON? Looks like to me you are making GL_QUADS… IIRC GL_POLYGON is slower than GL_QUADS but don’t quote me on that. And are you using mipmapping?

Skewed and miscolored textures are normally a sign for wrong glPixelStore(GL_UNPACK_ALIGNMENT, …) settings.
If you have GL_RGB the default unpack alignment of 4 won’t work for texures which are not a multiple of 4 in size (e.g. mipmaps 2x2 and 1x1 and non-power-of-two textures). Use an alignment of 1 if the data is tightly packed.
Greyscale instead of colored textures could also point to a mismatch in color channel layouts or complete format mismatch.
I would say your texture loading code is not ok.

How big is repeat[d]? If you scale the texture too much you will only get a bunch of aliased texel noise.

The code above looks awfully slow. As said by Mars you can group them into one GL_QUADS primitive and don’t copy paste so much, use some local variables to calculate the parameters you use multiple times.

cool my textures were mis-sized and making them good was hot! tyvm