Wheres the videos?
/
0 Comments
So you might be wondering if you are reading this blog where the videos I promised are.
Well I decided to implement a small seemingly insignificant feature to make the video look better. This ended up breaking the entire code base, and I just barely fixed the problems I created.
It came down to threading issues between Ogre and OpenGL.
It turns out Ogre is not thread safe (should have seen it coming) and OpenGL is even less thread safe. OpenGL is a state based language. It has one state where rendering can take place and another where objects can be created.
When creating a manualObject in Ogre. One must call the end() method to signal the completion of the manualObject. This call makes several rendering calls in order to place the created mesh into the Ogre rendering Pipeline.
Unfortunately this means if you try and make a second thread which creates your manualObjects, then the end() call could be made in the middle of the main thread's OpenGL rendering sequence. As you can't start the same state twice in OpenGL this causes a nasty exception and a crash of the engine.
There are some ways to get around this but it requires some crazy synchronization of GL state sharing. Trust me it gets nasty.
I decided to take the easier way out. I synchronized all rendering operations on the main thread. The second thread creates the manualObjects but does not call end(). It then passes the objects to the main thread which calls end() and loads them into the rendering pipeline. This fixed all my errors with threading and OpenGL. I have some optimization issues I need to address, but that can wait until a later time.
Now I am working on terrain generation and preparing some videos to show my work. I also might walk through some of my code once I clean it up a bit.
In other news Corndog has been hard at work and prepared some prototypes of our asteroids clone. (The title is still being discussed. He should be posting some links to the javascript prototype he created soon.
Well I decided to implement a small seemingly insignificant feature to make the video look better. This ended up breaking the entire code base, and I just barely fixed the problems I created.
It came down to threading issues between Ogre and OpenGL.
It turns out Ogre is not thread safe (should have seen it coming) and OpenGL is even less thread safe. OpenGL is a state based language. It has one state where rendering can take place and another where objects can be created.
When creating a manualObject in Ogre. One must call the end() method to signal the completion of the manualObject. This call makes several rendering calls in order to place the created mesh into the Ogre rendering Pipeline.
Unfortunately this means if you try and make a second thread which creates your manualObjects, then the end() call could be made in the middle of the main thread's OpenGL rendering sequence. As you can't start the same state twice in OpenGL this causes a nasty exception and a crash of the engine.
There are some ways to get around this but it requires some crazy synchronization of GL state sharing. Trust me it gets nasty.
I decided to take the easier way out. I synchronized all rendering operations on the main thread. The second thread creates the manualObjects but does not call end(). It then passes the objects to the main thread which calls end() and loads them into the rendering pipeline. This fixed all my errors with threading and OpenGL. I have some optimization issues I need to address, but that can wait until a later time.
Now I am working on terrain generation and preparing some videos to show my work. I also might walk through some of my code once I clean it up a bit.
In other news Corndog has been hard at work and prepared some prototypes of our asteroids clone. (The title is still being discussed. He should be posting some links to the javascript prototype he created soon.


