Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Masking Problem, any one could help, Urgent!!!

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2005
    Location
    Malaysia
    Posts
    3

    Masking Problem, any one could help, Urgent!!!

    hi,

    anyone could help,pls?I m stacked on this problem a few weeks.

    I m doing a Renju chess board, but after picking the stone dose not appear properly, i think is the alpha part problem... the coding pls refer to

    http://www.gamedev.net/community/for...opic_id=309393

    thank you thank you!!!

  2. #2
    Intern Contributor
    Join Date
    Dec 2004
    Posts
    71

    Re: Masking Problem, any one could help, Urgent!!!

    I'm not an expert on display lists (I never use them) but in the function 'build_piece' you call glBindTexture before glNewList so the texture call won't be compiled into the display list.

    It's not clear exactly what's wrong with your pieces but from your description I think you should create a 32-bit texture with pure white in the RGB channels and a circle mask in the alpha channel.

    You should then enable alpha blending and call glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)

    /A.B.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2005
    Location
    Malaysia
    Posts
    3

    Re: Masking Problem, any one could help, Urgent!!!

    hi,

    you are properly right, after i change the glBindTexture(GL_TEXTURE_2D, textures[9]);after call list, the piece appeared. But where should i add
    "enable alpha blending and call glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)"

  4. #4
    Intern Contributor
    Join Date
    Dec 2004
    Posts
    71

    Re: Masking Problem, any one could help, Urgent!!!

    I suggest you do it in 'draw_pieces' after glEnable(GL_TEXTURE_2D). To enable alpha blending use glEnable(GL_BLEND). As I said earlier, you need a 32-bit texture with the circle in the alpha channel for this to work properly.

    You might want to reset the OpenGL state at the end of the function, either with glPushAttrib/glPopAttrib or manually resetting the relevant states (i.e. glDisable(GL_BLEND) and so forth).

    /A.B.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •