Jump to content
  • Advertisement
Sign in to follow this  
Dean1988

OpenGL PNG Texture - SDL+OpenGL - Line at top of texture?

This topic is 4848 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, I load a .png with an alpha channel through SDL_Image, into a SDL_Surface which then get's converted to a GLuint which get's used as a texture. All of that works fine, even the alpha! However, the problem is that there's a line at the top of the picture, as show here: A friend said it may be the way i'm mapping the texture to the quad...which i doubt but here's my code for the quad.
	glBindTexture(GL_TEXTURE_2D, oglTexture2);

	glBegin(GL_QUADS);
		//Top-left vertex (corner)
		glTexCoord2f(0,1);
		glVertex3f(0.0f, 600-guiBar->Images[0].Dimension.h, 0.0f);
		
		//Bottom-left vertex (corner)
		glTexCoord2f(0,0);
		glVertex3f(0.0f, 600.0f, 0.0f);
		
		//Bottom-right vertex (corner)
		glTexCoord2f(1,0);
		glVertex3f(800.0f, 600.0f, 0.0f);
		
		//Top-right vertex (corner)
		glTexCoord2f(1,1);
		glVertex3f(800.0f, 600-guiBar->Images[0].Dimension.h, 0.0f);
	glEnd();

Does anyone have any ideas? Cheers, Dean

Share this post


Link to post
Share on other sites
Advertisement
Hey! same thing with me...at first I though it was just with the texture I was using...im not sure why its happiening...but if you figure it out could you send me a pm? if you remeber :P

Share this post


Link to post
Share on other sites
It looks to me like they are in the image, but they are so light of white that you can't see them unless you zoom in to about 400x, my advice, In photoshop fill the alpha area with bright green, turn all the nasty edges into the same green, then turn that back into alpha. Should remove all the nasty edges.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dancin_Fool
Could it have anything to do with the texture not being a power of 2, I've heard that causes a lot of issues.


The texture is 800x138, and still produces that line...:(

Quote:
Original post by DerAnged
It looks to me like they are in the image, but they are so light of white that you can't see them unless you zoom in to about 400x, my advice, In photoshop fill the alpha area with bright green, turn all the nasty edges into the same green, then turn that back into alpha. Should remove all the nasty edges.


Tried that too...and yet i still get the very annoying line!

Share this post


Link to post
Share on other sites
Look's like texture wrapping to me.

Try

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);

Share this post


Link to post
Share on other sites
Quote:
Original post by FlowingOoze
Look's like texture wrapping to me.

Try

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);


Is it too weird to say i love you? :P

Cheers mate, your a star!!

Share this post


Link to post
Share on other sites
It's a pretty common artefact when mapping whole-quads, derived from how UVs are mapped onto the texture.

Try pinching the texture-coordinate
(using range (1/WIDTH, 1/HEIGHT) to (1- 1/WIDTH, 1-1/HEIGHT) instead of (0,0) to (1,1).

Allan

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!