I have the following function it takes 3 arguments being a texture array, filename and texture id but when I invoke the function using:
CreateTexture(g_Texture, "\\\\nsq021vs\\u2\\abcb433\\MyDocs\\Visual Studio 2008\\Projects\\CaptainEdsAdv\\CaptainEdsAdv\\Back.bmp", BACK_ID );
it returns this:
- pBitmap 0xcccccccc {sizeX=??? sizeY=??? data=??? } _AUX_RGBImageRec *
sizeX CXX0030: Error: expression cannot be evaluated
sizeY CXX0030: Error: expression cannot be evaluated
data CXX0030: Error: expression cannot be evaluated
This is the function its self:
void CreateTexture(UINT textureArray[], LPSTR strFileName, int textureID)
{
AUX_RGBImageRec *pBitmap = NULL;
FILE *pFile = NULL; // The File Handle we will use to read the bitmap
if(!strFileName) // Return from the function if no file name was passed in
return;
pFile = fopen(strFileName,"r"); // Check To See If The File Exists
if(pFile) // If we have a valid file pointer we found the file
{
pBitmap = auxDIBImageLoad(strFileName); // Load the bitmap and store the data
}
else // If we can't find the file, quit!
{ // Prompt the error message
MessageBox(NULL, "Couldn't find a texture!", "Error!", MB_OK);
exit(0);
}
// Generate a texture with the associative texture ID stored in the array
glGenTextures(1, &textureArray[textureID]);
// This sets the alignment requirements for the start of each pixel row in memory.
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
// Bind the texture to the texture arrays index and init the texture
glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);
// Build Mipmaps (builds different versions of the picture for distances - looks better)
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitmap->sizeX, pBitmap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitmap->data);
// Lastly, we need to tell OpenGL the quality of our texture map. GL_LINEAR_MIPMAP_LINEAR
// is the smoothest. GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR,
// but looks blochy and pixilated. Good for slower computers though.
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
// The default GL_TEXTURE_WRAP_S and ""_WRAP_T property is GL_REPEAT.
// We need to turn this to GL_CLAMP_TO_EDGE, otherwise it creates ugly seems
// in our sky box. GL_CLAMP_TO_EDGE does not repeat when bound to an object.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Now we need to free the bitmap data that we loaded since openGL stored it as a texture
if (pBitmap) // If we loaded the bitmap
{
if (pBitmap->data) // If there is texture data
{
free(pBitmap->data); // Free the texture data, we don't need it anymore
}
free(pBitmap); // Free the bitmap structure
}
}
I really hope someone can help I am completely baffled I am trying to load the correct type .bmp am sure tis sommething to do with the pointer....