PDA

View Full Version : couple of questions- nurbs, transparency, etc



popapez
05-04-2009, 11:34 AM
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.


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?

popapez
05-05-2009, 11:04 AM
please? :(

dletozeun
05-05-2009, 02:15 PM
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.