Just grabbed some code I've been working on from my Windows machine and loaded it onto Linux and it isn't working. The error message suggests that it is on SFML's end, not mine, though when I tried the minimal threading example from the tutorials, it worked fine.
The error message is:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
ElectroToy: ../../src/xcb_io.c:273: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted
Process returned 134 (0x86) execution time : 0.232 s
Press ENTER to continue.
My code (I haven't worked on it for long yet so don't judge :p)
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <iostream>
#define WIDTH 800
#define HEIGHT 600
sf::RenderWindow App();
sf::Uint8 *pixels = new sf::Uint8[WIDTH * HEIGHT * 4];
void draw(int x, int y, int r, int g, int b)
{
pixels[(x + WIDTH * y) * 4 + 0] = r;
pixels[(x + WIDTH * y) * 4 + 1] = g;
pixels[(x + WIDTH * y) * 4 + 2] = b;
pixels[(x + WIDTH * y) * 4 + 3] = 255;
}
void display(void *UserData)
{
sf::RenderWindow App(sf::VideoMode(WIDTH, HEIGHT, 32), "Speed Test");
sf::Image screen(WIDTH, HEIGHT);
sf::Sprite sprite;
while (1)
{
screen.LoadFromPixels(WIDTH, HEIGHT, pixels);
sprite.SetImage(screen);
App.Clear();
App.Draw(sprite);
App.Display();
}
}
int main()
{
sf::RenderWindow App(sf::VideoMode(WIDTH, HEIGHT, 32), "Speed Test");
sf::Thread graphics(&display);
sf::Clock clock;
const sf::Input & Input = App.GetInput();
bool mouseX = Input.GetMouseX();
bool mouseY = Input.GetMouseY();
bool leftMouse = Input.IsMouseButtonDown(sf::Mouse::Left);
bool rightMouse = Input.IsMouseButtonDown(sf::Mouse::Right);
graphics.Launch();
while (1)
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
}
if (leftMouse)
draw(mouseX, mouseY, 255, 255, 255);
}
}