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

Author Topic: Enlarged Bounds?  (Read 988 times)

0 Members and 1 Guest are viewing this topic.

Arsonide

  • Newbie
  • *
  • Posts: 4
    • View Profile
Enlarged Bounds?
« on: July 22, 2013, 11:42:12 am »
I've created a custom VertexArray object. Essentially what is going on is that my atlas program has stripped the transparent areas of this image off, saving a bit of space in the atlas and subsequently a bit of space in memory. However, it causes it to be necessary to display everything at an offset. The offset is easy - just change the origin...however...It also changes the size of each image somewhat.

My question, is that right now it appears that the transform's globalBounds are intimately tied to the size of the image on the screen. I want to increase it to include the transparent areas that the atlas program cut off. Is this possible?

The reason for this is simple - imagine an animated player. If the bounds keep changing, he's going to be bouncing all over the place.

EDIT: I had a thought. Perhaps have four blank vertices at the original corners of the image, followed by four vertices defining the trimmed image. That should be possible, I'd imagine. So another question, would having an extra four blank vertices on every sprite impact performance at all, versus just leaving the transparent areas in the images and not bothering with all this trimming nonsense?
« Last Edit: July 22, 2013, 12:12:23 pm by Arsonide »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Enlarged Bounds?
« Reply #1 on: July 22, 2013, 12:55:29 pm »
Nope. The bounds represent exactly what's there on the graphics end, so if you cut things off, it will be cut-off. But you can always add it back manually...

Since I doubt that you'll run into any performance problems, by leaving in a bit more transparent pixels the GPU doesn't care about, I suggest to not cut it of for convenience, i.e. easier animation.
If you don't want to do this (although you still don't have any performance issue), then it's your job to define a way to be able to keep track of the animation position.

I'm unsure what you mean with the four vertices, but a bit more transparent pixels won't have a huge impact.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/