Jump to content

  • Log In with Google      Sign In   
  • Create Account

Lesson 09 - Transparent color?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Gorkamorka   Members   -  Reputation: 100

Like
0Likes
Like

Posted 24 June 2010 - 12:59 AM

I'm looking at lesson 9 (Moving Bitmaps In 3D Space, http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=09) and I can't figure out what part selects the color that is made transparent.

Basically, what the example program does is load a bmp-file and remove all the black color (#000000) in it, replacing it with transparent color. What I want to do is to specify another color to be replaced, for example #FFFF00.

Quote:
/* Load in the texture */
if ( !LoadGLTextures( ) )
return FALSE;

/* Enable Texture Mapping */
glEnable( GL_TEXTURE_2D );

/* Enable smooth shading */
glShadeModel( GL_SMOOTH );

/* Set the background black */
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );

/* Depth buffer setup */
glClearDepth( 1.0f );

/* Really Nice Perspective Calculations */
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );

/* Set The Blending Function For Translucency */
glBlendFunc( GL_SRC_ALPHA, GL_ONE );

/* Enable Blending */
glEnable( GL_BLEND );


Sponsor:

#2 lc_overlord   Members   -  Reputation: 435

Like
0Likes
Like

Posted 24 June 2010 - 02:14 AM

it's the last two commands, they make it so that anything that is drawn gets added to the screen instead of replacing whats on the screen, thus giving the appearance of transparency, but it's really not.

It's harder to take a specific color and make it transparent.
But what you can do is to have a specific alpha channel that takes care of the transparencies in a much better way.
More about that is in lessons 8, 24, 32 and 33.

#3 Gorkamorka   Members   -  Reputation: 100

Like
0Likes
Like

Posted 24 June 2010 - 10:07 AM

Yep, the three main solutions seem to be using black backgrounds or painting your own alpha layer onto TGA's or looping through the texture pixel by pixel.

I found this example app, http://www.codehead.co.uk/glsandbox.html , which helped out a lot.

#4 lc_overlord   Members   -  Reputation: 435

Like
0Likes
Like

Posted 25 June 2010 - 01:13 AM

well there is a fourth, but it involves using shaders to set the alpha or just discard the pixel.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS