0 Members and 1 Guest are viewing this topic.
#include <SFML/Graphics.hpp>class CWindow{private: static sf::RenderWindow Window;public: static void Init(unsigned int Width, unsigned int Height, int Style=sf::Style::Default) { Window.Create(sf::VideoMode(Width,Height), "", Style); } static bool IsOpened() { return Window.IsOpened(); } static void Clear(sf::Color Color=sf::Color(0,0,0)) { Window.Clear(Color); } static void Draw(const sf::Drawable &Drawable) { Window.Draw(Drawable); } static void Display() { Window.Display(); sf::Sleep(0); } static bool GetEvent(sf::Event& Event) { return Window.GetEvent(Event); } static void Close() { Window.Close(); }};sf::RenderWindow CWindow::Window;int main(){ sf::Image CornerImage; CornerImage.LoadFromFile("Corner.png"); sf::Sprite Corner; Corner.SetImage(CornerImage); CWindow::Init(100,100); while (CWindow::IsOpened()) { sf::Event Event; while (CWindow::GetEvent(Event)) { if (Event.Type==sf::Event::Closed) CWindow::Close(); } CWindow::Clear(sf::Color(255,255,0)); CWindow::Draw(Corner); CWindow::Display(); }}
When drawing sprites on window which is in static class, you get really weird artifacts
Here's the download to minimal example which has a png and somewhat minimal code.
What kind of artifacts?
A global/static pointer to a sf::RenderWindow which is allocated in CWindow::Init?
What happens if you create the image and sprite after calling CWindow::Init? ...
Woah! Now it works as it should for some reason! Never fought that window is interconnected with Image