t3jem
09-08-2005, 05:38 PM
Hi,
I'm trying to create a custom made cursor in one of my programs and I want the black pixels around the cursor to be transparent. I am using glut for my graphics system and I don't want to use the blending function "glBlendFunc(GL_SRC_ALPHA, GL_ONE)" because it doesn't quite get the effect i want.
What I am really looking for is a loading function that will add an alpha value to the loaded image depending on what color the pixel is. The folowing is the current code I am using to load my images.
void text(UINT textureArray[], LPSTR strFileName, int ID)
{
if(!strFileName) return;
AUX_RGBImageRec *pBitMap = auxDIBImageLoad(strFileName);
if(pBitMap == NULL) exit(0);
glGenTextures(1, &textureArray[ID]);
glBindTexture(GL_TEXTURE_2D, textureArray[ID]);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitMap->sizeX, pBitMap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitMap->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
if (pBitMap)
{
if (pBitMap->data)
{
free(pBitMap->data);
}
free(pBitMap);
}
}P.S. I don't use TGA files 1. because I can't make them and 2. because I have lost my loader to load TGA's
I'm trying to create a custom made cursor in one of my programs and I want the black pixels around the cursor to be transparent. I am using glut for my graphics system and I don't want to use the blending function "glBlendFunc(GL_SRC_ALPHA, GL_ONE)" because it doesn't quite get the effect i want.
What I am really looking for is a loading function that will add an alpha value to the loaded image depending on what color the pixel is. The folowing is the current code I am using to load my images.
void text(UINT textureArray[], LPSTR strFileName, int ID)
{
if(!strFileName) return;
AUX_RGBImageRec *pBitMap = auxDIBImageLoad(strFileName);
if(pBitMap == NULL) exit(0);
glGenTextures(1, &textureArray[ID]);
glBindTexture(GL_TEXTURE_2D, textureArray[ID]);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitMap->sizeX, pBitMap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitMap->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
if (pBitMap)
{
if (pBitMap->data)
{
free(pBitMap->data);
}
free(pBitMap);
}
}P.S. I don't use TGA files 1. because I can't make them and 2. because I have lost my loader to load TGA's