This commit is contained in:
Emmanuel 2020-09-08 11:39:59 +00:00
parent 0d95997345
commit b999bbcfd5
4 changed files with 29 additions and 7 deletions

View file

@ -51,6 +51,8 @@ namespace OpenTK
[ToolboxItem(true)]
public class GLWidget : DrawingArea
{
private static bool xThreadInit;
/// <summary>
/// Get or set the OpenGL minimum color buffer bits.
/// </summary>

View file

@ -3,7 +3,7 @@
<TargetFramework>netcoreapp3.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>GLWigdet for GTKSharp, using Opentk.</Description>
<Version>1.0.3-pre1</Version>
<Version>1.0.3.2</Version>
<RepositoryUrl>https://github.com/Ryujinx/GLWidget</RepositoryUrl>
</PropertyGroup>
<ItemGroup>

View file

@ -30,7 +30,7 @@ namespace OpenTK
}
public static bool Loaded;
private static bool _threadsInitialized;
private const string GlxLibrary = "libGL.so.1";
private const string WglLibrary = "opengl32.dll";
private const string OSXLibrary = "libdl.dylib";
@ -210,6 +210,21 @@ namespace OpenTK
return symbol;
}
public static void InitXThreads()
{
if (_threadsInitialized)
{
return;
}
if (CurrentPlatform == OSPlatform.Linux)
{
_threadsInitialized = true;
UnsafeNativeMethods.XInitThreads();
}
}
internal static class UnsafeNativeMethods
{
[DllImport("kernel32.dll", SetLastError = true)]
@ -242,6 +257,9 @@ namespace OpenTK
[DllImport(OSXLibrary, EntryPoint = "NSAddressOfSymbol")]
public static extern IntPtr NSAddressOfSymbol(IntPtr symbol);
[DllImport("libX11.so.6")]
public extern static int XInitThreads();
[DllImport(OSXLibrary)]
public extern static int CGLSetCurrentContext(IntPtr ctx);

View file

@ -1,5 +1,6 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Gtk;
using OpenTK;
@ -9,6 +10,7 @@ namespace GLWidgetTestGTK3
{
public static void Main(string[] args)
{
GTKBindingHelper.InitXThreads();
// GTK
Application.Init();
MainWindow win = MainWindow.Create();