Skip to content

Commit

Permalink
Implement Context GetFunction & IsExtensionAvailable
Browse files Browse the repository at this point in the history
  • Loading branch information
Marioalexsan committed Feb 19, 2024
1 parent 1c215f0 commit 8bfdda1
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/SFML.Window/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,42 @@ public Context()
sfContext_destroy(myThis);
}

////////////////////////////////////////////////////////////
/// <summary>
/// Check whether a given OpenGL extension is available.
/// </summary>
/// <param name="name">Name of the extension to check for</param>
/// <returns>True if available, false if unavailable</returns>
////////////////////////////////////////////////////////////
public bool IsExtensionAvailable(string name)
{
return sfContext_isExtensionAvailable(myThis, name);
}

////////////////////////////////////////////////////////////
/// <summary>
/// Activate or deactivate the context
/// </summary>
/// <param name="active">True to activate, false to deactivate</param>
/// <returns>true on success, false on failure</returns>
/// <returns>True on success, false on failure</returns>
////////////////////////////////////////////////////////////
public bool SetActive(bool active)
{
return sfContext_setActive(myThis, active);
}

////////////////////////////////////////////////////////////
/// <summary>
/// Get the address of an OpenGL function.
/// </summary>
/// <param name="name">Name of the function to get the address of</param>
/// <returns>Address of the OpenGL function, <see cref="IntPtr.Zero"/> on failure</returns>
////////////////////////////////////////////////////////////
public IntPtr GetFunction(string name)
{
return sfContext_getFunction(myThis, name);
}

////////////////////////////////////////////////////////////
/// <summary>
/// Get the settings of the context.
Expand Down Expand Up @@ -95,9 +119,15 @@ public override string ToString()
[DllImport(CSFML.window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
private static extern void sfContext_destroy(IntPtr View);

[DllImport(CSFML.window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
private static extern bool sfContext_isExtensionAvailable(IntPtr View, string name);

[DllImport(CSFML.window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
private static extern bool sfContext_setActive(IntPtr View, bool Active);

[DllImport(CSFML.window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
private static extern IntPtr sfContext_getFunction(IntPtr View, string name);

[DllImport(CSFML.window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
private static extern ContextSettings sfContext_getSettings(IntPtr View);
#endregion
Expand Down

0 comments on commit 8bfdda1

Please sign in to comment.