SFML community forums

Help => Graphics => Topic started by: NoRain on December 21, 2018, 12:16:53 pm

Title: [SOLVED] The RectangleShape outline is always red
Post by: NoRain on December 21, 2018, 12:16:53 pm
I have a grid of RectangleShapes in my project:
(https://i.imgur.com/dB0f1Ol.png)
And when I try to add an outline to a cell
m_rect.setOutlineColor(sf::Color::Cyan);
m_rect.setOutlineThickness(1.f);
 
* m_rect's type is RectangleShape

I looks like this:
(https://i.imgur.com/4vPoOn3.png)

uname -a
(click to show/hide)
sfml version: 2.5.1-1

What am I doing wrong?
Title: Re: The RectangleShape outline is always red
Post by: Laurent on December 21, 2018, 12:54:15 pm
If would be helpful if you could try and post a complete and minimal example that reproduces the problem.
Title: Re: The RectangleShape outline is always red
Post by: NoRain on December 21, 2018, 04:29:32 pm
I've tried to reproduce this in a small example, but there it works fine. The outline color is cyan.
So, here is a piece of my project's code: https://pastebin.com/hfG6zxFi.

I draw cells with this code
m_cells[i][j]->draw(target, states);
 
and then just call select/unselect everytime a player clicks on a cell.

Sorry that there's not a small example.
Title: Re: The RectangleShape outline is always red
Post by: eXpl0it3r on December 21, 2018, 07:58:01 pm
It's something in your code, try to reduce the existing code until you reach something more like the minimal example you've created. Along the way you should notice what makes the behavior change.
Or start with the minimal example and keep adding your code until you get a similar code base.

Took a look at the posted code, didn't see anything obvious, but the issue is probably in some code piece you don't expect it...
Title: Re: The RectangleShape outline is always red
Post by: NGM88 on December 22, 2018, 06:23:17 pm
If StackOverflow has taught me anything, it's this:

The code in your question MUST meet the following criteria

1. The code must compile and run when you copy/paste it to an empty (sfml-linked) project.
2. The code must reproduce the problem.

When both criteria are met, you will usually be able to see the solution before even finishing your post.

Even if you can't, you increase your chances of getting a solution from someone else by a zillion percent.
Title: Re: The RectangleShape outline is always red
Post by: NoRain on December 23, 2018, 11:37:22 am
Ok, I've found the problem. It is always red because I set the outline color to red in another function. Sorry, it was silly. I thought it was a bug, but it all because of my inattention.