Advertisement

Loading Multiple Textures!!!!!!

Started by November 30, 2001 02:51 PM
14 comments, last by TheSyan 23 years, 2 months ago
Thnx 4 that, but it still doesn''t work... The original code (changed by u) now reads...
  AUX_RGBImageRec *Image=NULL, *Image1=NULL;Image = auxDIBImageLoad("D:/My Documents/SIMON/PROGRAMMING/C++/Textures/Brick.bmp");	glGenTextures(2,&Textures[0]);	glBindTexture(GL_TEXTURE_2D, Textures[0]);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	glTexImage2D(GL_TEXTURE_2D,0,3,Image->sizeX, Image->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE, Image->data);	if (Image)	{				if (Image->data)				{					free(Image->data);				}			free(Image);	}		Image1 = auxDIBImageLoad("D:/My Documents/SIMON/PROGRAMMING/C++/Textures/BackGround.bmp");	glBindTexture(GL_TEXTURE_2D, Textures[1]);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	glTexImage2D(GL_TEXTURE_2D,0,3,Image1->sizeX, Image1->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE, Image1->data);if (Image1)	{			if (Image1->data)			{					free(Image1->data);			}		free(Image1);	}[\source]  
hehe funny thing, i went over to NeHe
heres a snipet from Lesson 17

glGenTextures(2, &texture[0]); // Create Two Texture

"Another important line to double check. I can''t begin to tell you how many emails I''ve received from people asking "why am I only seeing one texture, or why are my textures all white!?!". Usually this line is the problem. If you were to replace the 2 with a 1, only one texture would be created and the second texture would appear all white. If you replaced the 2 with a 3 you''re program may crash!
"
Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.
Advertisement
this line:
Image1 = auxDIBImageLoad("D:/My Documents/SIMON/PROGRAMMING/C++/Textures/BackGround.bmp");
goes before:
glGenTextures(2,&Textures[0]);
this line:
Image1 = auxDIBImageLoad("D:/My Documents/SIMON/PROGRAMMING/C++/Textures/BackGround.bmp");
goes before:
glGenTextures(2,&Textures[0]);

  AUX_RGBImageRec *Image=NULL, *Image1=NULL;Image = auxDIBImageLoad("D:/My Documents/SIMON/PROGRAMMING/C++/Textures/Brick.bmp");Image1 = auxDIBImageLoad("D:/My Documents/SIMON/PROGRAMMING/C++/Textures/BackGround.bmp");		glGenTextures(2,&Textures[0]);	glBindTexture(GL_TEXTURE_2D, Textures[0]);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	glTexImage2D(GL_TEXTURE_2D,0,3,Image->sizeX, Image->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE, Image->data);	if (Image)	{				if (Image->data)				{					free(Image->data);				}			free(Image);	}		glBindTexture(GL_TEXTURE_2D, Textures[1]);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	glTexImage2D(GL_TEXTURE_2D,0,3,Image1->sizeX, Image1->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE, Image1->data);if (Image1)	{			if (Image1->data)			{					free(Image1->data);			}		free(Image1);	}  

Edited by - Load Runner on November 30, 2001 4:59:33 PM

Edited by - Load Runner on November 30, 2001 5:00:30 PM

Edited by - Load Runner on November 30, 2001 5:03:24 PM
Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.
Afraid that doesn''t work either! I''ve had this problem with 3 different re-writes of the texture code 4 my program... Thanks all 4 any help... Sy
...okay I will replace my whole code without error I hope...at home It works!!

GLuint name[2];
AUX_RGBImageRec *texture[2];

glGenTextures(2,name);
texture[0]=auxDIBImageLoad("blablabla.bmp");
texture[1]=auxDIBImageLoad("xxxx.bmp");


for (int j=0;j<=1;j++) {
glBindTexture(GL_TEXTURE_2D,name[j]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, 3, texture[j]->sizeX, texture[j]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, texture[j]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
}

Edited by - Major on November 30, 2001 5:20:36 PM

This topic is closed to new replies.

Advertisement