Blank Textures in VC6 Release Mode (Win32)

I’m having some trouble with texturing when I use the Release configuration in Visual C++ 6.

I’m applying a texture to a quad, and it works just fine using the “Debug” configuration. When I switch to the “Release” configuration, the quad appears totally black.

The texture comes from a PPM file, which I’m reading through a custom routine.

I tried modifying the checker.c program from the redbook to apply the checker texture to one quad and my texture to another quad. The checker texture works in both Debug and Release, but my texture only works in Debug mode (again, the quad is all black in Release). Clearly, there must be something different with my texture loading code, but I’m baffled as to why it would only fail in Release mode.

Any ideas would be welcomed.

The problem turned out to be a bug in my PPM reading code; specifically, a problem with fscanf() and unsigned chars.

Before:

unsigned char *image, *traverse, red, green, blue;

// ...other code

fscanf(fp, "%d %d %d",&red, &green, &blue);

After:

unsigned char *image, *traverse;
unsigned int red, green, blue;

// ...other code

fscanf(fp, "%d %d %d",&red, &green, &blue);

I changed the variables passed to fscanf() from unsigned chars to unsigned ints, then assigned the unsigned ints to the unsigned chars representing my texture data later on in the code.