Hi, i have 2 bmp files, player and playerMask:
player have a colored "player" and a white background.
playerMask have the "player" in black and white background,
now i want so that the white background is Transparent.
My code:
This is the code for player and playerMask:
This is the DrawScene code:Code:void player1(){ glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glBlendFunc(GL_DST_COLOR, GL_ZERO); glLoadIdentity(); glColor3f(1.0f, 1.0f, 1.0f); glTranslated(0, 0, -3); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D, playerMask); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2f(0, 0); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.2, 0); glTexCoord2f(1.0f, 0.0f); glVertex2f(0.2, 0.2); glTexCoord2f(1.0f, 1.0f); glVertex2f(0, 0.2); glEnd(); glBlendFunc(GL_ONE, GL_ONE); glLoadIdentity(); glColor3f(1.0f, 1.0f, 1.0f); glTranslated(0, 0, -3); glBindTexture(GL_TEXTURE_2D, player); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2f(0, 0); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.2, 0); glTexCoord2f(1.0f, 0.0f); glVertex2f(0.2, 0.2); glTexCoord2f(1.0f, 1.0f); glVertex2f(0, 0.2); glEnd(); glPopMatrix(); glDisable(GL_TEXTURE_2D); }
I can se the Player bmp on the screen, but nothing else, it have a "player" in it and the white background who should be transparent.Code:void drawScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); player1(); //the player glutSwapBuffers(); }
I hope any of you can se what i have done wrong, or missed in my code.
//ty in advance



LinkBack URL
About LinkBacks


