Load a texture.
- Do a loop on each pixel.
- If pink, change the color to the transparent color (like in gifs)
- Otherwise leave it the way it is.

I believe that should do the trick, but now.... how to do that?
Actually, your are right; that is the way most people do (including my self) when you wants to use transparency (but avoiding the exra work to use a mask black/white texture) defining a pre-accorded color.

You have to load the whole texture data from file into a block memory and then process every pixel, if the RGB pixel color is 255,0,255 (or any other color you want) then put the alpha component equal to 0, if the pixel IS NOT pinky then put alpha = 1.

How to load a bitmap and inspect/edit every pixel?,

The easy way is to use standars BMP file (you say you preffer to use paint.exe program) in 32bit color format, so for every pixel you wil have 4 bytes (RGBA), tell to your artis to use full 255,0,255 color for define transparent areas in the sprite.

Then in delphi use a temporal TBITMAP for load your bmp file, then allocate a block memory using getmem(pixels, bitmap.width*bitmap.height*4) and then extract there all pixels from the bitmap using Bitmap.scanline() function. Every 4 bytes starting from the pixel pointer are the RGBA pixel color, procces the whole block memory.

*Hint: There is a delphi units out there called GraphicsEX which expand the TIMAGE component to load almost every picture file format (jpg, tga, tif, psd, pcx.. etc) using Timage.picture.loadfromfile() then you can use TBITMAP.canvas.draw(0,0,timage.picture) for convert what ever picture you loaded (in whatever bit color format) into your 24bit color bitmap.

Once you have your picture in memory with the pinky color with alpha=0 then build the texture fragment and enable the apropiate rendering parameters using the API you choose, opengl or directx.

I have implemented this technique full working but using directx, for opengl i found this example:

http://www.codesampler.com/oglsrc/og...#ogl_color_key

I have checked and seem the opengl way it is much more easier than in directx...


define the texture like this:

Code:
        glGenTextures( 1, &g_textureID );
        glBindTexture( GL_TEXTURE_2D, g_textureID );
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        // Don't forget to use GL_RGBA for our new image data... we support Alpha transparency now!
        glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, pImage_RGB->sizeX, pImage_RGB->sizeY, 0,
                      GL_RGBA, GL_UNSIGNED_BYTE, pImage_RGBA );

Then every time you are going to render the rectangles with transperent pixels do this:


Code:
       glEnable( GL_BLEND );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
Again, i have not tried that technique in opengl, but in directx, let me know if it work in your opengl test.


* This technique also works in 16 bit color mode, but it takes a litle more work to convert full 32 bit color to 16bit color, this is only necesary if your target machine specs are low.


good luck.

tp.