Nehe's lesson 8

Started by
5 comments, last by Waldoo 22 years, 1 month ago
How do you load different pictures on each side of cube in Nehe''s lesson 8 ? The reason I ask that because nehe wrote lenthy transparency and loadtexures code in it. I dont know where good place to add multiple textures in it. Waldoo
Advertisement
make an array of unsigned ints to serve as your texture IDs. Then, use the loading code to load each of your individual images and bind them to their respective sides.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

[twitter]warrenm[/twitter]

Could you please post code example here. I do understand what you are saying but I am newbie in VC++ and OpenGL. I hope you will be willing to post code here.

Waldoo
I''d be more than willing to. I''ll post it before tomorrow...probably in a few hours in fact.

Hang loose,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

[twitter]warrenm[/twitter]

Great I would like to see your work

I made array on texture load for 16 sides out of 32. I have some work left to go but I think there got to be a way to compress it. I probably need to use variable as array on texture load. If it will work. How do you generate array in variable for texture load and filename? I know its easy, I am newbie in VC++ and I dont know its rules. I ve used Basic and Visual Basic for many years.

Waldoo
I am greatly sorry that I don't have a complete solution. However, this is what I got. I just can't seem to get it to bind the individual textures. The idea is there, though.

      GLuint	texture[6];			// Storage For 6 Images -- UPDATED! (Note, We'll Only Use One Filter)char *texname[6] = {"Data/glass.bmp",                     "Data/glass2.bmp", 		    "Data/glass3.bmp", //Filenames For Our Images   -- NEW!                    "Data/glass4.bmp",                     "Data/glass5.bmp", 		    "Data/glass6.bmp"};   

This will go in your initialization section, and replace the original line that declares your textures.
  int LoadGLTextures()									// Load Bitmaps And Convert To Textures{	int Status=FALSE;									// Status Indicator	AUX_RGBImageRec *TextureImage;					// Create Storage Space For The Texture	for(int numtex = 0; numtex < 6; numtex++)        //Loop Through All Our Textures To Load Them -- NEW!	{		glGenTextures(1, &texture[numtex]);					// Create A Texture Slot			//memset(TextureImage,0,sizeof(void *)*1);           	// Set The Pointer To NULL		TextureImage = NULL;		// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit		if (TextureImage=LoadBMP(texname[numtex]))		{			Status=TRUE;									// Set The Status To TRUE			// Create MipMapped Texture			glBindTexture(GL_TEXTURE_2D, texture[numtex]);			glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);			glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);			gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage->sizeX, TextureImage->sizeY, GL_RGB,                                          GL_UNSIGNED_BYTE, TextureImage->data);		}		if (TextureImage)								// If Texture Exists		{			if (TextureImage->data)						// If Texture Image Exists			{				free(TextureImage->data);				// Free The Texture Image Memory			}				free(TextureImage);							// Free The Image Structure		}	}	return Status;										// Return The Status}  

I think this is the problem area. However, I have no clue as to why it doesn't work.

  		glBindTexture(GL_TEXTURE_2D, texture[1]);        //Bind Our Next Texture To This Side -- NEW!      


When using the different textures, place a line like this before you make your respective calls to glVertex3f(). Replace the 1 with the number of the texture (0-5) that you'd like to use.

Hope this helps a bit,
ZE.


//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

EDITED for formatting
EDITED because the forums are screwing with my head...

Edited by - zealouselixir on February 18, 2002 2:23:31 PM

[twitter]warrenm[/twitter]

I found what the problem you had. TextureImage need array too before it may enter into data (memory)

To load texture with array:
if (TextureImage[newtexB]=LoadBMP("x1.bmp")) //put this line in "int LoadGLTextures()" paragraph

One more question how do you generate array in filename? like this x[array].bmp ?

Thank for very much for the code

waldoo

Edited by - Waldoo on February 18, 2002 3:17:11 PM

Edited by - Waldoo on February 18, 2002 4:00:17 PM

This topic is closed to new replies.

Advertisement