1
Graphics / Re: Incorrect (shapes, sprites and other) texture drawing
« 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;
}
#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;
}