Results 1 to 5 of 5

Thread: glDrawPixel + transparency

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2006
    Location
    Italy
    Posts
    5

    glDrawPixel + transparency

    Hi everybody, I have this problem: I created a music editor in which each figure is rendered using the glDrawPixel of a bitmap representing the figure. Now the bitmap background is white and can cover other figure in the near. I would like to know if there is any way to say openGL to treat the white as a transparent color.ù
    The follwing the code I use to render each music figure:

    glPixelTransferi(GL_UNPACK_ALIGNMENT,4); glRasterPos2i(this->position[0]-10,this->position[1]+10);
    glDrawPixels(BM.bmWidth, BM.bmHeight,GL_RGB, GL_UNSIGNED_BYTE, BM.bmBits);

    Thank you so much for the help.

    Giancarlo

  2. #2
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: glDrawPixel + transparency

    Why not transfering these bitmaps permanently to GPU memory as textures?
    Then you only need to enable alpha test and draw a quad covered with this texture. Transparency in OpenGL is usually done using alpha channel.
    It will be much better that transfering bitmap to GPU every time you need to draw it. From main OpenGL site go to: Coding resources/Sample code & tutorials.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2006
    Location
    Italy
    Posts
    5

    Re: glDrawPixel + transparency

    Hi K, I am agree with you. But ...how. As I understand from your answer I should threat each bitmap as a texture. So each figure should be rendered as a squared textured with my bitmap and then I can manage the alpha channel. Is that right?

    Thank you.
    Giancarlo

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    744

    Re: glDrawPixel + transparency

    yes

  5. #5
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: glDrawPixel + transparency

    Actually you could place all images in one, large texture and just draw rectangles covered with fragments of that texture - this way you can avoid texture switching.

Similar Threads

  1. gldrawpixel for using openMP
    By sagob in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-11-2010, 04:57 PM
  2. glDrawPixel problem
    By AngelT in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-13-2004, 04:40 AM
  3. glDrawPixel problem
    By AngelT in forum OpenGL: Windows
    Replies: 0
    Last Post: 12-07-2004, 08:39 AM
  4. glDrawPixel problem
    By Ashish_Programmer in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-29-2004, 04:38 PM
  5. Lines using glDrawPixel
    By cyclopentane in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-01-2003, 10: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