🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

is this OK????

Started by
2 comments, last by BlackStorm 23 years, 11 months ago
Well, i know it's ok 'cause it does what supposed, but there's other way to doit?, 'cause for 1 different texture for each face of a cube will be pretty large ...I HATE my english!!
    
int LoadGLTextures()
{
	int Status=FALSE;

	AUX_RGBImageRec *TextureImage[2];

	memset(TextureImage,0,sizeof(void *)*1);

	
	if((TextureImage[0]=LoadBMP("Data/NeHe.bmp")) && (TextureImage[1]=LoadBMP("Data/enya.bmp")))
	{
		Status=TRUE;
		//Create 2 Textures

		glGenTextures(2,&texture[0]);
        //Process the first texture

		glBindTexture(GL_TEXTURE_2D,texture[0]);

		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);
        //Process the second Texture

        glBindTexture(GL_TEXTURE_2D,texture[1]);

        glTexImage2D(GL_TEXTURE_2D,0,3,TextureImage[1]->sizeX,TextureImage[1]->sizeY,0,
			         GL_RGB,GL_UNSIGNED_BYTE,TextureImage[1]->data);

		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	}
	if((TextureImage[0]) && (TextureImage[1]))
	{
		if((TextureImage[0]->data) && (TextureImage[1]->data))
		{
			free(TextureImage[0]->data);
			free(TextureImage[1]->data);
		}
		free(TextureImage[0]);
		free(TextureImage[1]);
	}
	return Status;
}
    
"I stole the colour of night,to get out of your sight.I am the Visionaire, follow me if you dare..." Edited by - BlackStorm on 7/16/00 11:01:04 PM Edited by - BlackStorm on 7/16/00 11:05:13 PM
"I stole the colour of night,to get out of your sight.I am the Visionaire, follow me if you dare..."
Advertisement
Here is a shorter way to do it with for loops.
                int LoadGLTextures()                                        // Load bitmaps and convert to textures{	int Status=FALSE;                                   // Status indicator	AUX_RGBImageRec *TextureImage[6];                   // Create storage space for the textures	memset(TextureImage, 0, sizeof(void *)*1);          // Set the pointer to NULL	// Load the bitmap, check for errors, if bitmap's not found quit	if ((TextureImage[0]=LoadBMP("Data/NeHe.bmp")) &&	    (TextureImage[1]=LoadBMP("Data/NeHe2.bmp")) &&	    (TextureImage[2]=LoadBMP("Data/NeHe3.bmp")) &&	    (TextureImage[3]=LoadBMP("Data/NeHe4.bmp")) &&	    (TextureImage[4]=LoadBMP("Data/NeHe5.bmp")) &&	    (TextureImage[5]=LoadBMP("Data/NeHe6.bmp")))	{		Status=TRUE;                                    // Set the status to true		glGenTextures(6, &texture[0]);                  // Create two textures		for (loop=0; loop<6; loop++)		{		    // Typical texture generation using data from the bitmap		    glBindTexture(GL_TEXTURE_2D, texture[loop]);		    // Generate the texture		    glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);	    	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear filtering	    	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear filtering		}	}	for (loop=0; loop<6; loop++)	{	    if (TextureImage[loop])                                    // If texture exists	    {		    if (TextureImage[loop]->data)                      // If texture image exists		    {			    free(TextureImage[loop]->data);            // Free the texture image memory		    }		    free(TextureImage[loop]);                          // Free the image structure	    }	}	return Status;}                


Hope this helps

Zack

Edited by - zeotron on July 17, 2000 3:21:37 AM
A moment enjoyed is not wasted. -Gamers.com
Yep, it helps , i almost forget the for loop.Thanks

"I stole the colour of night,to get out of your sight.I am the Visionaire, follow me if you dare..."
"I stole the colour of night,to get out of your sight.I am the Visionaire, follow me if you dare..."
You can also do it yourself, by including an image as custom resource into your program.

I''ve got a tutorial Using Custom Resources on my homepage...

This topic is closed to new replies.

Advertisement