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

Author Topic: Tilemap - pixel big gaps  (Read 2607 times)

0 Members and 1 Guest are viewing this topic.

jdm1891

  • Newbie
  • *
  • Posts: 17
    • View Profile
Tilemap - pixel big gaps
« on: April 30, 2016, 04:47:41 pm »
Whenever I use a view, I'm getting gaps like this http://imgur.com/v3WZZ0V

I've tried rounding everything - adding 0.375 and taking away 0.075 - Nothing works!

http://pastebin.com/X0926NQx - my gameEngine.cpp(view handling at the bottom)
http://pastebin.com/S9Wt05ZN - my TileMap.cpp(problem possibly at line 100?)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Tilemap - pixel big gaps
« Reply #1 on: April 30, 2016, 05:36:40 pm »
I've tried rounding everything - adding 0.375 and taking away 0.075 - Nothing works!
Adding those numbers is not supposed to work. The reason you may still find this advice in the forum can be a bug in SFML's rendering that was fixed years ago.

Have you read A note on coordinates and undistorted rendering here?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

jdm1891

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Tilemap - pixel big gaps
« Reply #2 on: April 30, 2016, 05:41:47 pm »
Yes, if you look at my gameEngine.cpp at the bottom, you can see that I have made sure to round all values

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Tilemap - pixel big gaps
« Reply #3 on: April 30, 2016, 05:50:56 pm »
The view is only one part. And force-rounding it won't help if it's not aligned with the window size, you better make sure center and size are integral in the first place.

It might help if you posted only relevant minimal code directly here, not on an external site. If you do so, please read that link carefully.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

jdm1891

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Tilemap - pixel big gaps
« Reply #4 on: April 30, 2016, 05:58:25 pm »
        //Window
        _settings.antialiasingLevel = 8;
        _window.create(_gameBorder, "Game", sf::Style::None, _settings);
        _window.setVerticalSyncEnabled(true);
        //Set window to be visible
        _window.setPosition(sf::Vector2i(_window.getPosition().x, _window.getPosition().y -_screenBorder.height*0.02));
 

        _view.setSize(sf::Vector2f(std::floor(32*5),std::floor(32*5) ) );
 

void GameEngine::updateView()
{
        _view.move(1, 1);
        _view.setSize(std::floor(_view.getSize().x), std::floor(_view.getSize().y));
        _view.setCenter(std::floor(_view.getCenter().x) , std::floor(_view.getCenter().y) );
        _window.setView(_view);
}

Here is all of the relevant code(I think?). What do you mean by align it to the window?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Tilemap - pixel big gaps
« Reply #5 on: April 30, 2016, 07:14:18 pm »
As I said, the view is only one part -- read the documentation I linked to, to see what you need to take care of for pixel-perfect rendering.

And what's the purpose of this?
std::floor(32*5)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

jdm1891

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Tilemap - pixel big gaps
« Reply #6 on: April 30, 2016, 07:19:18 pm »
There is no purpose., it was just to be doubly sure it is a whole number.


the documentation says:
"The object's position, origin and scale have no fractional part
The object's and the view's rotation are a multiple of 90 degrees
The view's center and size have no fractional part"

I have all of these things. It does not mention aligning it to the window size, and I don't understand what that means.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Tilemap - pixel big gaps
« Reply #7 on: May 01, 2016, 12:22:20 pm »
It might help if you posted only relevant minimal code directly here, not on an external site. If you do so, please read that link carefully.

It would be good if that code were minimal and complete, in order to be sure you're not doing something wrong elsewhere in your code, and we're looking for errors in the wrong place.

With aligning to the window, I meant that if you want to correspond a pixel in the texture to a pixel on the screen, you should use the window's default view (or an integrally offset version of it).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: