ich hat ihn selbst geschlossen ^^
aber hier die lösung ist zwar ein wenig kompliziert und geht über umwege ^^
Code:
void DrawAdver(void)
{
glColor4f(color[0],color[1],color[2],color[3]);
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
//glEnable(GL_DEPTH_TEST);
//glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_ALL_ATTRIB_BITS);
//glBindTexture(GL_TEXTURE_2D, texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[5]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(vp[2]-20-128.0,vp[3]-128.0-30.0);
glTexCoord2f(1.0f, 0.0f); glVertex2f(vp[2]-20,vp[3]-128.0-30.0);
glTexCoord2f(1.0f, 1.0f); glVertex2f(vp[2]-20,vp[3]-30.0);
glTexCoord2f(0.0f, 1.0f); glVertex2f(vp[2]-20-128.0,vp[3]-30.0);
glEnd();
glPopAttrib();
glPopMatrix();
}
Code:
AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;
if (!Filename)
return false;
File=fopen(Filename,"r");
if (File)
{
fclose(File);
return auxDIBImageLoad(Filename);
}
return NULL;
}
Code:
int LoadGLTexture(int textureID, char *Filename)
{
int Status=0;
AUX_RGBImageRec *TextureImage[1];
TextureImage[0] = NULL;
//memset(TextureImage,0,sizeof(void *)*1);
if (TextureImage[0]=LoadBMP(Filename))
{
Status=1;
COLORREF Color;
Color = RGB(255, 0, 255); //Setting the color we want transparent
TextureImage[0]->data = CreateRGBA(TextureImage[0]->data, Color, TextureImage[0]->sizeX, TextureImage[0]->sizeY);//I will give you this function later
glGenTextures(1, &texture[textureID]);
glBindTexture(GL_TEXTURE_2D, texture[textureID]);
//glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, TextureImage[0]->data);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGBA, 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);
}
if (TextureImage[0])
{
if (TextureImage[0]->data)
free(TextureImage[0]->data);
free(TextureImage[0]);
}
return Status;
}
Code:
unsigned char* CreateRGBA(unsigned char * oImage,COLORREF ZeroAlpha, int Width, int Height)
{
if(oImage == NULL) return NULL; //Error Checking
int nSize = (Height*Width) * 4;
unsigned char * Image = (unsigned char *) malloc(nSize); //Create Temporary Image Record
if(Image == NULL) return NULL; //Error Checking
for(int n=0,i=0; n < (Height*Width)*3; n+=3,i+=4) {
Image[i] = oImage[n]; //
Image[i+1] = oImage[n+1]; //Copies Origional Information to the Temporary one
Image[i+2] = oImage[n+2]; //
if(ZeroAlpha == -1) { Image[i+3]= (int)255; continue; } //Error Checking
if(Image[i] == GetRValue(ZeroAlpha) && Image[i+1] == GetGValue(ZeroAlpha) && Image[i+2] == GetBValue(ZeroAlpha)) //Checks to see if the values are (255, 0, 255)
Image[i+3] = 0; //If Yes then set the A Value to 0
else Image[i+3] = 255; //Else to full
}
return Image; //Return the new image
}
und hier das Resultat