5
« on: May 18, 2011, 09:22:48 am »
Alright so I've been playing around with SFML for a few days now, just for a bit of fun. I've decided to try to get it working with two threads, one to handle input, audio and the like, and the other to loop through a 3d scene and perform all the rendering tasks. The trouble is, I'm not sure if I'm getting this down correctly, presently I have a black filled window, that handles input and everything fine, but nothing from the rendering thread draws to the window. I've debugged and checked to make sure everything is running as I expect it to, so I'm guessing I've misinterpreted the docs on how to accomplish this. Here's what I've got thus far (just the important parts obviously):
Main Thread
App has a sf::Window as a member
App::Init()
{
// Creates and sf::Window
sf::VideoMode videoMode(iWidth, iHeight, 32);
mWindow.Create(videoMode, "AppNameHere");
}
App::Loop()
{
while(!quit)
{
mWindow.SetActive();
// Process Events for close, resize ect here
mWindow.Display();
}
mWindow.Close();
}
Render Thread
Renderer Class has a sf::Context as a member
Renderer::Init()
{
// Set GL States and Projection Matrix
}
Renderer::Loop()
{
while(!quit)
{
mContext.SetActive();
// OpenGL Commands here
}
}
This is what I gathered from searching about thus far. Any help would be greatly appreciated =]