mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 15:35:34 +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
c689f50a21
commit
e54aadad22
|
@ -202,8 +202,16 @@ namespace OpenTK
|
||||||
public void CreateWindow(DisplayMode mode)
|
public void CreateWindow(DisplayMode mode)
|
||||||
{
|
{
|
||||||
if (!Exists)
|
if (!Exists)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
glWindow.CreateWindow(mode);
|
glWindow.CreateWindow(mode);
|
||||||
|
}
|
||||||
|
catch (ApplicationException expt)
|
||||||
|
{
|
||||||
|
Debug.Print(expt.ToString());
|
||||||
|
throw;
|
||||||
|
}
|
||||||
OpenTK.OpenGL.GL.LoadAll();
|
OpenTK.OpenGL.GL.LoadAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -98,8 +98,8 @@ visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, attrib);
|
||||||
visualAttributes.Add((int)mode.Color.Green);
|
visualAttributes.Add((int)mode.Color.Green);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.BLUE_SIZE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.BLUE_SIZE);
|
||||||
visualAttributes.Add((int)mode.Color.Blue);
|
visualAttributes.Add((int)mode.Color.Blue);
|
||||||
//visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
|
||||||
//visualAttributes.Add((int)mode.Color.Alpha);
|
visualAttributes.Add((int)mode.Color.Alpha);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
|
||||||
visualAttributes.Add((int)mode.DepthBits);
|
visualAttributes.Add((int)mode.DepthBits);
|
||||||
visualAttributes.Add((int)1);
|
visualAttributes.Add((int)1);
|
||||||
|
@ -161,7 +161,6 @@ visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, attrib);
|
||||||
|
|
||||||
public void SwapBuffers()
|
public void SwapBuffers()
|
||||||
{
|
{
|
||||||
Debug.Print("Swapping buffers");
|
|
||||||
Glx.SwapBuffers(windowInfo.Display, windowInfo.Handle);
|
Glx.SwapBuffers(windowInfo.Display, windowInfo.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
Functions.XNextEvent(window.Display, ref e);
|
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
|
// Respond to the event e
|
||||||
switch (e.type)
|
switch (e.type)
|
||||||
|
@ -118,6 +118,10 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case XEventName.KeyPress:
|
||||||
|
case XEventName.KeyRelease:
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Debug.WriteLine(String.Format("{0} event was not handled", e.type));
|
Debug.WriteLine(String.Format("{0} event was not handled", e.type));
|
||||||
break;
|
break;
|
||||||
|
@ -237,12 +241,8 @@ namespace OpenTK.Platform.X11
|
||||||
window.Screen = API.DefaultScreen(window.Display);
|
window.Screen = API.DefaultScreen(window.Display);
|
||||||
window.RootWindow = API.RootWindow(window.Display, window.Screen);
|
window.RootWindow = API.RootWindow(window.Display, window.Screen);
|
||||||
|
|
||||||
Debug.Print(
|
Debug.Print("Display: {0}, Screen {1}, Root window: {2}",
|
||||||
"Display: {0}, Screen {1}, Root window: {2}",
|
window.Display, window.Screen, window.RootWindow);
|
||||||
window.Display,
|
|
||||||
window.Screen,
|
|
||||||
window.RootWindow
|
|
||||||
);
|
|
||||||
|
|
||||||
glContext = new X11GLContext(mode);
|
glContext = new X11GLContext(mode);
|
||||||
glContext.PrepareContext(window);
|
glContext.PrepareContext(window);
|
||||||
|
@ -264,8 +264,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow,
|
window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow,
|
||||||
0, 0, mode.Width, mode.Height, 0, window.VisualInfo.depth/*(int)CreateWindowArgs.CopyFromParent*/,
|
0, 0, mode.Width, mode.Height, 0, window.VisualInfo.depth/*(int)CreateWindowArgs.CopyFromParent*/,
|
||||||
(int)CreateWindowArgs.InputOutput, window.VisualInfo.visual, (UIntPtr)mask,
|
(int)CreateWindowArgs.InputOutput, window.VisualInfo.visual, (UIntPtr)mask, ref attributes);
|
||||||
ref attributes);
|
|
||||||
|
|
||||||
if (window.Handle == IntPtr.Zero)
|
if (window.Handle == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
|
@ -297,10 +296,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
Debug.Print("done! (id: {0})", window.Handle);
|
Debug.Print("done! (id: {0})", window.Handle);
|
||||||
|
|
||||||
API.MapRaised(window.Display, window.Handle);
|
/*
|
||||||
|
|
||||||
/*Debug.WriteLine("Mapped window.");
|
|
||||||
|
|
||||||
XEvent ev = new XEvent();
|
XEvent ev = new XEvent();
|
||||||
API.IfEvent(window.Display, ref ev,
|
API.IfEvent(window.Display, ref ev,
|
||||||
delegate(IntPtr display, ref XEvent @event, IntPtr arg)
|
delegate(IntPtr display, ref XEvent @event, IntPtr arg)
|
||||||
|
@ -314,16 +310,16 @@ namespace OpenTK.Platform.X11
|
||||||
},
|
},
|
||||||
window.Handle);
|
window.Handle);
|
||||||
*/
|
*/
|
||||||
glContext.Mode = mode;//new DisplayMode(mode);
|
|
||||||
glContext.windowInfo.Handle = window.Handle;
|
glContext.windowInfo.Handle = window.Handle;
|
||||||
glContext.CreateContext(null, true);
|
glContext.CreateContext(null, true);
|
||||||
|
|
||||||
API.MapRaised(window.Display, window.Handle);
|
API.MapRaised(window.Display, window.Handle);
|
||||||
|
|
||||||
Debug.WriteLine("Mapped window.");
|
Debug.WriteLine("Mapped window.");
|
||||||
|
|
||||||
Debug.WriteLine("Our shiny new context is now current - ready to rock 'n' roll!");
|
glContext.MakeCurrent();
|
||||||
|
|
||||||
Debug.Unindent();
|
Debug.Unindent();
|
||||||
|
Debug.WriteLine("GameWindow creation completed successfully!");
|
||||||
exists = true;
|
exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue