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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - shodan49

Pages: [1]
1
General / Re: 2 windows each with it's own rendering threa
« on: May 06, 2020, 09:31:18 am »
after asking in the discord i discovered you must add -lX11
to link the library.

2
General / Re: 2 windows each with it's own rendering threa
« on: May 06, 2020, 06:40:11 am »
ok, XInitThreads(); is a function inside an external library (not SFML).
to install it on linux you need to write: sudo apt install libx11-dev
and then include the header: #include <X11/Xlib.h>

I am now getting an error when i'm trying to link it though...

g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -?

what -? do i need to write to do that?

3
General / Re: 2 windows each with it's own rendering threa
« on: May 06, 2020, 05:49:24 am »
Quote
Most likely this is a multi-threaded client and XInitThreads has not been called
So, call XInitThreads() ;)

is it a function i have to write in the code or something i have to write in the terminal?

4
General / Re: 2 windows each with it's own rendering threa
« on: May 05, 2020, 07:13:27 pm »
yes, sometimes is says this:

[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
sfml-app: ../../src/xcb_io.c:641: _XReply: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted (core dumped)

5
General / 2 windows each with it's own rendering threa
« on: May 05, 2020, 05:35:53 pm »
what i'm doing should be very simple and yet every time i run this (on linux) i get a different error message, sometimes it runs for a few seconds before becoming unresponsive.

#include <SFML/Window.hpp>
#include <SFML/System.hpp>

class Application
{
public:
    sf::Window *mainWindow;
    sf::Window *debugWindow;
    Application(sf::Window *main, sf::Window *debug)
    {
        mainWindow = main;
        debugWindow = debug;
    }
    void execute()
    {
        while (mainWindow->isOpen())
        {
            // do something...
        }
    }
};
void ThreadA(sf::Window *window)
{
    window->setActive(true);

    while (window->isOpen())
    {
        sf::Event event;
        while (window->pollEvent(event))
            if (event.type == sf::Event::Closed)
                window->close();
        window->display();
    }
}
void ThreadB(sf::Window *window)
{
    window->setActive(true);

    while (window->isOpen())
    {
        sf::Event event;
        while (window->pollEvent(event))
            if (event.type == sf::Event::Closed)
                window->close();
        window->display();
    }
}
int main()
{
    sf::Window mainWindow(sf::VideoMode(1600, 900), "main window");
    sf::Window debugWindow(sf::VideoMode(400, 400), "debug window");
    mainWindow.setActive(false);
    debugWindow.setActive(false);
    Application Application(&mainWindow, &debugWindow);
    sf::Thread mainThread(&ThreadA, &mainWindow);
    mainThread.launch();
    sf::Thread debugThread(&ThreadB, &debugWindow);
    debugThread.launch();
    Application.execute();
    return 0;
}

i followed the tutorials step by step and i can't find what i'm doing wrong.

Pages: [1]
anything