tags:

views:

356

answers:

2

I am using glDrawPixels to display an image. I know, I should probably be using textures but there are reasons I'm not. Well at least not for now. Anyways, image being displayed is frequently being updated as if it is being scanned in. This works fine as long as I let it sit and finish the "scanning", however, if I click on the screen while the "scanning is still going on I get an AccessViolation Exception at my glDrawPixels.

Gl.glDrawPixels(mImageWidth, mImageHeight, Gl.GL_LUMINANCE, Gl.GL_UNSIGNED_SHORT, mDisplayBuffer);

mImageWidth and mImageHeight are the expected values so they are not this issue.

I put a for loop that looks at every element in mDisplayBuffer just before glDrawPixels call. No problem occurred here so the Access Violation doesn't seem to be coming from the mDisplayBuffer.

So it must be something within the glDrawPixels right?

I am using the TAO framework so that I can use C# and OpenGl.

Any thoughts would be greatly appreciated since I have run out of ideas.

A: 

Here is a discussion about access violations in tao

http://www.taoframework.com/node/666

epatel
+1  A: 

What's the type of mDisplayBuffer ? Could it be being updated by another thread while the glDrawPixels is in progress, or relocated by the garbage collector (try a scoped lock around the DrawPixels call) ?

timday