PDA

View Full Version : JPG TEXTURE LOADING PROBLEM =(



TPManiac2001
05-01-2001, 04:19 AM
Please can anyone help me?
i want to load JPG textures and i cant get this code work ! can anyone give me a code (VC++) to load JPGs?

AUX_RGBImageRec *LoadJPG(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle

if (!Filename) // Make Sure A Filename Was Given
{
return NULL; // If Not Return NULL
}

File=fopen(Filename,"r"); // Check To See If The File Exists

if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}

return NULL; // If Load Failed Return NULL
}

int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator

AUX_RGBImageRec *TextureImage[8]; // Create Storage Space For The Texture

memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL

// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
// textur 1 mipmap
if (TextureImage[0]=LoadJPG("Data/matrix.jpg"))
{
Status=TRUE; // Set The Status To TRUE

glGenTextures(1, &texture[0]); // Create The Texture

// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_NEAREST);

}

Humus
05-01-2001, 05:17 AM
Uhm ... I really don't think the auxDIBImageLoad function accept jpegs. I haven't used it myself but I think it's bmp/dib function only.

TPManiac2001
05-01-2001, 05:59 AM
can anyone tell me how to use the http://www.ijg.org/ libary to load a jpg texture? (with sample c code)