openGL screwy edges of textures

Member
Posts: 320
Joined: 2003.06
Post: #1
Quite often I'm seeing weird white lines on the edges of textures.

I'm working on a 2d game and am using openGL. A workaround that I've found that works is to make the texture coordinate 0.999 instead of 1.0. But this is messy.

I'm pretty sure that there are no white lines on the tga files themselves.

Usually the lines take up only a small amount of the edge of the texture - only half or less.

I am using the NeHe tga texture loading code, if that helps.

any ideas?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Make sure you're not making a texture with a border.

Make sure your TEXTURE_WRAP_S and TEXTURE_WRAP_T are set to either GL_REPEAT or GL_CLAMP_TO_EDGE_SGIS.
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #3
You may be talking about a similar problem that I was having. If you are displaying only parts of a larger texture on a poly, you may be getting "spill over" from the neighboring "texels." Shock

I used a similar solution to yours, but it's only a temporary fix.

arekkusu boiled it down and filed a bug report with Apple. Check out the details at this site. Apparently, it will be fixed soon.

If you have time to read the extensive discussion, you can check it out on this thread.

On the other hand, your problem may be more simple as suggested above. Wink

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #4
Quote:Originally posted by aaronsullivan
You [b]may be talking about a similar problem that I was having.

...

arekkusu boiled it down and filed a bug report with Apple. [/b]


No, my bug is about gluOrtho2D producing slightly inexact projection coordinates.

This problem is about texturing coordinates and is completely unrelated.

As OSC says, it is likely due to the texture border mode.
Quote this message in a reply
Member
Posts: 233
Joined: 2003.05
Post: #5
Indeed, if you are talking about displaying the entire texture and/or you have no white anywhere in the texture you are using, it has NOTHING to do with my earlier post or the bug. Grin

"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #6
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

Thanks again, the above code did the trick when placed in the loading part of the code. Funny, I really have no idea what I'm doing and I keep expecting to run into a dead end or something. So far my game's working alright though and I guess thats the main thing. I'll just keep waiting for things to break before I fix them. (with a bit of help from you guys) cheers
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
You (almost) never want GL_CLAMP. GL_CLAMP_TO_EDGE_SGIS is almost always the right mode to use.
Quote this message in a reply
Member
Posts: 177
Joined: 2002.08
Post: #8
What's the difference between GL_CLAMP_TO_EDGE_SGIS and plain GL_CLAMP_TO_EDGE from GL 1.2?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
Nothing AFAIK, but Rage 128s, GeForce2MXs and GeForce4MXs don't support OpenGL 1.2, so technically if you're supporting those cards you should check for the extension and use the extension's constant.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Preventing texture from creating transparent gaps on edges ardowz 3 1,319 Jan 21, 2014 11:28 AM
Last Post: SethWillits
  Create Aquaria-like terrain- texturing edges AndyKorth 3 6,259 Jul 31, 2011 08:13 PM
Last Post: FlamingHairball
  [SOLVED]OpenGL edges of textures mk12 2 4,369 Sep 2, 2010 08:07 PM
Last Post: mk12
  Replacing edges with degenerate quads (for shadow volumes) Coyote 9 7,679 Jan 15, 2010 07:08 PM
Last Post: Coyote
  OpenGL Image Textures mikey 52 24,329 Jun 30, 2009 10:42 AM
Last Post: AnotherJake