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 3 of 3

Thread: couple of questions- nurbs, transparency, etc

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    13

    couple of questions- nurbs, transparency, etc

    I am very new to opengl and I am trying to draw a peacock. I have an raw image of a feather that has white as the background and am trying to convert the white pixels to transparent pixels but am not sure how.
    Code :
    struct RGBA 
    {						// The data on one RGB pixel
        unsigned char red;
        unsigned char green;
        unsigned char blue;
    	unsigned char alpha;
    };
     
    RGBA image1[texHeight][texWidth];				// The image
     
     
     
     
     
    if ( in ) 
    	{
     
            for ( int r = texHeight-1; r >= 0; r-- ) 
    		{
                for ( int c = 0; c < texWidth; c++ ) 
    			{
    				if ( 
    					in.read( reinterpret_cast<char*>(&amp;image[r][c]), sizeof(RGB)) );
                }
    how would you assign this image an alpha value while reading it in?





    also, I have drawn a nurbs surface and was wondering how to texture map it?

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    13

    Re: couple of questions- nurbs, transparency, etc

    please?

  3. #3
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,370

    Re: couple of questions- nurbs, transparency, etc

    Set alpha to zero when you are on the background. Note that a white background is not judicious since the white color is very common is nature. You should set something less natural as background like pink: 0xff00ff or (1.0, 0.0, 1.0).

    Then when you have created your texture with opengl you can use alpha testing or blending to remove the background when rendering.

Posting Permissions

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