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

Author Topic: Incorrect (shapes, sprites and other) texture drawing  (Read 1735 times)

0 Members and 1 Guest are viewing this topic.

CrazyMan

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Incorrect (shapes, sprites and other) texture drawing
« on: January 31, 2021, 05:04:53 pm »
On drawing any drawable with texture i get this vertical line

How i can remove this?

P.S. Sorry for my bad english

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Incorrect (shapes, sprites and other) texture drawing
« Reply #1 on: February 01, 2021, 09:59:28 am »
Are you rendering on integer positions?

Can you provide a minimal and complete example?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CrazyMan

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Incorrect (shapes, sprites and other) texture drawing
« Reply #2 on: February 01, 2021, 11:02:57 am »
Are you rendering on integer positions?
Not

Can you provide a minimal and complete example?
Oh sure

#include <iostream>
#include <SFML/Graphics.hpp>

sf::RenderWindow _window;
sf::RectangleShape _test;
sf::Texture _tex;

void drawingLoop()
{
    _window.setActive(true);

    while (_window.isOpen())
    {
        _window.clear({ 16, 32, 128});

        _window.draw(_test);

        _window.display();
    }
}

int main()
{
    _tex.loadFromFile("Test.png");

    _test.setTexture(&_tex);
    _test.setTextureRect({ 1, 1, 15, 15});
    _test.setOrigin({ 128, 128 });
    _test.setPosition({ 512.5, 256 });
    _test.setSize({ 256, 256 });

        sf::ContextSettings settings;
        settings.antialiasingLevel = 4;

        _window.create({ 1280, 720 }, "Test", sf::Style::Close, settings);
        _window.setVerticalSyncEnabled(true);

        _window.setActive(false);

        sf::Thread drawingThread(&drawingLoop);
        drawingThread.launch();

        while (_window.isOpen())
        {
            sf::Event e;
            while (_window.pollEvent(e))
            {
                if (e.type == sf::Event::Closed)
                {
                    _window.close();
                }
            }
        }

        return 0;
}