int LoadGLTextures()
{
int Status=FALSE;
AUX_RGBImageRec *TextureImage[9];
memset(TextureImage,0,sizeof(void *)*2);
if ((TextureImage[0]=LoadBMP("data/Font.bmp")) && (TextureImage[1]=LoadBMP("data/circ.bmp")) && (TextureImage[2]=LoadBMP("data/particle.bmp")) && (TextureImage[3]=LoadBMP("data/cross.bmp")))
{
Status=TRUE;
glGenTextures(2, &texture[0]);
for (int loop1=0; loop1<4; loop1++)
{
glBindTexture(GL_TEXTURE_2D, texture[loop1]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop1]->sizeX, TextureImage[loop1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop1]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
for (loop1=0; loop1<4; loop1++)
{
if (TextureImage[loop1])
{
if (TextureImage[loop1]->data)
{
free(TextureImage[loop1]->data);
}
free(TextureImage[loop1]);
}
}
}
return Status;
}
weird prob
this is just the nehe code for loading bitmaps, but there is a loop, and the loop works fine with only 3 textures loading but when i put in a 4th one all the textures went all weird in the game. whats wrong with it?
thanks
[edited by - colinisinhere on May 1, 2003 1:10:14 PM]
That code looks ugly...
Anyway, what is the size of texture[] ?
Height Map Editor | Eternal Lands | Fast User Directory
Anyway, what is the size of texture[] ?
Height Map Editor | Eternal Lands | Fast User Directory
very usless code
make a texture class with a loadin function
just load the bmp, then
glGenTextures(&texnum, 1);
glBindTexture(GL_TEXTURE_2D, texnum);;
gluBuild2dMipmaps of glTexImage2d whatever
and bind the tex with glBindTexture(GL_TEXTURE_2D, tex.texnum)
make a texture class with a loadin function
just load the bmp, then
glGenTextures(&texnum, 1);
glBindTexture(GL_TEXTURE_2D, texnum);;
gluBuild2dMipmaps of glTexImage2d whatever
and bind the tex with glBindTexture(GL_TEXTURE_2D, tex.texnum)
i kinda understand what you mean, is this what you mean?
for some reason it says illigal use of expresstion for glGenTextures(1, &texture[textnum]); and glBindTexture(GL_TEXTURE_2D, texture[textnum]);
please please help
class texture{ public: int textnum; void loadBitmap(char *filename, int textnum1);};AUX_RGBImageRec *LoadBMP(char *Filename) { FILE *File=NULL; if (!Filename) { return NULL; } File=fopen(Filename,"r"); if (File) { fclose(File); return auxDIBImageLoad(Filename); } return NULL; }void texture::loadBitmap(char *filename, int textnum1){ AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL textnum = textnum1; // Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit if (TextureImage[0]=LoadBMP(filename)) { glGenTextures(1, &texture[textnum]); // Create The Texture // Typical Texture Generation Using Data From The Bitmap glBindTexture(GL_TEXTURE_2D, texture[textnum]); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); } if (TextureImage[0]) // If Texture Exists { if (TextureImage[0]->data) // If Texture Image Exists { free(TextureImage[0]->data); // Free The Texture Image Memory } free(TextureImage[0]); // Free The Image Structure }}
for some reason it says illigal use of expresstion for glGenTextures(1, &texture[textnum]); and glBindTexture(GL_TEXTURE_2D, texture[textnum]);
please please help
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement