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

Author Topic: Sprites rendered approximately  (Read 6707 times)

0 Members and 1 Guest are viewing this topic.

Dr_Asik

  • Newbie
  • *
  • Posts: 13
    • View Profile
Sprites rendered approximately
« on: November 05, 2009, 02:50:11 am »
I am coding a remake of Space Invaders, and my artwork is consequently very low-res. I need it to be drawn with pixel perfect accuracy.

I am using the Sprite class to draw my artwork to the screen, unfortunately, they appear blurry, even if I don't scale/rotate them. Is this a known issue with SFML?

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Sprites rendered approximately
« Reply #1 on: November 05, 2009, 02:52:23 am »
No, it's not even an issue. The problem is you didn't disable Image Smoothing.
I use the latest build of SFML2

Dr_Asik

  • Newbie
  • *
  • Posts: 13
    • View Profile
Sprites rendered approximately
« Reply #2 on: November 05, 2009, 03:10:39 am »
Oh, thanks, wouldn't have guessed that.

By the way, the behavior for specifying the sub rectangle is a bit non-intuitive. When I type

sprite.SetSubRect(IntRect(

Intellisense tells me that the four parameters are:

LeftCoord, TopCoord, RightCoord, BottomCoord

So having a sprite in my spritesheet at [0-7], [0-7], I wrote:

sprite.SetSubRect(IntRect(0, 0, 7, 7));

But then it seemed I was missing a pixel right and one bottom. So I actually have to write this:

sprite.SetSubRect(IntRect(0, 0, 8, 8 ));

Which describes my sprite's sub rectangle as
[0-8[, [0-8[

A bit weird IMO. XNA was fool-proof:

Code: [Select]
public Rectangle (
         int x,
         int y,
         int width,
         int height
)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sprites rendered approximately
« Reply #3 on: November 05, 2009, 07:22:19 am »
You're right, SFML rectangles are confusing and not consistent. They will be rewritten for SFML 2 :)
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Sprites rendered approximately
« Reply #4 on: November 05, 2009, 08:16:14 am »
Quote from: "Laurent"
You're right, SFML rectangles are confusing and not consistent. They will be rewritten for SFML 2 :)

I hope you mean the internals and not the structure with Right and Bottom?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sprites rendered approximately
« Reply #5 on: November 05, 2009, 08:28:19 am »
Well, maybe Width/Height would be less confusing than Right/Bottom, I don't know...
Laurent Gomila - SFML developer

Dr_Asik

  • Newbie
  • *
  • Posts: 13
    • View Profile
Sprites rendered approximately
« Reply #6 on: November 05, 2009, 08:35:52 am »
Thanks for the follow-up.

What confused me is that left/top are included, but bottom/right are excluded. The only way I could figure that out was through experimentation, and I was lucky to be using very small sprites, I might not have noticed a one pixel difference with larger ones.

Either have bottom/right included, or do it like XNA, IMO you can't go wrong with how XNA does things.  :)

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Sprites rendered approximately
« Reply #7 on: November 05, 2009, 01:06:27 pm »
We already had the discussion about included and excluded coordinates. It's an info that's probably missing in the documentation, but sf::Rect is currently inconsistent, anyway.

I'm absolutely for Right/Bottom. Width and height could be set through SetWidth()/SetHeight() mutators. The other way around would be SetRight()/SetBottom(), which seems a bit odd to me.

Also I find it more logical: A rectangle is mostly described by giving two points, not one point and a size. This opinion may differ. ;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sprites rendered approximately
« Reply #8 on: November 05, 2009, 02:31:32 pm »
I think that this is strictly identical, and it's mostly a matter of taste ;)

I'm personnally perfectly ok to describe a rectangle with a point and a size.

I was previously in favor of keeping the current members (right/bottom), but after reading this topic I realize that width/height is not confusing at all and doesn't have the "included/excluded" issue. Ok, I know, this must be documented anyway... ;)
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Sprites rendered approximately
« Reply #9 on: November 05, 2009, 08:04:54 pm »
It's not confusing, that's true. Like I said opinions may be different in that point. I guess I'm just used to it.

Btw, the "excluded coordinates problem" would not completely disappear. Wouldn't sf::Rect have accessors like GetRight()/GetBottom() when the members itself are Width and Height (I really would hate it to implement those myself ;))? But whatever, I like that behaviour, as long as it's documented.

I think it'd be interesting to hear more opinions about that, just out of curiosity. In the end it's already you, Laurent, who decides that. ;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sprites rendered approximately
« Reply #10 on: November 05, 2009, 08:11:55 pm »
Quote
I think it'd be interesting to hear more opinions about that

Definitely :)
Laurent Gomila - SFML developer

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
Sprites rendered approximately
« Reply #11 on: November 05, 2009, 11:03:36 pm »
How about rotated rects?
Listen to my band: pencilcase.bandcamp.com

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Sprites rendered approximately
« Reply #12 on: November 05, 2009, 11:55:31 pm »
Quote from: "Laurent"
Well, maybe Width/Height would be less confusing than Right/Bottom, I don't know...
I definitely agree. In my opinion, begin/size rects are far more intuitive and comfortable than begin/end ones.

By the way, I started this discussion half a year ago... ;)
http://www.sfml-dev.org/forum/viewtopic.php?t=1211
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Sprites rendered approximately
« Reply #13 on: November 06, 2009, 07:47:08 am »
Quote
How about rotated rects?

I already thought about it. They would be useful for some features, such as providing the global bounding rect of drawables or views, or defining rotated render masks ; however I'm not sure whether this stuff should be implemented in SFML.

Quote
By the way, I started this discussion half a year ago...

You see, I finally changed my mind :lol:
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Sprites rendered approximately
« Reply #14 on: November 06, 2009, 04:31:26 pm »
Quote from: "Laurent"
You see, I finally changed my mind :lol:
Oh, no problem. I'm really glad you are sceptical to every design change in your library. Without clear guidelines, the SFML library wouldn't be as well structured as it is now. ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: