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

Author Topic: SFML sprites won't be drawn to my render window if they have a negative position  (Read 899 times)

0 Members and 1 Guest are viewing this topic.

Sean Mulligan

  • Newbie
  • *
  • Posts: 16
    • View Profile
Whenever I try drawing an sfml sprite with a negative position to a render window, it will not display. Is this intentional? If so how do I go around it? If not how do I fix it? Please help, I have been trying to fix this for hours.

Further details:
I am using a view on the window that is provided in an sfml resource on how to allow resizing in a window. It ranges from (0,0) to the window's border
The window is render window, and I am accessing it using a pointer.
The sprite's texture is applied from a variable.
A a texture rect is applied to allow for correct sizing.
Then the sprite's size is set.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
the only thing I can think of without further information or any code is that since your view goes from 0,0 to window size, sprites in negative position will be outside the view and therefore will be drawn where they cannot be seen.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Sean Mulligan

  • Newbie
  • *
  • Posts: 16
    • View Profile
Yes, the sprite is being rendered from a point outside the view to inside the view, so the sprite should be partially seen, but is not rendering at all. I could provide some demo code if you would like.

Sean Mulligan

  • Newbie
  • *
  • Posts: 16
    • View Profile
Hey, I was debugging my code, and there was nothing wrong with SFML. Turns out I had an issue with signed/unsigned ints messing with the negative values when drawing.

Thank you nonetheless Stauricus for your help. ;) This may be one of the kindest sites on the internet.

----------------------------------ANSWER FOR ANYONE WITH THIS PROBLEM----------------------------------

Please check if your variables are signed and unsigned. This was the cause of the problem for me.
----------------------------------------------------------------------------------------------------------------------

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
so afterall it WAS being drawn offscreen  ;D
good thing you fixed it
Visit my game site (and hopefully help funding it? )
Website | IndieDB