Jump to content
  • Advertisement
Sign in to follow this  
Tommato

OpenGL GL_CLAMP - what I'm doing wrong?

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

[font=Helvetica][size=2]Hi All[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]I'm using:[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]If I set alpha = 0 for "edge" pixels - all is as expected (left [/font][font=Helvetica][size=2]picture - no texture outside region). However, with alpha = 255 [/font][font=Helvetica][size=2](middle picture) OpenGL still uses/applies some alpha. I can't [/font][font=Helvetica][size=2]figure out where this alpha comes from? No probs with software [/font][font=Helvetica][size=2]render (right picture)[/font]
[font=Helvetica][size=2]
[/font]
[font=Helvetica][size=2][/font][font=Helvetica][size=2][attachment=2531:OpenGL.png]
[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]What I'm doing wrong?[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]Thanks[/font]
[font=Helvetica][size=2][/font][font=Helvetica][size=2]
[/font][font=Helvetica][size=2]Tom[/font]

Share this post


Link to post
Share on other sites
Advertisement
This could be due to the mip-map level being used. The one pixel alpha border becomes interpolated at lower levels giving an alpha value between the 2 pixels closest to the edge.

(Actually I think this would cause the opposite of your case?)

Share this post


Link to post
Share on other sites

[font="Helvetica"] [/font][font="Helvetica"]If I set alpha = 0 for "edge" pixels[/font]

Define "edge pixels". Does your texture have an actual OpenGL texture border, do you set the constant border colour ?

If the answer to these questions is no or I don't know, then GL_CLAMP isn't doing what you think it is doing. Use GL_CLAMP_TO_EDGE in this case.

Oh, and GL_CLAMP is deprecated anyway.

Share this post


Link to post
Share on other sites

Define "edge pixels". Does your texture have an actual OpenGL texture border, do you set the constant border colour ?

If the answer to these questions is no or I don't know, then GL_CLAMP isn't doing what you think it is doing. Use GL_CLAMP_TO_EDGE in this case.

Oh, and GL_CLAMP is deprecated anyway.
Thank you, GL_CLAMP_TO_EDGE does solve ny prob!
If I need no texture outside, then I set "edge" pixels of image (alpha = 0) before call glTexImage2D (with "border" param = 0). Maybe there is a better way to do this?

Thanks
Tom


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!