Corrected what might be the cause of the NRE on X11GLNative.
This commit is contained in:
parent
387f455078
commit
998243f669
2 changed files with 20 additions and 27 deletions
|
@ -24,11 +24,6 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
private X11GLContext glContext;
|
private X11GLContext glContext;
|
||||||
private WindowInfo info = new WindowInfo();
|
private WindowInfo info = new WindowInfo();
|
||||||
private IntPtr display;
|
|
||||||
private int screen;
|
|
||||||
private IntPtr rootWindow;
|
|
||||||
private IntPtr window;
|
|
||||||
|
|
||||||
private DisplayMode mode = new DisplayMode();
|
private DisplayMode mode = new DisplayMode();
|
||||||
|
|
||||||
// Number of pending events.
|
// Number of pending events.
|
||||||
|
@ -88,13 +83,13 @@ namespace OpenTK.Platform.X11
|
||||||
Debug.Print("Creating native window with mode: {0}", mode.ToString());
|
Debug.Print("Creating native window with mode: {0}", mode.ToString());
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
|
||||||
info.Display = display = API.OpenDisplay(null); // null == default display
|
info.Display = API.OpenDisplay(null); // null == default display
|
||||||
if (display == IntPtr.Zero)
|
if (info.Display == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception("Could not open connection to X");
|
throw new Exception("Could not open connection to X");
|
||||||
}
|
}
|
||||||
info.Screen = screen = API.DefaultScreen(display);
|
info.Screen = API.DefaultScreen(info.Display);
|
||||||
info.RootWindow = rootWindow = API.RootWindow(display, screen);
|
info.RootWindow = API.RootWindow(info.Display, info.Screen);
|
||||||
|
|
||||||
Debug.Print(
|
Debug.Print(
|
||||||
"Display: {0}, Screen {1}, Root window: {2}",
|
"Display: {0}, Screen {1}, Root window: {2}",
|
||||||
|
@ -125,7 +120,7 @@ namespace OpenTK.Platform.X11
|
||||||
CreateWindowMask.CWColormap |
|
CreateWindowMask.CWColormap |
|
||||||
CreateWindowMask.CWEventMask;
|
CreateWindowMask.CWEventMask;
|
||||||
|
|
||||||
window = API.CreateWindow(
|
info.Handle = API.CreateWindow(
|
||||||
info.Display,
|
info.Display,
|
||||||
info.RootWindow,
|
info.RootWindow,
|
||||||
0, 0,
|
0, 0,
|
||||||
|
@ -140,12 +135,12 @@ namespace OpenTK.Platform.X11
|
||||||
wnd_attributes
|
wnd_attributes
|
||||||
);
|
);
|
||||||
|
|
||||||
if (window == IntPtr.Zero)
|
if (info.Handle == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception("Could not create window.");
|
throw new Exception("Could not create window.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.WriteLine("done! (id: " + window + ")");
|
Debug.WriteLine("done! (id: " + info.Handle + ")");
|
||||||
|
|
||||||
// Set the window hints
|
// Set the window hints
|
||||||
/*
|
/*
|
||||||
|
@ -171,10 +166,10 @@ namespace OpenTK.Platform.X11
|
||||||
//glContext.ContainingWindow = info.Window;
|
//glContext.ContainingWindow = info.Window;
|
||||||
|
|
||||||
|
|
||||||
glContext.windowInfo.Handle = window;
|
glContext.windowInfo.Handle = info.Handle;
|
||||||
glContext.CreateContext(null, true);
|
glContext.CreateContext(null, true);
|
||||||
|
|
||||||
API.MapRaised(display, window);
|
API.MapRaised(info.Display, info.Handle);
|
||||||
|
|
||||||
Debug.WriteLine("Mapped window.");
|
Debug.WriteLine("Mapped window.");
|
||||||
|
|
||||||
|
@ -209,14 +204,14 @@ namespace OpenTK.Platform.X11
|
||||||
// Process all pending events
|
// Process all pending events
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
pending = API.Pending(display);
|
pending = API.Pending(info.Display);
|
||||||
|
|
||||||
if (pending == 0)
|
if (pending == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//API.NextEvent(display, e);
|
//API.NextEvent(info.Display, e);
|
||||||
API.PeekEvent(display, e);
|
API.PeekEvent(info.Display, e);
|
||||||
//API.NextEvent(display, eventPtr);
|
//API.NextEvent(info.Display, eventPtr);
|
||||||
|
|
||||||
|
|
||||||
Debug.WriteLine(String.Format("Event: {0} ({1} pending)", e.Type, pending));
|
Debug.WriteLine(String.Format("Event: {0} ({1} pending)", e.Type, pending));
|
||||||
|
@ -230,12 +225,12 @@ namespace OpenTK.Platform.X11
|
||||||
switch (e.Type)
|
switch (e.Type)
|
||||||
{
|
{
|
||||||
case EventType.ReparentNotify:
|
case EventType.ReparentNotify:
|
||||||
API.NextEvent(display, reparent);
|
API.NextEvent(info.Display, reparent);
|
||||||
// Do nothing
|
// Do nothing
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EventType.CreateNotify:
|
case EventType.CreateNotify:
|
||||||
API.NextEvent(display, createWindow);
|
API.NextEvent(info.Display, createWindow);
|
||||||
|
|
||||||
// Set window width/height
|
// Set window width/height
|
||||||
mode.Width = createWindow.width;
|
mode.Width = createWindow.width;
|
||||||
|
@ -247,14 +242,14 @@ namespace OpenTK.Platform.X11
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EventType.DestroyNotify:
|
case EventType.DestroyNotify:
|
||||||
API.NextEvent(display, destroyWindow);
|
API.NextEvent(info.Display, destroyWindow);
|
||||||
quit = true;
|
quit = true;
|
||||||
Debug.WriteLine("Window destroyed, shutting down.");
|
Debug.WriteLine("Window destroyed, shutting down.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case EventType.ConfigureNotify:
|
case EventType.ConfigureNotify:
|
||||||
API.NextEvent(display, configure);
|
API.NextEvent(info.Display, configure);
|
||||||
|
|
||||||
// If the window size changed, raise the C# Resize event.
|
// If the window size changed, raise the C# Resize event.
|
||||||
if (configure.width != mode.Width ||
|
if (configure.width != mode.Width ||
|
||||||
|
@ -275,7 +270,7 @@ namespace OpenTK.Platform.X11
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
API.NextEvent(display, e);
|
API.NextEvent(info.Display, e);
|
||||||
Debug.WriteLine(String.Format("{0} event was not handled", e.Type));
|
Debug.WriteLine(String.Format("{0} event was not handled", e.Type));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +358,7 @@ namespace OpenTK.Platform.X11
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IntPtr Handle
|
public IntPtr Handle
|
||||||
{
|
{
|
||||||
get { return this.window; }
|
get { return this.info.Handle; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -469,7 +464,7 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
API.DestroyWindow(display, window);
|
API.DestroyWindow(info.Display, info.Handle);
|
||||||
// Kills connection to the X-Server. We don't want that,
|
// Kills connection to the X-Server. We don't want that,
|
||||||
// 'cause it kills the ExampleLauncher too.
|
// 'cause it kills the ExampleLauncher too.
|
||||||
//API.CloseDisplay(display);
|
//API.CloseDisplay(display);
|
||||||
|
|
|
@ -32,8 +32,6 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
IntPtr[] keysyms;
|
IntPtr[] keysyms;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static bool keymapExists;
|
private static bool keymapExists;
|
||||||
|
|
||||||
#region private static void Initialize()
|
#region private static void Initialize()
|
||||||
|
|
Loading…
Reference in a new issue