Results 1 to 7 of 7

Thread: cut off background of image

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2001
    Posts
    16

    cut off background of image

    I'm making a menu and i want that it will be transporent, but i have a problem:
    i use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) - it make it transporent,
    but i see the background of image?

    Can you explane me how to cut off background of image(bmp or tga)?
    (with out glBlendFunc(GL_SRC_ALPHA, GL_ONE) or which make the same effect.)

    dan-leech@mail.ru

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: cut off background of image

    If you want to make it transparent in some places only you have to use alpha test.
    Look fo glEnable(GL_ALPHA_TEST) in your preferred OpenGL help system or search on these forums.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2001
    Posts
    16

    Re: cut off background of image

    sorry but "glAlphaFunc" it doesn't work
    I think that you didn't understand me. I try to explane

    i have a bmp file with picture

    *******************
    *******************
    ********0000*******
    *****00000000******
    *****0000000*******
    *******000*********
    ********0**********
    *******************
    *******************

    * - background(which black or other color)
    0 - other picsels(picture)

    I want to don't see "*" on texture(it will be fully transparent)
    and "0" will be transporent for 70%.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Nice, France
    Posts
    201

    Re: cut off background of image

    You have to specify an alpha channel for the alpha test to work.

    To do this, when you load your texture as a RGB 24bpp bitmap, copy it to a buffer which has a RGBA 32 bpp depth. Copy RGB to RGB and for A put 0 if R=G=B=0 (black) and 1 otherwise. Then create a RGBA texture.
    Then specify a value of say 0.5 for the alphatest's trigger value and draw your textured geometry with alphatest enabled.

    If you want to make the rest of the texture 70% transparent, do as above but when the pixel's color is not black, put 0.3 for the A component instead of 1.
    Then use blending instead of the alphatest (Probably the best blend function for that is glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)).

    Alternatively, you can use a targa bitmap which already has the alpha channel and load it as the RGBA texture.

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2001
    Posts
    16

    Re: cut off background of image

    Can you sent me a simple code with tga load and fully transporent background?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Nice, France
    Posts
    201

    Re: cut off background of image

    I'll try to find something in some of my old code tomorrow.
    Now I'm going to sleep, it's 0.30 here

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2001
    Posts
    16

    Re: cut off background of image

    Thank you!!!!!!!!
    If you find it sent to
    dan-leech@mtu-net.ru

Similar Threads

  1. Replies: 1
    Last Post: 07-09-2017, 07:07 AM
  2. Image Background
    By Leandros in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-20-2010, 01:03 AM
  3. Background image
    By aga2678 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-19-2005, 09:09 AM
  4. background image
    By zukko in forum OpenGL: Windows
    Replies: 1
    Last Post: 06-13-2004, 02:11 PM
  5. How can I put a BMP image in background???
    By Le Bayonnais in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-25-2000, 03:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean