1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 17:29:55 +00:00

Fix crash when OSG_STEREO is enabled

This commit is contained in:
scrawl 2015-06-08 03:26:36 +02:00
parent 347c9b57b8
commit fc8e5dde3b

View file

@ -107,7 +107,7 @@ class Drawable : public osg::Drawable {
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
mReadFrom = (mReadFrom+1)%2;
mReadFrom = (mReadFrom+1)%sNumBuffers;
const std::vector<Batch>& vec = mBatchVector[mReadFrom];
for (std::vector<Batch>::const_iterator it = vec.begin(); it != vec.end(); ++it)
{
@ -188,15 +188,18 @@ public:
void clear()
{
mWriteTo = (mWriteTo+1)%2;
mWriteTo = (mWriteTo+1)%sNumBuffers;
mBatchVector[mWriteTo].clear();
}
META_Object(osgMyGUI, Drawable)
private:
// 2 would be enough in most cases, use 4 to get stereo working
static const int sNumBuffers = 4;
// double buffering approach, to avoid the need for synchronization with the draw thread
std::vector<Batch> mBatchVector[2];
std::vector<Batch> mBatchVector[sNumBuffers];
int mWriteTo;
mutable int mReadFrom;