Advertisement Jump to content


This topic is now archived and is closed to further replies.


Nehe's lesson 8

This topic is 6182 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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.


Share this post

Link to post
Share on other sites
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.


Share this post

Link to post
Share on other sites
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/glass3.bmp", //Filenames For Our Images -- NEW!


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]);
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,

//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

Share this post

Link to post
Share on other sites
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


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

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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!