SFML community forums

Help => Graphics => Topic started by: hdsiria on March 27, 2024, 05:18:02 pm

Title: hello. a question about setTextureRect
Post by: hdsiria on March 27, 2024, 05:18:02 pm
I use RectangleShape to hold the map. I use setTextureRect to adjust the area where the map appears in RectangleShape .
 But if I set the area to exceed the size of the original map, there's a blur of color around it. I wonder if I can remove these colors or make them black
 rectangleShape.setTextureRect(sf::IntRect(-100,-10,9000,9000));
 
The original size was 8000*8000.The picture of the problem is attached
Title: Re: hello. a question about setTextureRect
Post by: kojack on March 28, 2024, 04:11:45 am
OpenGL has the following texture wrapping modes: GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, GL_MIRRORED_REPEAT, GL_REPEAT and GL_MIRROR_CLAMP_TO_EDGE.
Clamp to edge does what you are seeing, the edge pixels are extended infinitely around the texture.
Clamp to border lets you specify a single colour (like black) to show around the texture.
Repeat makes the texture tile (so it repeats).

SFML however only supports repeat and clamp to edge. It doesn't have clamp to border. (At least in SFML 3, which I'm using).

I don't know if there's an easy way to trick it besides editing texture.cpp to add the border mode in.
Title: Re: hello. a question about setTextureRect
Post by: eXpl0it3r on March 28, 2024, 07:20:52 am
There's no support for GL_CLAMP_TO_BORDER indeed.

I recommend to not stick to texture size and draw a border of your own.