Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411581 Posts in 69386 Topics- by 58445 Members - Latest Member: Mansreign

May 05, 2024, 08:49:00 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)openGL leaky textures
Pages: [1]
Print
Author Topic: openGL leaky textures  (Read 1739 times)
dspencer
Level 3
***


View Profile WWW
« on: August 09, 2009, 05:30:48 PM »

Hello everyone,

I'm not sure what to call this phenomenon - if I knew, I could probably just have googled for the answer. So, sorry about that!

I'm adding actual graphics to my project, and I'm having some trouble with my textures (in openGL via C++). Right now I've got two tiles - dirt, underground, and the top layer, with some grass on top. I'm finding that sometimes, the tile with grass (which is 32x32 pixels) will have a line of green at the very bottom, just like it does on the top. However, I'm not sure why this is happening... It only happens for some frames, so I think it might be a product of the scrolling (it never happens when the scrolling comes to rest). Does anyone have any ideas? I've tried changing the texture wrapping mode from loop to clamp, but it didnt help.



Thanks!
« Last Edit: August 09, 2009, 05:35:30 PM by dspencer » Logged

Ivan
Owl Country
Level 10
*


alright, let's see what we can see


View Profile
« Reply #1 on: August 09, 2009, 05:35:52 PM »

See if it's the same issue as this:

http://forums.tigsource.com/index.php?topic=4205.msg131938
Logged

http://polycode.org/ - Free, cross-platform, open-source engine.
dspencer
Level 3
***


View Profile WWW
« Reply #2 on: August 09, 2009, 05:53:09 PM »

At first glance, it appears so; however, none of the solutions presented on that thread work for mine. Thinking back, though, maybe the problem is in how I load the texture to opengl... Just kidding, tried another method and it has the same problem.
« Last Edit: August 09, 2009, 06:12:40 PM by dspencer » Logged

Aquin
Level 10
*****


Aquin is over here.


View Profile WWW
« Reply #3 on: August 09, 2009, 06:21:19 PM »

It sounds like the line of green is coming from the other side of the texture.  "But wait," you say, "I turned off clamping!?"

It doesn't matter.  When you do your mip-mapping, OpenGL will do a wrap-around to calculate how it looks.  Turn on NEAREST filter for the textures and the green line will go away.
Logged

I'd write a devlog about my current game, but I'm too busy making it.
dspencer
Level 3
***


View Profile WWW
« Reply #4 on: August 09, 2009, 06:27:13 PM »

I know - that's what I thought, too. But, I tried that (it was suggested in that other thread) and the green lines are still coming up). I tried changing the colors, so I'm sure the texture is getting wrapped around... but I just don't know why.
Logged

Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #5 on: August 09, 2009, 06:45:03 PM »

SFML works around this issue by mapping to a half texel away from the border.
(also changing texture WRAP to CLAMP)

Like:
baseTexCoords = (
  0.5/texturePixelWidth,
  0.5/texturePixelHeight,
  (texturePixelWidth-0.5)/texturePixelWidth,
  (texturePixelHeight-0.5)/texturePixelHeight
)

See if it works for you.
Logged

Working on HeliBrawl
dspencer
Level 3
***


View Profile WWW
« Reply #6 on: August 09, 2009, 06:59:54 PM »

That works, and looks fine. I guess I misread that solution - I tried something similar which didnt work. I'd still like to find a solution that doesn't rely on me remembering to manually change the texture coords... but still, thank you!
Logged

Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #7 on: August 09, 2009, 08:37:18 PM »

Call an intermediate calculateTexCoords(myUsualCoords) to centralize the behaviour, easy cheesy Smiley
Logged

Working on HeliBrawl
Zaphos
Guest
« Reply #8 on: August 10, 2009, 12:44:05 AM »

I thought that was what GL_CLAMP_TO_EDGE was supposed to do?
Logged
dspencer
Level 3
***


View Profile WWW
« Reply #9 on: August 10, 2009, 07:55:13 PM »

Found the problem - never set the filter *before* generating mipmaps. Fixed, thread locked, thanks so much for all of your help Smiley.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic