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

Author Topic: Impossible to activate render texture  (Read 1054 times)

0 Members and 1 Guest are viewing this topic.

SpaceKotik

  • Newbie
  • *
  • Posts: 3
    • View Profile
Impossible to activate render texture
« on: April 06, 2020, 09:05:21 pm »
Hey there. I'm currently working on a game on linux and it compiles and works fine. But when I try to run my project on win10, I get the error "Impossible to activate render texture (failed to create backup context)
Failed to activate OpenGL context:   ."
This function is being passed to the threads and drawing to targetTex in it causes the error:
void LightScene::doRayTracing(int i, Emitter &emitter, RenderTexture &_targetTex, std::mutex &rtLock) {
    emitter.updateRayTracing();

    rtLock.lock();
    targetTex.draw(emitter.createMesh(), BlendAdd);
    targetTex.display();
    rtLock.unlock();
}
 
As I can figure out, the problem is with changing the context, but I see no possible reasons for it. SFML 2.5.0 and 2.5.1 give the same result and all drivers are up-to-date.
« Last Edit: April 07, 2020, 01:53:21 am by SpaceKotik »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: Impossible to activate render texture
« Reply #1 on: April 07, 2020, 10:25:02 am »
Since you're using a mutex am I right to assume that you're doing something multi-threading?
OpenGL isn't multi-thread capable, as such it's generally not advised to do OpenGL calls from multiple threads.
However if you do, you will have to call setActive() on the RT that should be currently active in a thread.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SpaceKotik

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Impossible to activate render texture
« Reply #2 on: April 07, 2020, 01:21:57 pm »
Thanks, that helped. I made everything run in main thread, but I don't see any performance issues. That was the reason why I started using multi-threading on linux. Is windows somehow manages to make calculations more optimally than linux?  ???

 

anything