Jump to content
  • Advertisement
Sign in to follow this  
MatrixCubed

OpenGL Blending texture edges

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

Hello all, A situation has arisen where I wish to add an effect to my game engine. It's a 2D sprite engine which uses OpenGL as the workhorse. Currently what I'm doing at texture-loading time is: - load PNGs using SDL_Image (IMG_Load) into an SDL_Surface - iterate pixel by pixel through the SDL surface to add alpha=0 to color-keyed pixels, or alpha=255 for opaque pixels - load this into an OpenGL texture as a 32 bit RGBA texture What I want to try doing is giving 50% alpha to pixels which border both opaque and transparent pixels. I figure this will give a smooth look to the game engine, but who knows, it might totally suck, I just want to see what the end result will look like. :) Immediately I thought of performing a 2nd pass in the loading code, check surrounding pixels, and setting alpha that way. But to render textured polys with the desired effect, what renderstates do I need to set? Right now I use these to discard colorkeyed pixels: glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_NOTEQUAL, 0.0f); Do I additionally need to add this to render pixels based on values contained in the alpha channel? glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); Thanks in advance, - m³

Share this post


Link to post
Share on other sites
Advertisement
umm i'm not sure i have understanded what you want to do but...
Tga and PNG format got an option to add a channel
and so they wont show anything in that channel
take a look at nehe lesson 32

hope i helped

mc

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!