ERP's picture

OpenTK.GL.SelectBuffer doesn't pin the memory long enough

Project:The Open Toolkit library
Category:feature request

GL takes a pointer to the buffer passed in and writes to that memory on the next call to Gl.RenderMode.
The code pins for the duration of the call, but this pattern requires the memory be pinned throughout the intervening operations.
The only example code I could find (in the forums), fails to do this., and it's not mentioned that pinning is required in the docs.

I would suggest removing the GL.SelectBuffer(Int32 size, Int[] buffer) signatures, leaving only the GL.SelectBuffer(Int32 size, Int *buffer) signatures, so people at least realize that the memory needs to be pinned.

The other alternative is to have the library track the buffer that's been set in the current context and pin the memory on calls to GL.SelectBuffer, unpinning when the buffer address is changed.

If nothing else the XML docs should include a statement to the effect that the memory must be pinned or allocated from the unmanaged heap.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture


Version:all versions» 1.x-dev
Component:Code» Documentation
Category:bug report» feature request
Priority:normal» minor
Status:open» confirmed

The user is always responsible for pinning client-side buffers. This is by design: tracking objects is unreliable and raw pointers are not CLS-compliant (which would make these functions impossible to use from e.g. VB.Net).

I'm changing this to a documentation issue: the documentation popup should note that you must pin memory used in this function.

Note that GL3.0 removes all client-side storage functions.