Opengl masking problem

This is a discussion on Opengl masking problem within the Game Programming forums, part of the General Programming Boards category; Hi, i have 2 bmp files, player and playerMask: player have a colored "player" and a white background. playerMask have ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    14

    Opengl masking problem

    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:
    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);
    }
    This is the DrawScene code:
    Code:
    void drawScene() {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    	player1();	//the player
    	glutSwapBuffers();
    }
    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.

    I hope any of you can se what i have done wrong, or missed in my code.

    //ty in advance

  2. #2
    Registered User
    Join Date
    Aug 2007
    Posts
    14
    Noone know what the problem is ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multithread pthread with OpenGL
    By parad0x13 in forum C++ Programming
    Replies: 8
    Last Post: 07-24-2008, 03:04 PM
  2. OpenGL Color update problem
    By arifin in forum C++ Programming
    Replies: 0
    Last Post: 07-22-2008, 12:17 AM
  3. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 11:02 AM
  4. OpenGL lighting
    By BabyG in forum Game Programming
    Replies: 3
    Last Post: 08-29-2004, 09:58 AM
  5. So.. what's the difference between DirectX and OpenGL?
    By QuestionC in forum Game Programming
    Replies: 6
    Last Post: 01-19-2002, 05:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21