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,10 +51,12 @@ namespace OpenTK
[ToolboxItem(true)] [ToolboxItem(true)]
public class GLWidget : DrawingArea public class GLWidget : DrawingArea
{ {
/// <summary> private static bool xThreadInit;
/// Get or set the OpenGL minimum color buffer bits.
/// </summary> /// <summary>
[Property("color-bits")] /// Get or set the OpenGL minimum color buffer bits.
/// </summary>
[Property("color-bits")]
public uint ColorBits public uint ColorBits
{ {
get { return (_ColorBits); } get { return (_ColorBits); }
@ -194,7 +196,7 @@ namespace OpenTK
/// <summary>Constructs a new GLWidget</summary> /// <summary>Constructs a new GLWidget</summary>
public GLWidget(Version apiVersion, bool forwardCompatible) public GLWidget(Version apiVersion, bool forwardCompatible)
{ {
GLVersionMajor = apiVersion.Major; GLVersionMajor = apiVersion.Major;
GLVersionMinor = apiVersion.Minor; GLVersionMinor = apiVersion.Minor;
ForwardCompatible = forwardCompatible; ForwardCompatible = forwardCompatible;
} }

View file

@ -3,7 +3,7 @@
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>GLWigdet for GTKSharp, using Opentk.</Description> <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> <RepositoryUrl>https://github.com/Ryujinx/GLWidget</RepositoryUrl>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

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

View file

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