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

Author Topic: Loading resources using thread  (Read 5339 times)

0 Members and 1 Guest are viewing this topic.

Glocke

  • Sr. Member
  • ****
  • Posts: 289
  • Hobby Dev/GameDev
    • View Profile
Loading resources using thread
« on: October 02, 2014, 04:02:16 pm »
Hi, I'm trying to load my resources using a thread. But it isn't working yet. Here's my error output at the console:
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 88 requests (88 known processed) with 0 events remaining.

I'm using Linux laptop 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:01 UTC 2014 i686 athlon i686 GNU/Linux, C++11, SFML2.1 and this as my example program:

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

sf::Texture tex;

void loadResources() {
    tex.loadFromFile("tile.png");
}

int main() {
    sf::RenderWindow window(sf::VideoMode(640, 480), "Demo");
    sf::Thread thread(&loadResources);
    thread.launch();

    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
        }
    }
   
    return 0;
};
 

Porting to C++11's std::thread causes:
Failed to use the XRandR extension while trying to get the desktop video modes
X Error of failed request:  BadRequest (invalid request code or no such operation)
  Major opcode of failed request:  186 ()
  Minor opcode of failed request:  0
  Serial number of failed request:  89
  Current serial number in output stream:  90
 

Any ideas?

/EDIT: The output seems to vary from each start to another. Here is another one (using sf::Thread again)
X Error of failed request:  BadIDChoice (invalid resource ID chosen for this connection)
  Major opcode of failed request:  1 (X_CreateWindow)
  Resource id in failed request:  0x3c0000b
  Serial number of failed request:  88
  Current serial number in output stream:  88
 
An yet another one:
[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.
main: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
« Last Edit: October 02, 2014, 04:05:31 pm by Glocke »
Current project: Racod's Lair - Rogue-inspired Coop Action RPG

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Loading resources using thread
« Reply #1 on: October 02, 2014, 04:18:30 pm »
The solution is here:

Quote
Most likely this is a multi-threaded client and XInitThreads has not been called
Laurent Gomila - SFML developer

Glocke

  • Sr. Member
  • ****
  • Posts: 289
  • Hobby Dev/GameDev
    • View Profile
Re: Loading resources using thread
« Reply #2 on: October 02, 2014, 04:24:18 pm »
The solution is here:

Quote
Most likely this is a multi-threaded client and XInitThreads has not been called

I included <X11/Xlib.h>, called XInitThreads() right at the beginning of my main function and linked X11. But the error occures anyway :-\

/EDIT: Weeeeell, .... suddenly working Oo
« Last Edit: October 02, 2014, 04:36:33 pm by Glocke »
Current project: Racod's Lair - Rogue-inspired Coop Action RPG

Glocke

  • Sr. Member
  • ****
  • Posts: 289
  • Hobby Dev/GameDev
    • View Profile
Re: Loading resources using thread
« Reply #3 on: May 13, 2016, 11:43:21 am »
Hi, is it correct that calling XInitThreads isn't necessary anymore for v2.3.2?
Current project: Racod's Lair - Rogue-inspired Coop Action RPG

 

anything