-1

I've been working on a program using OpenGL for a while now and I recently started getting an error occasionally on this line:

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexID);

Here is the error that comes up, though I don't think it'll help too much:

First-chance exception at 0x0000000069E03C13 (nvoglv64.dll) in Voxel.exe: 0xC0000005: Access violation reading location 0x000000000AA87000.

The address given for the access violation varies, and the time it takes for the violation to occur also varies. Given that the time it takes for the access violation to occur varies, I'm guessing it has to do with two threads trying to access the same data, but there's never any other thread working on the same object when the violation occurs, and I'm using mutexes to make sure that two threads can't write to the same data. I've checked and made sure that the ID for index buffer is valid, and since the only thread that generates and deletes buffer IDs is also the only thread that binds and transfers data into the buffers, I don't believe it's possible for the access violation to be because of that.

How can I track down and/or fix what's causing this access violation?

4

1 回答 1

0

我猜这与试图访问相同数据的两个线程有​​关,

那将被称为竞争条件。竞争条件不会导致访问冲突!

我最好的选择是您从多个线程中使用 OpenGL,并且您只为一个线程初始化扩展。Windows 在 OpenGL 扩展和线程方面有点棘手:函数指针可能因上下文和线程而异。如果您使用为不同的上下文和/或线程初始化的函数指针,则会发生这种情况。

确保您的扩展加载机制正确处理多个线程和上下文。

于 2013-10-26T10:26:14.030 回答