Improved exception handling in GameWindow

X11GLContext now requests formats with alpha channels. Removed debug output from X11 SwapBuffers.
Corrected X11GLNative window creation (context is now made current). Beautified X11GLNative.cs
This commit is contained in:
the_fiddler 2007-08-20 13:47:14 +00:00
parent c689f50a21
commit e54aadad22
3 changed files with 23 additions and 20 deletions

View file

@ -202,8 +202,16 @@ namespace OpenTK
public void CreateWindow(DisplayMode mode)
{
if (!Exists)
{
try
{
glWindow.CreateWindow(mode);
}
catch (ApplicationException expt)
{
Debug.Print(expt.ToString());
throw;
}
OpenTK.OpenGL.GL.LoadAll();
}
else

View file

@ -98,8 +98,8 @@ visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, attrib);
visualAttributes.Add((int)mode.Color.Green);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.BLUE_SIZE);
visualAttributes.Add((int)mode.Color.Blue);
//visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
//visualAttributes.Add((int)mode.Color.Alpha);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
visualAttributes.Add((int)mode.Color.Alpha);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
visualAttributes.Add((int)mode.DepthBits);
visualAttributes.Add((int)1);
@ -161,7 +161,6 @@ visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, attrib);
public void SwapBuffers()
{
Debug.Print("Swapping buffers");
Glx.SwapBuffers(windowInfo.Display, windowInfo.Handle);
}

View file

@ -76,7 +76,7 @@ namespace OpenTK.Platform.X11
Functions.XNextEvent(window.Display, ref e);
Debug.WriteLine(String.Format("Event: {0} ({1} pending)", e.type, pending));
Debug.Print("Event: {0} ({1} pending)", e.type, pending);
// Respond to the event e
switch (e.type)
@ -118,6 +118,10 @@ namespace OpenTK.Platform.X11
}
break;
case XEventName.KeyPress:
case XEventName.KeyRelease:
return;
default:
Debug.WriteLine(String.Format("{0} event was not handled", e.type));
break;
@ -237,12 +241,8 @@ namespace OpenTK.Platform.X11
window.Screen = API.DefaultScreen(window.Display);
window.RootWindow = API.RootWindow(window.Display, window.Screen);
Debug.Print(
"Display: {0}, Screen {1}, Root window: {2}",
window.Display,
window.Screen,
window.RootWindow
);
Debug.Print("Display: {0}, Screen {1}, Root window: {2}",
window.Display, window.Screen, window.RootWindow);
glContext = new X11GLContext(mode);
glContext.PrepareContext(window);
@ -264,8 +264,7 @@ namespace OpenTK.Platform.X11
window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow,
0, 0, mode.Width, mode.Height, 0, window.VisualInfo.depth/*(int)CreateWindowArgs.CopyFromParent*/,
(int)CreateWindowArgs.InputOutput, window.VisualInfo.visual, (UIntPtr)mask,
ref attributes);
(int)CreateWindowArgs.InputOutput, window.VisualInfo.visual, (UIntPtr)mask, ref attributes);
if (window.Handle == IntPtr.Zero)
{
@ -297,10 +296,7 @@ namespace OpenTK.Platform.X11
Debug.Print("done! (id: {0})", window.Handle);
API.MapRaised(window.Display, window.Handle);
/*Debug.WriteLine("Mapped window.");
/*
XEvent ev = new XEvent();
API.IfEvent(window.Display, ref ev,
delegate(IntPtr display, ref XEvent @event, IntPtr arg)
@ -314,16 +310,16 @@ namespace OpenTK.Platform.X11
},
window.Handle);
*/
glContext.Mode = mode;//new DisplayMode(mode);
glContext.windowInfo.Handle = window.Handle;
glContext.CreateContext(null, true);
API.MapRaised(window.Display, window.Handle);
Debug.WriteLine("Mapped window.");
Debug.WriteLine("Our shiny new context is now current - ready to rock 'n' roll!");
glContext.MakeCurrent();
Debug.Unindent();
Debug.WriteLine("GameWindow creation completed successfully!");
exists = true;
}
}