mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-10 16:55:31 +00:00
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:
parent
33527aa2c9
commit
3b5d61a337
|
@ -203,7 +203,15 @@ namespace OpenTK
|
|||
{
|
||||
if (!Exists)
|
||||
{
|
||||
glWindow.CreateWindow(mode);
|
||||
try
|
||||
{
|
||||
glWindow.CreateWindow(mode);
|
||||
}
|
||||
catch (ApplicationException expt)
|
||||
{
|
||||
Debug.Print(expt.ToString());
|
||||
throw;
|
||||
}
|
||||
OpenTK.OpenGL.GL.LoadAll();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue