My texture shows up offset & with a seam???????

I’m trying to do a poker game in openGL. I’m using Paint.net to create the card faces and deck backs. I modified a tutorial from swiftless.com (Donald Urquhart AKA Swiftless) for texturing a 2D plain. I’m using a .bmp file with a resolution of 400pixel wide by 700 pixel height. My problem is that then I run my program ( all it does is map my card back image to a 2D plane and rotate it on all three axis) the card back image is vertically aligned (top to bottom), but it looks horizontally shifted to the right by about 100 pixels, such that the black border around the image is not at the edges of the 2D plain. I can also see a blue “seam” at that 100 pixel mark. My first question would be what is the best format to use for this type of image texturing, and how would I correct the horizontal offset. As a “quick fix” I changed the pixels to 700x700, centered my image and filled the 150 pixels on each side with black. But I would rather not settle on this as a solution, is there a library header file to collect .bmp file specs and delegate them to correct the processing error or is it simple enough that I could write my own?

Any suggestions would be a great help.

thanks

This is what my load function looks like:
/******************************************************************************
load()
function to load the file used for texturing
******************************************************************************/
GLuint load(const char *filename, int w, int h)
{
int area = w * h * 3;
GLuint texture;
unsigned char *data;
FILE *file;

//this code will read the RAW file
file = fopen(filename, "rb");

if(file == NULL) return 0;
data = (unsigned char *)malloc(area);
fread(data, area, 1, file);
fclose(file);

glGenTextures(1, &texture);				//generate the texture with the loaded data
glBindTexture(GL_TEXTURE_2D, texture);	//bind the texture to its array
//sets the texture enviro parameters
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

//Here we are setting what textures to use and when,
//the MIN filter is the quality to show
//when the texture is near the view, the MAG filter 
//is the quality to show when the texture is far from the view.

//the qualities are(in order from worst to best)
//GL_NEAREST
//GL_LINEAR
//GL_LINEAR_MIPMAP_NEAREST
//GL_LINEAR_MIPMAP_LINEAR

//When using extensions, you can use Anisotropic filtering textures
//which are an even better quality, but these will do for now

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

//here we are setting the parameter to clamp the texture
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

//generate the texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
free(data);		//free the pointer to the file data
return texture;	//return whether it was successfull

}//end of LoadTexture

TGA should be considered preferable to BMP; it loads faster (less decoding involved), needs comparitively less code, is a much simpler format, and supports an alpha channel. Right now the loading code you have seems to take no account whatsoever of the file format - BMP headers/etc, and that’s something you just can’t do. Google for a TGA loader, there are plenty of examples online.

The downside of TGA is that files can be quite large, so PNG is another good quality option, but the tradeoff is slower loading times and possibly a dependence on external libraries.

With texture loading you can’t just use any width and height you like. If you want to run on downlevel hardware you should resize all of your images to be powers-of-2 sizes; so use dimensions like 64, 128, 256, 512, 1024, etc. Make sure that you use the size loaded from your image file, NOT a size specified by the program - they might be different.

You don’t need someone’s help mapping a texture to a card.

Use texture coordinates on vertices.

0,0 = botom left, 1,1 = top right

Everything in between is linear.

Pick your own texture coordinates and someone’s library (or your misuse of it) won’t screw it up.

try glPixelStorei(GL_UNPACK_ALIGNMENT, 1);