SFML fails in multithreading

后端 未结 1 1700
礼貌的吻别
礼貌的吻别 2021-01-14 20:28

im new to sfml and c++.and I have a project that uses the sfml library\'s to draw the graphics but when I add an additional thread to my program it fails to execute the code

相关标签:
1条回答
  • 2021-01-14 21:22

    http://www.sfml-dev.org/tutorials/2.0/graphics-draw.php#drawing-from-threads

    SFML supports multi-threaded drawing, and you don't even have to do anything to make it work. The only thing to remember is to deactivate a window before using it in another thread; that's because a window (more precisely its OpenGL context) cannot be active in multiple threads at the same time.

    call window.setActive(false); in your main(), before you pass it off to the thread.

    And remember that you must handle events in the GUI thread (the main thread) for maximum portability.

    0 讨论(0)
提交回复
热议问题