Move OpenTK configuration to dedicated static ctor
This commit is contained in:
parent
f38c75f06d
commit
60022ab146
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
using OpenTK;
|
||||
|
||||
namespace BizHawk.Bizware.BizwareGL
|
||||
{
|
||||
public static class OpenTKConfigurator
|
||||
{
|
||||
static OpenTKConfigurator()
|
||||
{
|
||||
// make sure OpenTK initializes without getting wrecked on the SDL check and throwing an exception to annoy our MDA's
|
||||
var toolkitOptions = ToolkitOptions.Default;
|
||||
toolkitOptions.Backend = PlatformBackend.PreferNative;
|
||||
Toolkit.Init(toolkitOptions);
|
||||
// NOTE: this throws EGL exceptions anyway. I'm going to ignore it and whine about it later
|
||||
// still seeing the exception in VS as of 2.5.3 dev... --yoshi
|
||||
}
|
||||
|
||||
/// <summary>no-op; this class' static ctor is guaranteed to be called exactly once if this is called at least once</summary>
|
||||
public static void EnsureConfigurated() {}
|
||||
}
|
||||
}
|
|
@ -38,6 +38,8 @@ namespace BizHawk.Bizware.DirectX
|
|||
_d3d = new Direct3D();
|
||||
}
|
||||
|
||||
OpenTKConfigurator.EnsureConfigurated();
|
||||
|
||||
// make an 'offscreen context' so we can at least do things without having to create a window
|
||||
_offscreenNativeWindow = new NativeWindow { ClientSize = new Size(8, 8) };
|
||||
|
||||
|
|
|
@ -34,15 +34,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
private Pipeline _currPipeline;
|
||||
private RenderTarget _currRenderTarget;
|
||||
|
||||
static IGL_TK()
|
||||
{
|
||||
//make sure OpenTK initializes without getting wrecked on the SDL check and throwing an exception to annoy our MDA's
|
||||
var toolkitOptions = global::OpenTK.ToolkitOptions.Default;
|
||||
toolkitOptions.Backend = PlatformBackend.PreferNative;
|
||||
global::OpenTK.Toolkit.Init(toolkitOptions);
|
||||
//NOTE: this throws EGL exceptions anyway. I'm going to ignore it and whine about it later
|
||||
}
|
||||
|
||||
public string API => "OPENGL";
|
||||
|
||||
public int Version
|
||||
|
@ -66,6 +57,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public IGL_TK(int majorVersion, int minorVersion, bool forwardCompatible)
|
||||
{
|
||||
OpenTKConfigurator.EnsureConfigurated();
|
||||
|
||||
//make an 'offscreen context' so we can at least do things without having to create a window
|
||||
OffscreenNativeWindow = new NativeWindow { ClientSize = new sd.Size(8, 8) };
|
||||
GraphicsContext = new GraphicsContext(GraphicsMode.Default, OffscreenNativeWindow.WindowInfo, majorVersion, minorVersion, forwardCompatible ? GraphicsContextFlags.ForwardCompatible : GraphicsContextFlags.Default);
|
||||
|
|
Loading…
Reference in New Issue