Hi, I've a very low FPS (15 FPS) in my project because the CPU is waiting after the GPU. :/
So, I want to render the scene in another thread because my scene is very complex.
The main purpose is to make my games more realistic. (Shadow, light, disfraction and refraction, etc...)
Most of all I've to apply the shaders in a specific ordre to handle the opacity.
So, I can't draw everything with a single draw call.
I've seen on your tutorials that it's possible to use a thread with SFML to draw the scene.
So, I've tried this with a minimal code. (No need to draw anything to repoduce the crash)
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
void renderingThread(sf::RenderWindow* window)
{
// the rendering loop
while (window->isOpen())
{
window->clear();
window->display();
}
}
int main (int argv, char* argc[]) {
//XInitThreads();
// 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;
}
Here is what it shows in the terminal :
[xcb] Unknow request in queue while dequeuing
[xcb]Most likely this is a multi-threaded client and XInitThreads has not been
called.
[xcb]Abording, sorry about that.
ODFAEG-DEMO: ../../src/xcb_io.c;179: dequeue_pending_request: Assertion '!xcb_xlib_unknown_req_in_deq' failed.
Aborded (core dumped)
Process returned 134 (0x86) execution time : 0.293 s
Press ENTER to continue.
I've tried to make what it says : calling XInitThreads at the frist line in the main but it doesn't solve the problem.
Is there another library than Xlib which support multi-threading with GUI on linux ?
I've heard about xcb but, I don't know it very well.
PS : I've also tried to use std::thread instead of sf::Thread but it still doesn't solve the problem.
Thanks for your help.