Advertisement

Tutorial 8 (blending)

Started by February 07, 2006 01:06 PM
13 comments, last by eSCHEn 18 years, 7 months ago
does the paint program you use support 32bit bmps? (not sure if the Aux funcs support 32bit). make sure you can load the file back into a paint program a view the alpha channel....

Yup i was right, bmp's cant use alpha, so here is a little hack i wrote (its not bugtested or anything, so you might have to rewrite some things), it replaces the for loop in witch you have your glTexImage2D call.


unsigned int imgsize=TextureImage[0]->sizeX*TextureImage[0]->sizeY*4;unsigned char imageData[imgsize];int pixels=TextureImage[0]->sizeX*TextureImage[0]->sizeY;// Typical Texture Generation Using Data From The Bitmapfor(int ctr = 0; ctr <= 5; ctr++){   //build the alpha map from the color green   while(i < pixels)   {     imageData=TextureImage[ctr]->data;     imageData[i+1]=TextureImage[ctr]->data[i+1];     imageData[i+2]=TextureImage[ctr]->data[i+2];     if((imageData==0) && (imageData[i+1]==255) && (imageData[i+2]==0))     imageData[i+3]=0;     else imageData[i+3]=255;     i+=4;   }glBindTexture(GL_TEXTURE_2D, texture[ctr]);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TextureImage[ctr]->sizeX, TextureImage[ctr]->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);}
Advertisement
hi,

you can use an other format such as png too,
and load this with the correct alpha value...

and another note:
I see you use many different textures only for your mario,
it's better to use one texture with all images of your mario in
in it and use the texture coordinates to select different portions
of your image, that will save performance...

Bye

Marc
So using one larger file with multiple images in it, and binding different parts of the image to the polygons is faster than using multiple smaller files? I think I'll start doing that instead then.
To a point this is correct but old graphics cards will have trouble loading images bigger than 256 x 256 so you might want to make that your maximum size if you're targetting older hardware. Larger images are no problem for more modern cards though. Try looking at Delphi3D's hardware info section and you will be able to find the maximum supported texture size for various card and driver combinations.
--
Cheers,
Darren Clark

This topic is closed to new replies.

Advertisement