This code from a bmp loader tut has a problem compiling, seems to be the bitmapData that is causing the prob. I’m not sure how to change it, anyone?-
16 C:\Program Files\c++\Dev-Cpp\ben-prog exturesquare3.cpp
ISO C++ forbids declaration of bitmapData' with no type 12 C:\Program Files\c++\Dev-Cpp\ben-prog exturesquare3.cpp previous declaration as
unsigned char*bitmapData’
#define BITMAP_ID 0x4D42
BITMAPINFOHEADER bitmapInfoHeader;
unsigned char *bitmapData;
unsigned int texture;
unsigned char *LoadBitmapFile(char *filename, BITMAPINFOHEADER *bitmapInfoHeader);
char image[] = { “texture.bmp” };
bitmapData = LoadBitmapFile(image, &bitmapInfoHeader);
unsigned char *LoadBitmapFile(char *file, BITMAPINFOHEADER *bitmapInfoHeader)
{
// Bitmaps are made up of 3 parts, the file header, info header, and
// the image. Once we load in the file and info headers we can then
// load the image into our unsigned char variable called bitmapData.
FILE *pFile; // Need this to open a file.
BITMAPFILEHEADER header; // This will hold the bitmap header information.
unsigned char *textureData; // This will hold the bitmap image itself.
// This will be used to swap the image colors from BGR to RGB.
unsigned char textureColors;
pFile = fopen(file, "rb"); // Open the file.
if(pFile == NULL) return NULL;// Check and make sure there are no errors.
// Read in the bitmap header info into the BITMAPFILEHEADER variable.
fread(&header, sizeof(BITMAPFILEHEADER), 1, pFile);
// Make sure this is a real bitmap by checking the ID.
if(header.bfType != BITMAP_ID)
{
fclose(pFile);
return NULL;
}
// Read in the second header info into the BITMAPINFOHEADER variable.
fread(bitmapInfoHeader, sizeof(BITMAPINFOHEADER), 1, pFile);
// Place the pointer in front of where the image data starts.
fseek(pFile, header.bfOffBits, SEEK_SET);
// Dynamically create enough memory for the image.
textureData = (unsigned char*)malloc(bitmapInfoHeader->biSizeImage);
// Error checking. Make sure the memory was allocated.
if(!textureData)
{
free(textureData);
fclose(pFile);
return NULL;
}
// Read in the image.
fread(textureData, 1, bitmapInfoHeader->biSizeImage, pFile);
// Error checking. Make sure an image was loaded.
if(textureData == NULL)
{
fclose(pFile);
return NULL;
}
// Bitmaps are saved in BGR format so we will make the image RGB by...
for(int index = 0; index < bitmapInfoHeader->biSizeImage; index+=3)
{
textureColors = textureData[index];
textureData[index] = textureData[index + 2];
textureData[index + 2] = textureColors;
}
fclose(pFile); // We are done with the file so close it.
return textureData; // Send the image to the function that called this.
}