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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Laguna_1989

Pages: [1]
1
C / Re: Is SFML Compatable with Emscripten (Webassembly)?
« on: April 05, 2022, 03:19:08 pm »
Would be highly interested in this one as well. Any updates here?

2
Graphics / Re: Scrolling tilemap issue: black bars
« on: November 05, 2020, 04:47:40 pm »
i think that its not on the view, but mainly the tiles positions. try to position them with integers instead of floats.

It solved the issue for me and it makes perfect sense, why that is. tiles are always placed on full tile positions.
In the version without the fix, the view was position on subpixel coordinates (view position is float and you could easily move it by 0.1 of a pixel, which lead to the opengl glitch).
In the fixed version the view can only be placed at full pixel positions.

Extending tiles by a pixel is a simple solution. You can also sometimes get away with shrinking the texture rectangle by a fraction (half is most secure but 0.2 could make a serious reduction on artifacts) of a pixel on each edge but this is better when the texture doesn't have to be "pixel perfect".
This soulds like a lot of work, as I load the tiles from one tileset image, which is also used in Tiled.
If you have one image per tile, this might be an easier solution.

3
Graphics / Re: Scrolling tilemap issue: black bars
« on: November 04, 2020, 06:42:26 pm »
Thanks for the quick reply. I wasn't aware this is an opengl issue.

There are two possible fixes:

a) As the tilemap is drawn on the complete screen anyway, I could just omit the clearing of the rendertarget.
b) Make sure the view position is only set to integer positions instead of pixel positions.The following code fixed it for me:

    sf::Vector2i camOffsetInt { static_cast<int>(m_CamOffset.x + getView()->getSize().x / 2),
        static_cast<int>(m_CamOffset.y + getView()->getSize().y / 2) };

    getView()->setCenter(
        sf::Vector2f { static_cast<float>(camOffsetInt.x), static_cast<float>(camOffsetInt.y) });



Best,
Laguna

4
Graphics / Scrolling tilemap issue: black bars
« on: November 04, 2020, 03:24:49 pm »
Hi,

I have an issue with scrolling tilemaps. Black bars appear sometimes, as you can see in the attached gif.

This happens regardless of vsync on of off, also a framerate limit does not help.

Some additional information:
SFML-2.5.1, win 10, 64 bit
The renderTarget is cleared with black every frame. After that the tilemap is rendered. I do not have a sprite for every single tile but one per tile. E.g. one water tile and one grass tile. I then loop over all tiles and check if I want to draw water or grass. the respective sprite is positioned and drawn.

The camera/scrolling is implemented using the sf::view move() function. I take the framtime into account ,e.g. view->move(scrollspeed * elapsedTime, 0);

Is this possibly some floating point/pixel alingment issue?

Best,
Laguna

Pages: [1]
anything