{"author_name":"TheBenjaneer","cat":"LD #26","comments":[{"author_name":"Stingray Polymathic","time":"April 20, 2013 9:42 am","epoch":1366468920,"text":"I don&#8217;t have time to verify in detail just now, but it sounds like you&#8217;re drawing the sprite at non-pixel-aligned co\u00f6rdinates, which on a GL billboard would cause a similar effect; it&#8217;d be sampling the texture at an offset.  If that&#8217;s so, you&#8217;ll have to hint your draw transformation so the edges of the quad are exactly at pixel boundaries.  GL uses (\u22121, +1) for each axis of window\/viewport space, so if you already have the final transformed co\u00f6rdinates C you can do P = (C + 1) * viewport_resolution \/ 2 (treating the 2D vectors elementwise) to get pixel co\u00f6rdinates, then do elementwise floor() or such as a quick hack (round() can work too but you have to be careful that related co\u00f6rds don&#8217;t get rounded in different directions or you&#8217;ll get similar distortion), then invert the transformation again to turn them back into GL co\u00f6rdinates, C\u2032 = (P * (2 \/ viewport_resolution)) \u2212 1.","spam":"N"}],"epoch":1366467600,"likes":2,"metadata":{"p_key":"47026","p_author":"TheBenjaneer","p_authorkey":"20637","p_urlkey":"82689","p_title":"Can Anyone Please Help? (SFML)","p_cat":"LD #26","p_event":"LD26","p_time":"1366467600","p_likes":"2","p_comments":"1","p_status":"UPD5","us_key":"20637","us_name":"TheBenjaneer","us_username":"thebenjaneer","event_start":"1366934400","event_key":"16","event_name":"LD26"},"text":"<div id=\"attachment_225163\" style=\"width: 560px\" class=\"wp-caption alignnone\"><img class=\"size-large wp-image-225163\" alt=\"Help Plox!\" src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2013\/04\/weirdPixelsSfml-550x343.png\" width=\"550\" height=\"343\" srcset=\"http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2013\/04\/weirdPixelsSfml-300x187.png 300w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2013\/04\/weirdPixelsSfml-550x343.png 550w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><p class=\"wp-caption-text\">Why does this happen?<\/p><\/div>\n <p>***EDIT:<\/p>\n <p>The first comment here seems to confirm\u00a0Stingray Polymathic&#8217;s (Thanks again!) description of the issue:<\/p>\n <p><em id=\"__mceDel\"><a href=\"http:\/\/www.sfml-dev.org\/old-forum\/viewtopic.php?t=6665&amp;sid=29867a0656278d75e3daec10b7417b8b\">http:\/\/www.sfml-dev.org\/old-forum\/viewtopic.php?t=6665&amp;sid=29867a0656278d75e3daec10b7417b8b<\/a><br \/>\n <\/em><\/p>\n <p>I&#8217;ll go see about adding in a floor() method to see if that solves things.<\/p>\n <p>EDIT<em id=\"__mceDel\">***<br \/>\n <\/em><\/p>\n <p><em id=\"__mceDel\">*****<br \/>\n Edit<\/em> 2:<br \/>\n Floor() &#8216;ing and position update values did the trick for now, and seems to be the best way to handle pixel perfect rendering ( which in retrospect, is rather obvious).<br \/>\n ******<\/p>\n <p>Click for a better look at it. It&#8217;s a very small 128 x 128 px sprite which should be rendered at a 1:1 scale from my understanding, but for some reason is occasionally distorted. The blue &#8216;eyes&#8217; are the wrong size and the red triangle looks off if you look at it closely. It might not seem bad looking at the picture, but it&#8217;s been annoying.<\/p>\n <p>Background info:<\/p>\n <p>I&#8217;m rendering an sf::Sprite in my update loop in a \u00a0sf::RenderWindow, with the texture from a png file. Everything seems fine usually, but sometimes the sprites seem to distort a bit. As you can see from the clipped screenshots in the background the sprite usually looks the same, but occasionally looks like it does in the running window.<\/p>\n <p>Vsync is enabled, and the top middle yellow text is from a very simple frame rate display i wrote, the top right is from fraps.<\/p>\n <p>If it helps, i use SFML 2.0 rc and you can find all of my library code &amp; the sfml binaries here:<\/p>\n <p><a href=\"https:\/\/bitbucket.org\/TheBenjaneer\/libnucleode\">https:\/\/bitbucket.org\/TheBenjaneer\/libnucleode<\/a><\/p>\n <p>I have no idea why this happens. It seems random.<br \/>\n Further, until I move the sprite, it continues to be distorted in exactly the same way every frame.<\/p>\n <p>OpenGl 4.3 Context according to my logs.\u00a0Anti-aliasing\u00a0is at 8. depth bits at 24.<\/p>\n <p>Nvidia GTX 550 ti, driver v 314.22 (latest)<\/p>\n <p>Windows 7 x64 bit ( engine is built\/running 32 bit though ).<\/p>\n <p>Any help, tips, or pointers would \u00a0be vastly appreciated.<br \/>\n Thank you!<br \/>\n -ben<\/p>\n \n <p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/c\/\" rel=\"tag\">C++<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/opengl\/\" rel=\"tag\">opengl<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/please-help\/\" rel=\"tag\">please help<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/screenshot\/\" rel=\"tag\">screenshot<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/sfml-2-0-rc\/\" rel=\"tag\">SFML 2.0 rc<\/a><\/p>","time":"April 20th, 2013 9:20 am","title":"Can Anyone Please Help? (SFML)"}