Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/OpenGL/Silk.NET.WGL/WGL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ public bool TryGetExtension<T>(out T ext, nint hdc)

public override bool IsExtensionPresent(string extension) => IsExtensionPresent(extension, GetCurrentDC());

private ConcurrentDictionary<nint, HashSet<string>> _extensions;
private readonly ConcurrentDictionary<nint, HashSet<string>> _extensions = new();

[NativeApi(EntryPoint = "wglGetExtensionsStringARB")]
private partial string GetExtensionsString(nint hdc);

private static HashSet<string>? _empty;
private static readonly HashSet<string> _empty = new();
private bool _hasGetExtensionsString;

public bool IsExtensionPresent(string extension, nint hdc) => _extensions.GetOrAdd
(
hdc, hdc => !(_hasGetExtensionsString =
_hasGetExtensionsString || GetProcAddress("wglGetExtensionsStringARB") != 0)
? _empty ??= new HashSet<string>()
: new HashSet<string>(GetExtensionsString(hdc).Split(' '))
? _empty
: new HashSet<string>(GetExtensionsString(hdc).Split(' '))
)
.Contains(extension.StartsWith("WGL_") ? extension : $"WGL_{extension}");
}
Expand Down
Loading