Jump to content
  • Advertisement
Sign in to follow this  
shoggoth

OpenGL texturing with linear filtering

This topic is 4438 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 all So I'm using some OpenGL Quads to render text to the screen and I have my whole character set in one texture and just pick appropriate texture coordinates to display the right character in the quad. This works mighty fine when I set the texture to use GL_NEAREST filter mode but when I use GL_LINEAR mode, I sometimes get a portion of the adjacent bit of the texture 'bleeding over' at the edges of the quad. Stands to reason really. Is there a way to get around this other than spacing out the characters on my texture? It'd be a shame if I had to do this as it's only a problem with wide characters such as 'M' and 'W' and tall characters of course. I tried using clamp mode but to no avail. I read something about border colours in the Red Book, might this be what I'm after? Any help madly appreciated. Cheers

Share this post


Link to post
Share on other sites
Advertisement
(Bump)
Hi, I am sorry to not have a solution for you. I had the same problem and couldn't work it out (I researched the red and blue books a bit). So eventually I just had the characters in the texture padded by 1 pixel.

If you find a better solution I would appreciate it if you posted it.
Good luck.

Share this post


Link to post
Share on other sites
I don't think there's a way round it myself after going through the books, google etc. Clamping and border colours don't help of course as this is not going outside the 0.0f - 1.0f texture coordinates :/
I'll certainly let you know if I find a better solution.

Share this post


Link to post
Share on other sites
I would think this is more about the accuracy of your texture coordinate calculations than anything else. Clamping and borders apply to the edges of the texture and not to subportions of the texture which you define with texture coordinates. When building texture fonts, I usually take the width of the widest character (more often than not W as you found), add on a pixel or two for spacing, and make that the width and height of every character on the texture (I grid it out). Texture fonts are not typically TrueType (support variable width characters). I haven't encountered any bleeding with this approach. If you send a link to your texture font I will download and run it through my texture font text program and see if any bleeding or overlap occurs with the various filters it supports.

F451

Share this post


Link to post
Share on other sites
There won't be a solution other than spacing out your characters on the texture.

The only way a solution could be implemented would be to say "linear filter the first 10 (say) horizontal pixels, then the next 8,..." - it would simply be too complex and not realistic to implement.

Share this post


Link to post
Share on other sites
I think I will just have to space things out a bit. I've tried reducing the texture coords a bit but it produces similarly unsatisfactory results. The simplest solution is probably the right one :)

hxxp://www.fritx.ukshells.co.uk/image/HUD.png <- there you will find the texture in question. The charsets are at the very bottom of the .png

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!