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

Author Topic: Unwanted outline appearing on RectangleShape  (Read 2024 times)

0 Members and 1 Guest are viewing this topic.

lexected

  • Newbie
  • *
  • Posts: 8
    • View Profile
Unwanted outline appearing on RectangleShape
« on: January 05, 2016, 09:10:49 pm »
Hello!

I'm using this code
rectangle = new sf::RectangleShape(size);
rectangle->setFillColor(sf::Color::White);
rectangle->setOutlineThickness(0.f);
rectangle->setOutlineColor(sf::Color::Transparent);
rectangle->setPosition(position);
target.draw(*rectangle);
 

and yet I'm experiencing something like this


If you look closer you will see a thin gray border around the white boxes. However, it isn't present everyhere. For example, the third box has no border on the bottom side.

A similar thing happens to my textures applied on RectangleShape


No such thing is visible in Inkscape


Any idea what could be causing this?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Unwanted outline appearing on RectangleShape
« Reply #1 on: January 05, 2016, 11:06:59 pm »
It might be an alpha problem.
If it's happening on textures with transparent sections, it's very likely.
The untextured shape, however, might cause edging if the edges/corners are not placed at exact co-ordinates. Are you using anti-aliasing?

For further investigation into your problem, please post a complete and minimal example.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

lexected

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Unwanted outline appearing on RectangleShape
« Reply #2 on: January 06, 2016, 10:09:42 am »
Thank you for your answer.

What is "an alpha problem" and how can it be avoided?

To the untextured shape: I'm not using anti-aliasing. From what I understood from internet, there could be a rounding error of floats in the positions of vertices, but mine seem to be fine to me.

I also didn't mention that I'm rendering contents of a window (both texture and white box) into a RenderTexture, and only then I'm rendering that onto the background rectangle shape in the window.


I'd like to provide a minimal example, but when I tried to reproduce this problem with a new application, it wasn't there.

EDIT:
Ok, I did a bit of further "testing".
I found that those borders aren't there if I overlap two RectangleShapes of the same color.


I am now sure that the problem is in the RenderTexture step. Notice that the characters here are not blured, because I rendered the box directly into the RenderWindow.


EDIT2: SOLVED!
My RenderTexture´s IntRect was smaller (or different) than the size of the texture. That's it.
« Last Edit: January 06, 2016, 10:34:31 am by lexected »

lexected

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Unwanted outline appearing on RectangleShape
« Reply #3 on: January 06, 2016, 10:34:05 am »
I'd still like to ask about that alpha problem. What is it? How could one avoid it? setSmooth, antialiasing or some other trick?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Unwanted outline appearing on RectangleShape
« Reply #4 on: January 06, 2016, 10:35:49 pm »
See my post in the other thread. Is there some specific reason you're trying to draw those rectangles as textures rather than primitives/polygons?

 

anything