Jump to content
  • Advertisement
Sign in to follow this  
atraf

i have Question with Lesson 10

This topic is 4775 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

int LoadGLTextures()                                    // Load Bitmaps And Convert To Textures
{
        int Status=FALSE;  
		// Status Indicator
       
        AUX_RGBImageRec *TextureImage[2];               // Create Storage Space For The Texture

        memset(TextureImage,1,sizeof(void *)*2);        // Set The Pointer To NULL

        // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
        if (TextureImage[0]=LoadBMP("Data/Mud.bmp"))
		
        {
                Status=TRUE;                            // Set The Status To TRUE

                glGenTextures(3, &texture[0]);          // Create Three Textures

				// Create Nearest Filtered Texture
				glBindTexture(GL_TEXTURE_2D, texture[0]);
				glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
				glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
				glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

                // Create Linear Filtered Texture
                glBindTexture(GL_TEXTURE_2D, texture[1]);
                glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
                glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
                glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

				// Create MipMapped Texture
				glBindTexture(GL_TEXTURE_2D, texture[2]);
				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[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
        }
        if (TextureImage[0])                            // If Texture Exists
        {
                if (TextureImage[0]->data)              // If Texture Image Exists
                {
                        free(TextureImage[0]->data);    // Free The Texture Image Memory
                }

                free(TextureImage[0]);                  // Free The Image Structure
        }

                                       // Return The Status
          
 return Status;  
 
 

my Question is: HOW I CAN ADD MORE TextureImage (BMP) [Edited by - atraf on August 27, 2005 1:05:14 PM]

Share this post


Link to post
Share on other sites
Advertisement
first, you should wrap that code you have in [ source ] [ /source ] tags.

second, could you rephrase your question, i have no clue what you are asking...

Share this post


Link to post
Share on other sites
perhaps something like this


unsigned int LoadGLTexture(char filename[120]) // Load Bitmaps And Convert To Textures
{

unsigned int texture;
AUX_RGBImageRec *TextureImage=NULL; // Create Storage Space For The Texture

// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage=LoadBMP(filename))

{

glGenTextures(1, &texture); // Create Three Textures


// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture);
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 The Status

return texture;

}




then just use it like this

unsigned int tex1,tex2;

tex1=LoadGLTexture("texture1.bmp");
tex2=LoadGLTexture("texture2.bmp");

and then just call bind like this glBindTexture(GL_TEXTURE_2D, tex1);

and of cause i can not guarante that this code works, but it might be a hint on how to do it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!