I'm having a problem and I think it has something to do with my topic. Basically I send a "start" signal to my Renderer and when it receives that signal it will create the window and launch the thread that will handle the rendering. Then in the rendering thread, so far all it does is call Display on the window. I've checked and all values are correct so it's no invalid pointers or something like that. Also debugging it showed me that the threads are running like they should.
The error message I get is "Failed to activate the window's context" when I call Display.
What am I missing?
Anyway here's concerning code:
void RendererReceiver::OnStart(const SignalBase &signal)
{
const RendererStartSignal &start = static_cast<const RendererStartSignal &>(signal);
myController.InitTarget(start.GetWindow(), start.GetMode(), start.GetTitle(), start.GetStyle(), start.GetSettings());
myController.LaunchThread();
}
void RendererController::InitTarget(sf::RenderWindow *window, const sf::VideoMode &mode, const std::string &title, const unsigned long style, const sf::ContextSettings &settings)
{
myTarget = window;
window->Create(mode, title, style, settings);
window->SetFramerateLimit(MaxFrameRate);
window->Clear();
window->Display();
}
void RendererController::Run()
{
sf::Sleep(0.1f);
while(myContinueExecutionFlag == true)
{
myReceiver->ProcessSignals();
myTarget->Display();
}
}
Forgot to say that this is with SFML2 and a thought is that in Windows a window handle or opengl context or whatever is the problem might not be capable of being shared between threads? Or me missing something important.