Clean up OpenTK after every example
Use the IDisposable instance returned by OpenTK.Toolkit.Init() to shutdown OpenTK after the end of each example run.
This commit is contained in:
parent
a85cecdc59
commit
019f466130
2 changed files with 19 additions and 4 deletions
|
@ -425,7 +425,10 @@ namespace Examples
|
||||||
Trace.Listeners.Add(dbg);
|
Trace.Listeners.Add(dbg);
|
||||||
Trace.Listeners.Add(new ConsoleTraceListener());
|
Trace.Listeners.Add(new ConsoleTraceListener());
|
||||||
|
|
||||||
_main.Invoke(null, null);
|
using (OpenTK.Toolkit.Init())
|
||||||
|
{
|
||||||
|
_main.Invoke(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
dbg.Flush();
|
dbg.Flush();
|
||||||
dbg.Close();
|
dbg.Close();
|
||||||
|
|
|
@ -37,14 +37,26 @@ namespace Examples
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
|
static void EnableOpenTKHack()
|
||||||
|
{
|
||||||
|
// If OpenTK is not initialized before Windows.Forms,
|
||||||
|
// the program will crash on Mac OS X. This hack will
|
||||||
|
// enable OpenTK in a temporary AppDomain before entering
|
||||||
|
// the main program - this appears to be enough.
|
||||||
|
var domain = AppDomain.CreateDomain("sandbox");
|
||||||
|
domain.DoCallBack(() => {
|
||||||
|
using (OpenTK.Toolkit.Init())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// This seems to be useful enough to leave in for a while.
|
EnableOpenTKHack();
|
||||||
TextWriterTraceListener console = new TextWriterTraceListener(System.Console.Out);
|
|
||||||
Trace.Listeners.Add (console);
|
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
Loading…
Reference in a new issue