Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

robert_s

Alpha ! how to........

This topic is 6084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

HI! this is my bit of terrain! and this is my main cockpit panel! Now I am trying to get rid of the white colour from the panel image! I know that I should use Alpha blending which I used but it works in the other way round now!! ie. white colour still stays solid but the areas which display the panel are transparent!! How do I do that it will ignore completely the white background colour (ie. white not visible at all) and the panel will be completely solid (visible) ie. not transprent at all clearly visible! this is what I wrote: glEnable(GL_BLEND); // Enable Blending glBlendFunc(GL_SRC_ALPHA, GL_ONE); // Select The Type Of Blending glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPushMatrix(); // Store The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix gluOrtho2D(0, winWidth,0,winHeight); // Set Up An Ortho Screen glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glPushMatrix(); // Store The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix glEnable(GL_TEXTURE_2D); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.9f); //display map HUD glBindTexture(GL_TEXTURE_2D, cockpitPanel); //draw the panel at the bottom of the window glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2d( 0.0, 0.0); // Bottom Left Of The Texture and Quad glTexCoord2f(1.0f, 0.0f); glVertex2d( winWidth, 0.0); // Bottom Right Of The Texture and Quad glTexCoord2f(1.0f, 1.0f); glVertex2d( winWidth, winHeight); // Top Right Of The Texture and Quad glTexCoord2f(0.0f, 1.0f); glVertex2d( 0.0, winHeight); // Top Left Of The Texture and Quad glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); ...........etc.. thanks for your time!! PS: please see if the order I have nested those alpha functions are correct!? ie. glAlphaFunc and glBlendFunc. Edited by - robert_s on November 17, 2001 1:47:52 PM Edited by - robert_s on November 17, 2001 1:50:25 PM Edited by - robert_s on November 17, 2001 1:53:13 PM

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
This is wrong then : glBlendFunc(GL_SRC_ALPHA, GL_ONE);

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you want to use colorkey instead of alpha blending unless you actually add an alpha channel to your pic.

Share this post


Link to post
Share on other sites
DOnt know how to help you. It looks like a old game i ahve called F-15.... are you copying/recreating it? or just making a new one that just happens to look exactly the same?

Share this post


Link to post
Share on other sites
----------------------------------------------------------
Anonymous Poster
This is wrong then : glBlendFunc(GL_SRC_ALPHA, GL_ONE);
you want to use colorkey instead of alpha blending unless you actually add an alpha channel to your pic.
------------------------------------------------------------

ok! thx! but whats actually colorkey? could you exaplin please?

--------------------------------------------------------------
DarkHunter
DOnt know how to help you. It looks like a old game i ahve called F-15.... are you copying/recreating it? or just making a new one that just happens to look exactly the same?
----------------------------------------------------------------

Sorry DarkHunter but I don't even know what game do you really mean! I do not copy anything! this is just a plain chunk of a terrain covered with textures which even hasn't got normals calculated yet and a simple skybox with texs too. so I don't really understand what's wrong with it? if you know where i could get some source code for that game you mentioned I'll be more than pleased to know the link from u! haha!!
About textures: you're right! the panel was taken from a game but not the one you mentioned!! sky is just a real picture! thats all!! the terrain texture is just one 128x128 texture created in about 5 min on Photoshop! thats it! so, whole secret revealed!! haha!!!
Obviously I am not going to create panel and sky for this engine on my own as I don't have time for this!! My point is to understand the design and learn game programming techniques but not wasting my time on creating textures which are not relevent for me at this stage!! When I completely finish the main design I'll then concentrate on texs but not now!!!
Anyway this is not going to be a commercial software that you can buy!! this is just for my fun!
The panel I did not draw "with a pencil and I am not going to" . I am sure that anyone out there who wants to have a nice looking panel does a similar thing ie. converts a real image on photoshop or takes from some other sources and slightly converts it on photoshop!!thats it!

ok! sorry I got a bit annoyed!
Anyway I am still looking for someone who can help me!
Anyone?!

Edited by - robert_s on November 17, 2001 4:37:28 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Does your texture have a alpha channel? I am betting it doesn''t.

Share this post


Link to post
Share on other sites
Yes !! you''re right it doesn''t have an alpha channel!! How do I add it? is is a lot of work? please explain!
(Thanks for reply! )

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It isn''t allot of work, as long as you have a paint program that supports alpha (Paintshop pro or photoshop) and you save the image as either TGA or PNG formats, since those allow alpha channel. Now, once you save them, you then read them back in, and set up the texture format to support alpha. I know a few of Nehe''s tutorials show this.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Oh, forgot to say, you can also save RAW if you wish... then your laoding code, have it do:

glTexImage2D(GL_TEXTURE_2D,0,c_type,width,height,0,c_type,GL_UNSIGNED_BYTE,raw_bitmap);

c_type= GL_RGBA for a texture that has Alpha, GL_RGB for one that don''t.

You can also create your own alpha channel if you wish.

Share this post


Link to post
Share on other sites
Gosh! that means I have to implement an algorith to load TGAs as my one reads only BMPs! so it won''t work!!
Ok once I''ve done that do I just use same code as above? or needs something more??

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!