Skip to main content
gamedev.net
🔒 Locked

Multiple Textures

Started by Sade Jun 25, 2004 at 11:54 PM 8 replies 600+ views
Original Post
Sade
Sade
Hiya, i'm a little new to OpenGL and i've got a problem. I'm able to apply a single texture and all but i get an error when i try more than one ("Debug Assertioan Failed!"). This seems to be happening when i loop through the textures applying them and freeing them up, but i'm not sure whats wrong. Thanx in advance...
NLDEV
NLDEV
Can you show some code?
Sade
Sade
int LoadGLTextures()
{
bool Status=FALSE;

AUX_RGBImageRec *Image[2];
memset(Image,0,sizeof(void *)*3);

if((Image[0]=LoadBMP("Text1.bmp")) && (Image[1]=LoadBMP("Text2.bmp")) && (Image[2]=LoadBMP("Text3.bmp")))
{
Status = TRUE;

glGenTextures(3, &texture[0]);

for(num=0; num < 3; num++)
{
glBindTexture(GL_TEXTURE_2D, texture[num]); //select which texture to fill

glTexImage2D(GL_TEXTURE_2D, 0, 3, Image[num]->sizeX, Image[num]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, Image[num]->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //linear filtering
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
}

for(num=0; num < 3; num++)
{
if(Image[num])
{
if(Image[num]->data)
{
free(Image[num]->data);
}

free(Image[num]);
}
}

return Status;
}
Sade
Sade
Thats freeing the image structure (?)
Kuladus
Kuladus
[src]
AUX_RGBImageRec *Image[2];
...
...(Image[2]=LoadBMP("Text3.bmp"))...
[/src]

I think you need to touch up on your arrays in C. You've only specified an array of length 2.
AUX_RGBImageRec *Image[3];
Sade
Sade
Wouldnt there be 3 since it starts from zero ?
falkone
falkone
Quote:
Original post by Sade
Wouldnt there be 3 since it starts from zero ?


It starts from 0 when addressing, but you only asked for two...
Disclaimer: "I am in no way qualified to present advice n any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)" o
Sade
Sade
I see, it works now...thanx for the help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.