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:
parent
347c9b57b8
commit
fc8e5dde3b
1 changed files with 6 additions and 3 deletions
|
@ -107,7 +107,7 @@ class Drawable : public osg::Drawable {
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
|
||||||
mReadFrom = (mReadFrom+1)%2;
|
mReadFrom = (mReadFrom+1)%sNumBuffers;
|
||||||
const std::vector<Batch>& vec = mBatchVector[mReadFrom];
|
const std::vector<Batch>& vec = mBatchVector[mReadFrom];
|
||||||
for (std::vector<Batch>::const_iterator it = vec.begin(); it != vec.end(); ++it)
|
for (std::vector<Batch>::const_iterator it = vec.begin(); it != vec.end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -188,15 +188,18 @@ public:
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
mWriteTo = (mWriteTo+1)%2;
|
mWriteTo = (mWriteTo+1)%sNumBuffers;
|
||||||
mBatchVector[mWriteTo].clear();
|
mBatchVector[mWriteTo].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
META_Object(osgMyGUI, Drawable)
|
META_Object(osgMyGUI, Drawable)
|
||||||
|
|
||||||
private:
|
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
|
// 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;
|
int mWriteTo;
|
||||||
mutable int mReadFrom;
|
mutable int mReadFrom;
|
||||||
|
|
Loading…
Reference in a new issue