Class BindingsBase
Provides a common foundation for all flat API bindings and implements the extension loading interface.
Inherited Members
Namespace: OpenTK
Assembly: OpenTK.dll
Syntax
public abstract class BindingsBase
Constructors
BindingsBase()
Constructs a new BindingsBase instance.
Declaration
public BindingsBase()
Properties
RebuildExtensionList
Gets or sets a Boolean that indicates whether the list of supported extensions may have changed.
Declaration
protected bool RebuildExtensionList { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
SyncRoot
Gets an object that can be used to synchronize access to the bindings implementation.
Declaration
protected abstract object SyncRoot { get; }
Property Value
Type | Description |
---|---|
Object |
Remarks
This object should be unique across bindings but consistent between bindings of the same type. For example, ES10.GL, OpenGL.GL and CL10.CL should all return unique objects, but all instances of ES10.GL should return the same object.
Methods
FreeStringArrayPtr(IntPtr, Int32)
Frees a marshalled string that allocated by MarshalStringArrayToPtr
.
Declaration
protected static void FreeStringArrayPtr(IntPtr ptr, int length)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | ptr | An unmanaged pointer allocated with |
Int32 | length | The length of the string array. |
FreeStringPtr(IntPtr)
Frees a marshalled string that allocated by MarshalStringToPtr
.
Declaration
protected static void FreeStringPtr(IntPtr ptr)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | ptr | An unmanaged pointer allocated with |
GetAddress(String)
Retrieves an unmanaged function pointer to the specified function.
Declaration
protected abstract IntPtr GetAddress(string funcname)
Parameters
Type | Name | Description |
---|---|---|
String | funcname | A String that defines the name of the function. |
Returns
Type | Description |
---|---|
IntPtr | A IntPtr that contains the address of funcname or IntPtr.Zero, if the function is not supported by the drivers. |
Remarks
Note: some drivers are known to return non-zero values for unsupported functions. Typical values include 1 and 2 - inheritors are advised to check for and ignore these values.
MarshalPtrToString(IntPtr)
Marshals a pointer to a null-terminated byte array to a new System.String
.
This method supports OpenTK and is not intended to be called by user code.
Declaration
protected static string MarshalPtrToString(IntPtr ptr)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | ptr | A pointer to a null-terminated byte array. |
Returns
Type | Description |
---|---|
String | A |
MarshalStringArrayToPtr(String[])
Marshals a System.String
array to unmanaged memory by calling
Marshal.AllocHGlobal for each element.
Declaration
protected static IntPtr MarshalStringArrayToPtr(string[] str_array)
Parameters
Type | Name | Description |
---|---|---|
String[] | str_array | The string array to marshal. |
Returns
Type | Description |
---|---|
IntPtr | An unmanaged pointer to an array of null-terminated strings |
MarshalStringToPtr(String)
Marshal a System.String
to unmanaged memory.
The resulting string is encoded in UTF8 and must be freed
with FreeStringPtr
.
Declaration
protected static IntPtr MarshalStringToPtr(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str | The |
Returns
Type | Description |
---|---|
IntPtr | An unmanaged pointer containing the marshalled string.
This pointer must be freed with |