Jump to content
  • Advertisement

Archived

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

monkeyman

OpenGL How to do transparent textures in OpenGL?

This topic is 6616 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

I''ve got the alpha values set in my texture..I''ve got the code that enables the alpha test when using a transparent texture..I don''t need to do any blending, I just need to see through certain parts of the texture..I''ve manually set the alpha values in the texture to 1''s and 0''s, so that''s ready to go..I found a good tutorial on NeHe''s site but it illustrates a double-pass system rather than using the alpha channel..I''m sure it''s something specific that I need to set with OpenGL before I can see the results, but I don''t know what...any suggestions? "Like all good things, it starts with a monkey.."

Share this post


Link to post
Share on other sites
Advertisement
Hi there,

This is the code i use to do this

    
void __fastcall TEngine::Render()
{
//render facelists

glDisable(GL_BLEND);

RenderFaceList(opaque_faces);

if(blended_faces) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(GL_FALSE);

RenderFaceList(blended_faces);

//re-enable depth buffer write

//before clear or it wont be cleared

glDepthMask(GL_TRUE);
}

//delete facelists

DeleteFaceList(opaque_faces);
opaque_faces = NULL;
cur_opaque = NULL;
DeleteFaceList(blended_faces);
blended_faces = NULL;
cur_blended = NULL;
}


the faces are added to 2 linked lists one opaque one transparent
render the opaque first set the depth buffer to read only then
render the transparent.

Hope this helps.

Bye

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!