Hilariously hacky version of netcore compatibility

This commit is contained in:
Varon 2020-11-12 14:19:29 +02:00
Родитель fa24a2f03a
Коммит ce42895cc1
25 изменённых файлов: 165 добавлений и 555 удалений

Просмотреть файл

@ -9,10 +9,6 @@ ProjectSection(SolutionItems) = preProject
paket.lock = paket.lock
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLWpfControl", "src\GLWpfControl\GLWpfControl.csproj", "{06F9FD53-C287-4275-8B98-4B891EA3ABDD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLWpfControlExample", "src\GLWpfControlExample\GLWpfControlExample.csproj", "{98F30B6C-37A6-4FF9-B9B7-C95E10FB39EC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{8A911F4A-8A01-4B86-959B-27CA1CDA2C1B}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
@ -20,19 +16,17 @@ ProjectSection(SolutionItems) = preProject
src\GLWpfControl\paket.template = src\GLWpfControl\paket.template
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLWpfControl", "src\GLWpfControl\GLWpfControl.csproj", "{E201C66F-F247-4E23-AB4D-0EB50005091D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{06F9FD53-C287-4275-8B98-4B891EA3ABDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06F9FD53-C287-4275-8B98-4B891EA3ABDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06F9FD53-C287-4275-8B98-4B891EA3ABDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06F9FD53-C287-4275-8B98-4B891EA3ABDD}.Release|Any CPU.Build.0 = Release|Any CPU
{98F30B6C-37A6-4FF9-B9B7-C95E10FB39EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98F30B6C-37A6-4FF9-B9B7-C95E10FB39EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98F30B6C-37A6-4FF9-B9B7-C95E10FB39EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98F30B6C-37A6-4FF9-B9B7-C95E10FB39EC}.Release|Any CPU.Build.0 = Release|Any CPU
{E201C66F-F247-4E23-AB4D-0EB50005091D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E201C66F-F247-4E23-AB4D-0EB50005091D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E201C66F-F247-4E23-AB4D-0EB50005091D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E201C66F-F247-4E23-AB4D-0EB50005091D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

Просмотреть файл

@ -1,7 +1,7 @@
<Application x:Class="GLWpfControlExample.App"
<Application x:Class="Example.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFControlTest"
xmlns:local="clr-namespace:Example"
StartupUri="MainWindow.xaml">
<Application.Resources>

14
src/Example/App.xaml.cs Normal file
Просмотреть файл

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Example {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application { }
}

Просмотреть файл

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

Просмотреть файл

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\src\GLWpfControl\GLWpfControl.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFControlTest"
xmlns:local="clr-namespace:GLWpfControlExample"
xmlns:glWpfControl="clr-namespace:OpenTK.Wpf;assembly=GLWpfControl"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">

Просмотреть файл

@ -5,6 +5,7 @@ using OpenTK.Wpf;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Mathematics;
namespace GLWpfControlExample {
/// <summary>

Просмотреть файл

@ -4,8 +4,9 @@ using System.Threading;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using OpenTK.Graphics;
using OpenTK.Platform;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using Window = System.Windows.Window;
namespace OpenTK.Wpf
{
@ -16,13 +17,6 @@ namespace OpenTK.Wpf
/// </summary>
public sealed class GLWpfControl : FrameworkElement
{
static GLWpfControl()
{
Toolkit.Init(new ToolkitOptions
{
Backend = PlatformBackend.PreferNative
});
}
private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
private TimeSpan _lastFrameStamp;
@ -32,7 +26,6 @@ namespace OpenTK.Wpf
private static IGraphicsContext _commonContext;
private static int _activeControlCount = 0;
private IGraphicsContext _context;
private IWindowInfo _windowInfo;
private bool _hasSyncFenceAvailable;
private volatile bool _needsRedraw = true;
@ -64,6 +57,8 @@ namespace OpenTK.Wpf
private Rect _imageRectangle;
private TranslateTransform _translateTransform;
private ScaleTransform _flipYTransform;
private NativeWindow _glfwWindow;
/// The OpenGL Framebuffer Object used internally by this component.
/// Bind to this instead of the default framebuffer when using this component along with other FrameBuffers for the final pass.
public int Framebuffer => _renderer?.FrameBuffer ?? 0;
@ -132,19 +127,27 @@ namespace OpenTK.Wpf
private void InitOpenGLContext() {
if (_commonContext == null) {
var nws = NativeWindowSettings.Default;
nws.StartFocused = false;
nws.StartVisible = false;
nws.NumberOfSamples = 0;
nws.APIVersion = new Version(3,2);
nws.Profile = ContextProfile.Compatability;
_glfwWindow = new NativeWindow(nws) {IsVisible = false};
// retrieve window handle/info
var window = Window.GetWindow(this);
var baseHandle = window is null ? IntPtr.Zero : new WindowInteropHelper(window).Handle;
_hwnd = new HwndSource(0, 0, 0, 0, 0, "GLWpfControl", baseHandle);
_windowInfo = Utilities.CreateWindowsWindowInfo(_hwnd.Handle);
_commonContext = _glfwWindow.Context;
// GL init
var mode = new GraphicsMode(ColorFormat.Empty, 0, 0, 0, 0, 0, false);
_commonContext = new GraphicsContext(mode, _windowInfo, _settings.MajorVersion, _settings.MinorVersion,
_settings.GraphicsContextFlags);
_commonContext.LoadAll();
_commonContext.MakeCurrent(_windowInfo);
// var mode = new GraphicsMode(ColorFormat.Empty, 0, 0, 0, 0, 0, false);
// _commonContext = new GraphicsContext(mode, _windowInfo, _settings.MajorVersion, _settings.MinorVersion,
// _settings.GraphicsContextFlags);
// _commonContext.LoadAll();
_commonContext.MakeCurrent();
}
_context = _commonContext;
Interlocked.Increment(ref _activeControlCount);
@ -158,7 +161,7 @@ namespace OpenTK.Wpf
}
ReleaseOpenGLResources();
_windowInfo?.Dispose();
_glfwWindow?.Dispose();
_hwnd?.Dispose();
}
@ -220,7 +223,7 @@ namespace OpenTK.Wpf
_context = null;
var newCount = Interlocked.Decrement(ref _activeControlCount);
if (newCount == 0) {
_commonContext?.Dispose();
_glfwWindow?.Dispose();
}
}
}

Просмотреть файл

@ -1,91 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{06F9FD53-C287-4275-8B98-4B891EA3ABDD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenTK.Wpf</RootNamespace>
<AssemblyName>GLWpfControl</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Content Include="OpenTK.dll.config">
<Paket>True</Paket>
</Content>
<Compile Include="DXInterop.cs" />
<Compile Include="GLWpfControl.cs" />
<Compile Include="GLWpfControlRendererDX.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GLWpfControlSettings.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenTK" Version="3.3.1" />
<PackageReference Include="SharpDX" Version="4.2.0" />
<PackageReference Include="SharpDX.Direct3D9" Version="4.2.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.2'">
<ItemGroup>
<Reference Include="OpenTK">
<HintPath>..\..\packages\OpenTK\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.2'">
<ItemGroup>
<Reference Include="SharpDX">
<HintPath>..\..\packages\SharpDX\lib\net45\SharpDX.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.2'">
<ItemGroup>
<Reference Include="SharpDX.Direct3D9">
<HintPath>..\..\packages\SharpDX.Direct3D9\lib\net45\SharpDX.Direct3D9.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OpenTK" Version="4.1.0" />
<PackageReference Include="SharpDX.Direct3D9" Version="4.2.0" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,8 +1,8 @@
using System;
using System.Windows;
using System.Windows.Interop;
using GLWpfControl;
using OpenTK.Graphics.OpenGL;
using OpenTK.Platform.Windows;
using SharpDX.Direct3D9;
namespace OpenTK.Wpf {
@ -19,6 +19,8 @@ namespace OpenTK.Wpf {
private readonly Device _dxDevice;
private readonly Surface _dxSurface;
private readonly D3DImage _image;
private readonly WGLInterop _wglInterop;
private readonly bool _hasSyncFenceAvailable;
private IntPtr _syncFence;
@ -26,6 +28,7 @@ namespace OpenTK.Wpf {
public int FrameBuffer => _glFrameBuffer;
public GLWpfControlRendererDx(int width, int height, D3DImage imageControl, bool hasSyncFenceAvailable) {
_wglInterop = new WGLInterop();
_hasSyncFenceAvailable = hasSyncFenceAvailable;
@ -66,15 +69,15 @@ namespace OpenTK.Wpf {
_glFrameBuffer = GL.GenFramebuffer();
_glSharedTexture = GL.GenTexture();
_glHandle = Wgl.DXOpenDeviceNV(_dxDevice.NativePointer);
Wgl.DXSetResourceShareHandleNV(_dxSurface.NativePointer, _dxSharedhandle);
_glHandle = _wglInterop.WglDXOpenDeviceNV(_dxDevice.NativePointer);
_wglInterop.WglDXSetResourceShareHandleNV(_dxSurface.NativePointer, _dxSharedhandle);
var genHandle = Wgl.DXRegisterObjectNV(
var genHandle = _wglInterop.WglDXRegisterObjectNV(
_glHandle,
_dxSurface.NativePointer,
(uint)_glSharedTexture,
(uint)TextureTarget.Texture2D,
WGL_NV_DX_interop.AccessReadWrite);
WGLInterop.WGL_ACCESS_READ_WRITE_NV);
_glDxInteropSharedHandles = new[] { genHandle };
GL.BindFramebuffer(FramebufferTarget.Framebuffer, _glFrameBuffer);
@ -121,7 +124,7 @@ namespace OpenTK.Wpf {
// }
//
GL.Flush();
Wgl.DXUnlockObjectsNV(_glHandle, 1, _glDxInteropSharedHandles);
_wglInterop.WglDXUnlockObjectsNV(_glHandle, 1, _glDxInteropSharedHandles);
_image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, _dxSurface.NativePointer);
_image.AddDirtyRect(new Int32Rect(0, 0, _image.PixelWidth, _image.PixelHeight));
_image.Unlock();
@ -130,7 +133,7 @@ namespace OpenTK.Wpf {
public void PreRender()
{
_image.Lock();
Wgl.DXLockObjectsNV(_glHandle, 1, _glDxInteropSharedHandles);
_wglInterop.WglDXLockObjectsNV(_glHandle, 1, _glDxInteropSharedHandles);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, _glFrameBuffer);
GL.Viewport(0, 0, _image.PixelWidth, _image.PixelHeight);
}

Просмотреть файл

@ -1,4 +1,5 @@
using OpenTK.Graphics;
using OpenTK.Windowing.Common;
namespace OpenTK.Wpf {
@ -6,9 +7,9 @@ namespace OpenTK.Wpf {
/// May be null. If defined, an external context will be used, of which the caller is responsible
/// for managing the lifetime and disposal of.
public GraphicsContext ContextToUse { get; set; }
public IGraphicsContext ContextToUse { get; set; }
public GraphicsContextFlags GraphicsContextFlags { get; set; } = GraphicsContextFlags.Default;
public ContextFlags GraphicsContextFlags { get; set; } = ContextFlags.Default;
public int MajorVersion { get; set; } = 3;
public int MinorVersion { get; set; } = 3;

Просмотреть файл

@ -1,25 +0,0 @@
<configuration>
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
<!-- XQuartz compatibility (X11 on Mac) -->
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
</configuration>

Просмотреть файл

@ -1,22 +0,0 @@
// <auto-generated/>
using System;
using System.Reflection;
[assembly: AssemblyTitleAttribute("GLWpfControl")]
[assembly: AssemblyProductAttribute("OpenTK.GLWpfControl")]
[assembly: AssemblyDescriptionAttribute("A native WPF control for OpenTK 3.X.")]
[assembly: AssemblyVersionAttribute("3.1.0")]
[assembly: AssemblyFileVersionAttribute("3.1.0")]
[assembly: CLSCompliantAttribute(true)]
[assembly: AssemblyCopyrightAttribute("Copyright (c) 2019 Team OpenTK.")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "GLWpfControl";
internal const System.String AssemblyProduct = "OpenTK.GLWpfControl";
internal const System.String AssemblyDescription = "A native WPF control for OpenTK 3.X.";
internal const System.String AssemblyVersion = "3.1.0";
internal const System.String AssemblyFileVersion = "3.1.0";
internal const System.Boolean CLSCompliant = true;
internal const System.String AssemblyCopyright = "Copyright (c) 2019 Team OpenTK.";
}
}

Просмотреть файл

@ -0,0 +1,72 @@
using System;
using System.Runtime.InteropServices;
namespace GLWpfControl
{
internal sealed class WGLInterop
{
[DllImport("OPENGL32.dll", EntryPoint = "wglGetProcAddress", ExactSpelling = true, SetLastError = true)]
internal extern static IntPtr GetProcAddress(string lpszProc);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
internal delegate bool wglDXSetResourceShareHandleNV(IntPtr dxObject, IntPtr shareHandle);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
internal delegate IntPtr wglDXOpenDeviceNV(IntPtr dxDevice);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
internal delegate bool wglDXCloseDeviceNV(IntPtr hDevice);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
internal delegate IntPtr wglDXRegisterObjectNV(IntPtr hDevice, IntPtr dxObject, uint name, uint typeEnum, uint accessEnum);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
internal delegate bool wglDXUnregisterObjectNV(IntPtr hDevice, IntPtr hObject);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
internal delegate bool wglDXObjectAccessNV(IntPtr hObject, uint accessEnum);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
internal delegate bool wglDXLockObjectsNV(IntPtr hDevice, int count, IntPtr[] hObjectsPtr);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
internal delegate bool wglDXUnlockObjectsNV(IntPtr hDevice, int count, IntPtr[] hObjectsPtr);
internal const uint WGL_ACCESS_READ_ONLY_NV = 0x0000;
internal const uint WGL_ACCESS_READ_WRITE_NV = 0x0001;
internal const uint WGL_ACCESS_WRITE_DISCARD_NV = 0x0002;
internal wglDXCloseDeviceNV WglDXCloseDeviceNV;
internal wglDXLockObjectsNV WglDXLockObjectsNV;
internal wglDXObjectAccessNV WglDXObjectAccessNV;
internal wglDXOpenDeviceNV WglDXOpenDeviceNV;
internal wglDXRegisterObjectNV WglDXRegisterObjectNV;
internal wglDXSetResourceShareHandleNV WglDXSetResourceShareHandleNV;
internal wglDXUnlockObjectsNV WglDXUnlockObjectsNV;
internal wglDXUnregisterObjectNV WglDXUnregisterObjectNV;
internal WGLInterop()
{
WglDXCloseDeviceNV = Assign<wglDXCloseDeviceNV>();
WglDXLockObjectsNV = Assign<wglDXLockObjectsNV>();
WglDXObjectAccessNV = Assign<wglDXObjectAccessNV>();
WglDXOpenDeviceNV = Assign<wglDXOpenDeviceNV>();
WglDXRegisterObjectNV = Assign<wglDXRegisterObjectNV>();
WglDXSetResourceShareHandleNV = Assign<wglDXSetResourceShareHandleNV>();
WglDXUnlockObjectsNV = Assign<wglDXUnlockObjectsNV>();
WglDXUnregisterObjectNV = Assign<wglDXUnregisterObjectNV>();
}
private bool IsValid(IntPtr address)
{
// See https://www.opengl.org/wiki/Load_OpenGL_Functions
long a = address.ToInt64();
bool is_valid = (a < -1) || (a > 3);
return is_valid;
}
private T Assign<T>()
{
var name = typeof(T).Name;
var address = GetProcAddress(name);
if(address != IntPtr.Zero && IsValid(address))
return Marshal.GetDelegateForFunctionPointer<T>(address);
throw new NotSupportedException();
}
}
}

Просмотреть файл

@ -1,2 +0,0 @@
OpenTK
SharpDX.Direct3D9

Просмотреть файл

@ -1,26 +0,0 @@
type project
title
OpenTK.GLWpfControl
id
OpenTK.GLWpfControl
owners
opentk varon
authors
Team OpenTK
summary
A native WPF control for OpenTK 3.X.
projectUrl
https://www.opentk.net
iconUrl
https://raw.githubusercontent.com/opentk/opentk.net/docfx/assets/opentk.png
licenseUrl
https://github.com/varon/GLWpfControl/blob/master/LICENSE.md
requireLicenseAcceptance
false
copyright
Copyright (c) 2019 Team OpenTK.
dependencies
OpenTK >= 3.3.1 < 4.0.0
SharpDX.Direct3D9 ~> 4.2.0
include-pdbs true

Просмотреть файл

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

Просмотреть файл

@ -1,6 +0,0 @@
namespace GLWpfControlExample {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App { }
}

Просмотреть файл

@ -1,109 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{98F30B6C-37A6-4FF9-B9B7-C95E10FB39EC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>GLWpfControlExample</RootNamespace>
<AssemblyName>GLWpfControlExample</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GLWpfControl\GLWpfControl.csproj">
<Project>{06f9fd53-c287-4275-8b98-4b891ea3abdd}</Project>
<Name>GLWpfControl</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="OpenTK.dll.config">
<Paket>True</Paket>
</Content>
<Content Include="paket.references" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.2'">
<ItemGroup>
<Reference Include="OpenTK">
<HintPath>..\..\packages\OpenTK\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>

Просмотреть файл

@ -1,25 +0,0 @@
<configuration>
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
<!-- XQuartz compatibility (X11 on Mac) -->
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
</configuration>

Просмотреть файл

@ -1,22 +0,0 @@
// <auto-generated/>
using System;
using System.Reflection;
[assembly: AssemblyTitleAttribute("GLWpfControlExample")]
[assembly: AssemblyProductAttribute("OpenTK.GLWpfControl")]
[assembly: AssemblyDescriptionAttribute("A native WPF control for OpenTK 3.X.")]
[assembly: AssemblyVersionAttribute("3.1.0")]
[assembly: AssemblyFileVersionAttribute("3.1.0")]
[assembly: CLSCompliantAttribute(true)]
[assembly: AssemblyCopyrightAttribute("Copyright (c) 2019 Team OpenTK.")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "GLWpfControlExample";
internal const System.String AssemblyProduct = "OpenTK.GLWpfControl";
internal const System.String AssemblyDescription = "A native WPF control for OpenTK 3.X.";
internal const System.String AssemblyVersion = "3.1.0";
internal const System.String AssemblyFileVersion = "3.1.0";
internal const System.Boolean CLSCompliant = true;
internal const System.String AssemblyCopyright = "Copyright (c) 2019 Team OpenTK.";
}
}

Просмотреть файл

@ -1,57 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WPFControlTest.Properties {
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() { }
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get
{
if ((resourceMan == null)) {
global::System.Resources.ResourceManager temp =
new global::System.Resources.ResourceManager("GLWpfControlExample.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get { return resourceCulture; }
set { resourceCulture = value; }
}
}
}

Просмотреть файл

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

Просмотреть файл

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenTK" version="3.3.1" targetFramework="net452" />
</packages>

Просмотреть файл

@ -1 +0,0 @@
OpenTK