Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Sprite streches the Texture  (Read 1566 times)

0 Members and 1 Guest are viewing this topic.

Zeus-Ammon

  • Newbie
  • *
  • Posts: 3
    • View Profile
sf::Sprite streches the Texture
« on: September 27, 2019, 04:25:33 pm »
Hi. I have recently started playing around with SFML and have come across a strange problem.

I am creating a Tile Map implementation and the texture I'm using for the tiles is a 64*64 png but when it comes time to draw the sprites they seem to be stretched in the X axis to what appears to be exactly double the size (128*64).

I have no idea why this is happening. I load the tile texture from the file directly and I have checked that it loads with the correct size. When I create the sprites I use the constructor that receives a Texture which is my understanding that it creates the sprite such that it displays the texture in its original size. Then I simply move the sprite to its correct position (using move function).

EDIT:
To clarify even simply creating a sprite with said 64*64 texture and drawing it on screen still reproduces these results independently of any of my Tile Map implementation code being run.

To the effect of:

sf::RenderWindow window(sf::ViewMode(1920,1080), "Title", sf::Style::Fullscreen);
sf::Texture t;
t.loadfromfile("path");
sf::Sprite s( t );

// Somewhere in render loop
window.draw(t);

Any help would be appreciated.
Thanks in advance.
« Last Edit: September 27, 2019, 07:24:28 pm by Zeus-Ammon »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: sf::Sprite streches the Texture
« Reply #1 on: September 27, 2019, 08:00:58 pm »
If you run the SFML examples do they look similarly stretched? If not, can you provide a complete but minimal example?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Zeus-Ammon

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: sf::Sprite streches the Texture
« Reply #2 on: September 28, 2019, 11:09:42 pm »
Thanks for your concern. It has come to my attention that the View I was using was being instantiated with is default constructor and thus created with a size of 1000*1000 which did not match the window resolution which resulted in the strange effect where displayed textures had different sizes to what I expected. Noob mistake !