• Advertisement
Sign in to follow this  

Weird Graphics Bug

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

Hello, I ran my game and a tile is not what it should be. I checked to see if I was using the right file, and I am, and I re-saved the file but it does not seem to work. Does anybody have any idea why this is happening?

 

Original Tile: [attachment=16747:Origonal.PNG]

 

Bugged Tile(in-game): [attachment=16746:weird bug.PNG]

 

Thank you for any help.

Edited by Crusable

Share this post


Link to post
Share on other sites
Advertisement

You're going to need to help us help you, and be more exacting in your description of the problem. What is loading the image, what format is the image, what is being used to draw the image, and what is using whatever is being used to draw the image as a tile. For all we know you could be using HTML and making a webpage.

Edited by radioteeth

Share this post


Link to post
Share on other sites

I am using Gimp to make the images and they are all PNG files. This image is part of a sheet. I am using SFML and C++. The object using the image is a sf::VertexArray of type sf::Quads with 4 elements. The Image itself is a sf::Texture. This specific texture is part of an animated object and the first image works properly as well as all the others on the sheet. 

 

here is the code for mapping the texture choords:

	m_sfObjBox[0].texCoords = sf::Vector2f(m_fCurrentFrame * m_sfSize.x, m_fCurrentFrame * m_sfSize.y);
	m_sfObjBox[1].texCoords = sf::Vector2f((m_fCurrentFrame * m_sfSize.x) + m_sfSize.x, m_fCurrentFrame * m_sfSize.y);
	m_sfObjBox[2].texCoords = sf::Vector2f((m_fCurrentFrame * m_sfSize.x) + m_sfSize.x, (m_fCurrentFrame * m_sfSize.y) + m_sfSize.y);
	m_sfObjBox[3].texCoords = sf::Vector2f(m_fCurrentFrame * m_sfSize.x, (m_fCurrentFrame * m_sfSize.y) + m_sfSize.y);

m_fCurrentFrame is either 0 or 1 because there is only two frames in this animation. m_sfSize is a sf::Vector2f with both x and y being 32. m_sfObjBox is the sf::VertexArray.

 

Edit: I did not see sik_the_hedghog's post and I just looked at it. I see my error.

Edited by Crusable

Share this post


Link to post
Share on other sites

As others have said this looks like uv coordinates are wrong. You want to map the whole texture to the rectangle correct?

 

Assuming your rendering as triangle strips try implementing the following pseudocode:

 

vert 1.texcoord = 0,0

vert 2.texcoord = 0,1

vert 3.texcoord = 1,1

vert 4.texcoord = 1,0

 

If that doesn't work try shifting the coords between the different verts, one combination should work for you.

 

 

Good luck.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement