Fixes two issues:
1. FreeStringArrayPtr used the wrong variable in the offset to
ReadIntPtr causing an access violation.
2. Better cleanup of memory in MarshalStringArrayToPtr when any alloc
fails.
Most OpenGL versions work with single-byte ASCII strings exclusively.
OpenGL 4.2 adds UTF8 encoded comments to GLSL shaders. Unfortunately,
UTF16 (.Net) to UTF8 conversions will usually modify the length of the
resulting byte array.
This is not currently possible to implement inside OpenTK, since the
binding generator does not know which length parameter corresponds to a
string parameter.
For this reason, and to maintain compatibility with older OpenGL
versions, we perform a destructive UTF16-to-ASCII encoding, which
replaces unsupported characters by '?'. This allows multi-byte post-4.2.
GLSL shaders to work as expected.
If non-destructive round-tripping of strings is required, the user will
have to use the IntPtr overload for string parameters and perform the
UTF16-to-UTF8 encoding/decoding manually. This need is very unlikely to
arise in practice.
Starting with OpenGL 4.2, strings passed to GL.ShaderSource are allowed
to contain multi-byte characters in comments (issue #18). This patch
modifies the marshaling code to use UTF8.GetBytes in order to marshal
strings, instead of Marshal.StringToHGlobalAnsi().
Added GraphicsContext() constructor that takes an existing, valid OpenGL context. This can be used for interop with third-party toolkits which create the OpenGL context themselves.
* Graphics/BindingsBase.cs:
* Graphics/GraphicsBindingsBase.cs: Moved GraphicsBindingsBase to its
own file.
Moved BindingsBase to root OpenTK folder (reason: BindingsBase is not
specific to OpenTK.Graphics anymore).
Documented GetAddress methods.
2009-10-07 10:52:48 +00:00
Renamed from Source/OpenTK/Graphics/BindingsBase.cs (Browse further)