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 - MaxV37

Pages: [1]
1
System / Problem with threads on Linux
« on: July 15, 2017, 03:46:05 pm »
I am trying to separate the event thread and the rendering thread in my game.

To try it out, I ran the following code from the SFML tutorials :

void renderingThread(sf::RenderWindow* window)
{
    // the rendering loop
    while (window->isOpen())
    {
        // draw...

        // end the current frame
        window->display();
    }
}

int main()
{
    // create the window (remember: it's safer to create it in the main thread due to OS limitations)
    sf::RenderWindow window(sf::VideoMode(800, 600), "OpenGL");

    // deactivate its OpenGL context
    window.setActive(false);

    // launch the rendering thread
    sf::Thread thread(&renderingThread, &window);
    thread.launch();

    // the event/logic/whatever loop
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) window.close();
        }
    }

    return 0;
}
 

However, after compiling and running this program, I get this error :

Code: [Select]
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
test: xcb_io.c:165: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed.
Aborted (core dumped)

I read in this topic that this problem can be solved by calling XInitThreads(), but that it is a bad solution, because not only is it not cross-platform, but it adds overhead and might slow down everything.

It is explicitly stated in the tutorials to manage events in the main thread, which is the case here, so I think it is a bit misleading to promote a solution that is not cross platform in the tutorials.

I also tested it with std::thread and i get the same results.
I sometimes get this error message repeated multiple times : `Error while creating udev enumerator`, so I believe the problem comes from SFML.

For information, my OS is manjaro Linux, and I use SFML 2.4.2.

2
Graphics / Re: Is it worth it to create as few sprites as possible
« on: July 05, 2016, 02:31:22 pm »
thank you very much for your help

3
Graphics / Is it worth it to create as few sprites as possible
« on: July 05, 2016, 01:25:17 pm »
I am currently making a game with SFML and I wonder if I should reuse the same sf::Sprite to draw all of the entities that are on screen.
For example, if I wanted to draw 20 entities with the same texture, should I make them share the same sprite and move it to the position of the entity before drawing it or is it ok to use 20 sprites sharing the same sf::Texture ?

Same question for the terrain because there are much more sprites involved.

I am worried about slowing the game a lot, but I read that the important thing was to reuse the same texture instance so I am not sure that it is necessary to reuse the same sprite for every entity.

Pages: [1]
anything