mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-10 21:25:42 +00:00
Corrected usages of tabs instead of spaces.
This commit is contained in:
parent
13494f515c
commit
9309889a1a
|
@ -9,30 +9,30 @@ namespace OpenTK.OSX
|
||||||
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the OSX platform for both GTK2 and
|
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the OSX platform for both GTK2 and
|
||||||
/// GTK3.
|
/// GTK3.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class OSXWindowInfoInitializer
|
public static class OSXWindowInfoInitializer
|
||||||
{
|
{
|
||||||
#if GTK3
|
#if GTK3
|
||||||
const string OSXLibGdkName = "libgdk-3.dylib";
|
const string OSXLibGdkName = "libgdk-3.dylib";
|
||||||
#else
|
#else
|
||||||
const string OSXLibGdkName = "libgdk-quartz-2.0.0.dylib";
|
const string OSXLibGdkName = "libgdk-quartz-2.0.0.dylib";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an <see cref="IWindowInfo"/> under the OSX platform.
|
/// Initializes an <see cref="IWindowInfo"/> under the OSX platform.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gdkWindowHandle"></param>
|
/// <param name="gdkWindowHandle"></param>
|
||||||
public static IWindowInfo Initialize(IntPtr gdkWindowHandle)
|
public static IWindowInfo Initialize(IntPtr gdkWindowHandle)
|
||||||
{
|
{
|
||||||
IntPtr windowHandle = gdk_quartz_window_get_nswindow(gdkWindowHandle);
|
IntPtr windowHandle = gdk_quartz_window_get_nswindow(gdkWindowHandle);
|
||||||
IntPtr viewHandle = gdk_quartz_window_get_nsview(gdkWindowHandle);
|
IntPtr viewHandle = gdk_quartz_window_get_nsview(gdkWindowHandle);
|
||||||
|
|
||||||
return Utilities.CreateMacOSWindowInfo(windowHandle, viewHandle);
|
return Utilities.CreateMacOSWindowInfo(windowHandle, viewHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(OSXLibGdkName)]
|
[SuppressUnmanagedCodeSecurity, DllImport(OSXLibGdkName)]
|
||||||
private static extern IntPtr gdk_quartz_window_get_nswindow(IntPtr handle);
|
private static extern IntPtr gdk_quartz_window_get_nswindow(IntPtr handle);
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(OSXLibGdkName)]
|
[SuppressUnmanagedCodeSecurity, DllImport(OSXLibGdkName)]
|
||||||
private static extern IntPtr gdk_quartz_window_get_nsview(IntPtr handle);
|
private static extern IntPtr gdk_quartz_window_get_nsview(IntPtr handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,35 +9,35 @@ namespace OpenTK.Win
|
||||||
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the Windows platform for both GTK2 and
|
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the Windows platform for both GTK2 and
|
||||||
/// GTK3.
|
/// GTK3.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class WinWindowsInfoInitializer
|
public static class WinWindowsInfoInitializer
|
||||||
{
|
{
|
||||||
#if GTK3
|
#if GTK3
|
||||||
private const string WinLibGDKName = "libgdk-3-0.dll";
|
private const string WinLibGDKName = "libgdk-3-0.dll";
|
||||||
#else
|
#else
|
||||||
private const string WinLibGDKName = "libgdk-win32-2.0-0.dll";
|
private const string WinLibGDKName = "libgdk-win32-2.0-0.dll";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an <see cref="IWindowInfo"/> under the Windows platform.
|
/// Initializes an <see cref="IWindowInfo"/> under the Windows platform.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gdkWindowHandle"></param>
|
/// <param name="gdkWindowHandle"></param>
|
||||||
public static IWindowInfo Initialize(IntPtr gdkWindowHandle)
|
public static IWindowInfo Initialize(IntPtr gdkWindowHandle)
|
||||||
{
|
{
|
||||||
#if GTK3
|
#if GTK3
|
||||||
IntPtr windowHandle = gdk_win32_window_get_handle(gdkWindowHandle);
|
IntPtr windowHandle = gdk_win32_window_get_handle(gdkWindowHandle);
|
||||||
#else
|
#else
|
||||||
IntPtr windowHandle = gdk_win32_drawable_get_handle(gdkWindowHandle);
|
IntPtr windowHandle = gdk_win32_drawable_get_handle(gdkWindowHandle);
|
||||||
#endif
|
#endif
|
||||||
return Utilities.CreateWindowsWindowInfo(windowHandle);
|
return Utilities.CreateWindowsWindowInfo(windowHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GTK3
|
#if GTK3
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(WinLibGDKName, CallingConvention = CallingConvention.Cdecl)]
|
[SuppressUnmanagedCodeSecurity, DllImport(WinLibGDKName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gdk_win32_window_get_handle(IntPtr w);
|
static extern IntPtr gdk_win32_window_get_handle(IntPtr w);
|
||||||
#else
|
#else
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(WinLibGDKName, CallingConvention = CallingConvention.Cdecl)]
|
[SuppressUnmanagedCodeSecurity, DllImport(WinLibGDKName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gdk_win32_drawable_get_handle(IntPtr d);
|
static extern IntPtr gdk_win32_drawable_get_handle(IntPtr d);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,165 +11,165 @@ namespace OpenTK.X11
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the X11 platform for both GTK2 and GTK3.
|
/// Handler class for initializing <see cref="IWindowInfo"/> objects under the X11 platform for both GTK2 and GTK3.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class XWindowInfoInitializer
|
public static class XWindowInfoInitializer
|
||||||
{
|
{
|
||||||
|
|
||||||
#if GTK3
|
#if GTK3
|
||||||
const string UnixLibGdkName = "libgdk-3.so.0";
|
const string UnixLibGdkName = "libgdk-3.so.0";
|
||||||
#else
|
#else
|
||||||
const string UnixLibGdkName = "libgdk-x11-2.0.so.0";
|
const string UnixLibGdkName = "libgdk-x11-2.0.so.0";
|
||||||
#endif
|
#endif
|
||||||
private const string UnixLibX11Name = "libX11.so.6";
|
private const string UnixLibX11Name = "libX11.so.6";
|
||||||
private const string UnixLibGLName = "libGL.so.1";
|
private const string UnixLibGLName = "libGL.so.1";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes an <see cref="IWindowInfo"/> under the X11 platform.
|
/// Initializes an <see cref="IWindowInfo"/> under the X11 platform.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mode"></param>
|
/// <param name="mode"></param>
|
||||||
/// <param name="displayHandle"></param>
|
/// <param name="displayHandle"></param>
|
||||||
/// <param name="screenNumber"></param>
|
/// <param name="screenNumber"></param>
|
||||||
/// <param name="gdkWindowHandle"></param>
|
/// <param name="gdkWindowHandle"></param>
|
||||||
/// <param name="gdkRootWindowHandle"></param>
|
/// <param name="gdkRootWindowHandle"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IWindowInfo Initialize(GraphicsMode mode, IntPtr displayHandle, int screenNumber, IntPtr gdkWindowHandle, IntPtr gdkRootWindowHandle)
|
public static IWindowInfo Initialize(GraphicsMode mode, IntPtr displayHandle, int screenNumber, IntPtr gdkWindowHandle, IntPtr gdkRootWindowHandle)
|
||||||
{
|
{
|
||||||
IntPtr display = gdk_x11_display_get_xdisplay(displayHandle);
|
IntPtr display = gdk_x11_display_get_xdisplay(displayHandle);
|
||||||
|
|
||||||
#if GTK3
|
#if GTK3
|
||||||
IntPtr windowXid = gdk_x11_window_get_xid(gdkWindowHandle);
|
IntPtr windowXid = gdk_x11_window_get_xid(gdkWindowHandle);
|
||||||
IntPtr rootWindowXid = gdk_x11_window_get_xid(gdkRootWindowHandle);
|
IntPtr rootWindowXid = gdk_x11_window_get_xid(gdkRootWindowHandle);
|
||||||
#else
|
#else
|
||||||
IntPtr windowXid = gdk_x11_drawable_get_xid(gdkWindowHandle);
|
IntPtr windowXid = gdk_x11_drawable_get_xid(gdkWindowHandle);
|
||||||
IntPtr rootWindowXid = gdk_x11_drawable_get_xid(gdkRootWindowHandle);
|
IntPtr rootWindowXid = gdk_x11_drawable_get_xid(gdkRootWindowHandle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IntPtr visualInfo;
|
IntPtr visualInfo;
|
||||||
if (mode.Index.HasValue)
|
if (mode.Index.HasValue)
|
||||||
{
|
{
|
||||||
XVisualInfo info = new XVisualInfo
|
XVisualInfo info = new XVisualInfo
|
||||||
{
|
{
|
||||||
VisualID = mode.Index.Value
|
VisualID = mode.Index.Value
|
||||||
};
|
};
|
||||||
|
|
||||||
int dummy;
|
int dummy;
|
||||||
visualInfo = XGetVisualInfo(display, XVisualInfoMask.ID, ref info, out dummy);
|
visualInfo = XGetVisualInfo(display, XVisualInfoMask.ID, ref info, out dummy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
visualInfo = GetVisualInfo(mode, display, screenNumber);
|
visualInfo = GetVisualInfo(mode, display, screenNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
IWindowInfo retval = Utilities.CreateX11WindowInfo(display, screenNumber, windowXid, rootWindowXid, visualInfo);
|
IWindowInfo retval = Utilities.CreateX11WindowInfo(display, screenNumber, windowXid, rootWindowXid, visualInfo);
|
||||||
XFree(visualInfo);
|
XFree(visualInfo);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr XGetVisualInfo(IntPtr display, XVisualInfoMask infoMask, ref XVisualInfo template, out int nitems)
|
private static IntPtr XGetVisualInfo(IntPtr display, XVisualInfoMask infoMask, ref XVisualInfo template, out int nitems)
|
||||||
{
|
{
|
||||||
return XGetVisualInfoInternal(display, (IntPtr)(int)infoMask, ref template, out nitems);
|
return XGetVisualInfoInternal(display, (IntPtr)(int)infoMask, ref template, out nitems);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetVisualInfo(GraphicsMode mode, IntPtr display, int screenNumber)
|
private static IntPtr GetVisualInfo(GraphicsMode mode, IntPtr display, int screenNumber)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int[] attributes = CreateAttributeList(mode).ToArray();
|
int[] attributes = CreateAttributeList(mode).ToArray();
|
||||||
return glXChooseVisual(display, screenNumber, attributes);
|
return glXChooseVisual(display, screenNumber, attributes);
|
||||||
}
|
}
|
||||||
catch (DllNotFoundException e)
|
catch (DllNotFoundException e)
|
||||||
{
|
{
|
||||||
throw new DllNotFoundException("OpenGL dll not found!", e);
|
throw new DllNotFoundException("OpenGL dll not found!", e);
|
||||||
}
|
}
|
||||||
catch (EntryPointNotFoundException enf)
|
catch (EntryPointNotFoundException enf)
|
||||||
{
|
{
|
||||||
throw new EntryPointNotFoundException("Glx entry point not found!", enf);
|
throw new EntryPointNotFoundException("Glx entry point not found!", enf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<int> CreateAttributeList(GraphicsMode mode)
|
private static List<int> CreateAttributeList(GraphicsMode mode)
|
||||||
{
|
{
|
||||||
List<int> attributeList = new List<int>(24);
|
List<int> attributeList = new List<int>(24);
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.RGBA);
|
attributeList.Add((int)GLXAttribute.RGBA);
|
||||||
|
|
||||||
if (mode.Buffers > 1)
|
if (mode.Buffers > 1)
|
||||||
{
|
{
|
||||||
attributeList.Add((int)GLXAttribute.DOUBLEBUFFER);
|
attributeList.Add((int)GLXAttribute.DOUBLEBUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.Stereo)
|
if (mode.Stereo)
|
||||||
{
|
{
|
||||||
attributeList.Add((int)GLXAttribute.STEREO);
|
attributeList.Add((int)GLXAttribute.STEREO);
|
||||||
}
|
}
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.RED_SIZE);
|
attributeList.Add((int)GLXAttribute.RED_SIZE);
|
||||||
attributeList.Add(mode.ColorFormat.Red / 4); // TODO support 16-bit
|
attributeList.Add(mode.ColorFormat.Red / 4); // TODO support 16-bit
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.GREEN_SIZE);
|
attributeList.Add((int)GLXAttribute.GREEN_SIZE);
|
||||||
attributeList.Add(mode.ColorFormat.Green / 4); // TODO support 16-bit
|
attributeList.Add(mode.ColorFormat.Green / 4); // TODO support 16-bit
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.BLUE_SIZE);
|
attributeList.Add((int)GLXAttribute.BLUE_SIZE);
|
||||||
attributeList.Add(mode.ColorFormat.Blue / 4); // TODO support 16-bit
|
attributeList.Add(mode.ColorFormat.Blue / 4); // TODO support 16-bit
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.ALPHA_SIZE);
|
attributeList.Add((int)GLXAttribute.ALPHA_SIZE);
|
||||||
attributeList.Add(mode.ColorFormat.Alpha / 4); // TODO support 16-bit
|
attributeList.Add(mode.ColorFormat.Alpha / 4); // TODO support 16-bit
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.DEPTH_SIZE);
|
attributeList.Add((int)GLXAttribute.DEPTH_SIZE);
|
||||||
attributeList.Add(mode.Depth);
|
attributeList.Add(mode.Depth);
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.STENCIL_SIZE);
|
attributeList.Add((int)GLXAttribute.STENCIL_SIZE);
|
||||||
attributeList.Add(mode.Stencil);
|
attributeList.Add(mode.Stencil);
|
||||||
|
|
||||||
//attributeList.Add(GLX_AUX_BUFFERS);
|
//attributeList.Add(GLX_AUX_BUFFERS);
|
||||||
//attributeList.Add(Buffers);
|
//attributeList.Add(Buffers);
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.ACCUM_RED_SIZE);
|
attributeList.Add((int)GLXAttribute.ACCUM_RED_SIZE);
|
||||||
attributeList.Add(mode.AccumulatorFormat.Red / 4);// TODO support 16-bit
|
attributeList.Add(mode.AccumulatorFormat.Red / 4);// TODO support 16-bit
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.ACCUM_GREEN_SIZE);
|
attributeList.Add((int)GLXAttribute.ACCUM_GREEN_SIZE);
|
||||||
attributeList.Add(mode.AccumulatorFormat.Green / 4);// TODO support 16-bit
|
attributeList.Add(mode.AccumulatorFormat.Green / 4);// TODO support 16-bit
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.ACCUM_BLUE_SIZE);
|
attributeList.Add((int)GLXAttribute.ACCUM_BLUE_SIZE);
|
||||||
attributeList.Add(mode.AccumulatorFormat.Blue / 4);// TODO support 16-bit
|
attributeList.Add(mode.AccumulatorFormat.Blue / 4);// TODO support 16-bit
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.ACCUM_ALPHA_SIZE);
|
attributeList.Add((int)GLXAttribute.ACCUM_ALPHA_SIZE);
|
||||||
attributeList.Add(mode.AccumulatorFormat.Alpha / 4);// TODO support 16-bit
|
attributeList.Add(mode.AccumulatorFormat.Alpha / 4);// TODO support 16-bit
|
||||||
|
|
||||||
attributeList.Add((int)GLXAttribute.NONE);
|
attributeList.Add((int)GLXAttribute.NONE);
|
||||||
|
|
||||||
return attributeList;
|
return attributeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport(UnixLibX11Name, EntryPoint = "XGetVisualInfo")]
|
[DllImport(UnixLibX11Name, EntryPoint = "XGetVisualInfo")]
|
||||||
private static extern IntPtr XGetVisualInfoInternal(IntPtr display, IntPtr infoMask, ref XVisualInfo template, out int nitems);
|
private static extern IntPtr XGetVisualInfoInternal(IntPtr display, IntPtr infoMask, ref XVisualInfo template, out int nitems);
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibX11Name)]
|
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibX11Name)]
|
||||||
private static extern void XFree(IntPtr handle);
|
private static extern void XFree(IntPtr handle);
|
||||||
|
|
||||||
#if GTK3
|
#if GTK3
|
||||||
/// <summary> Returns the X resource (window or pixmap) belonging to a GdkWindow. </summary>
|
/// <summary> Returns the X resource (window or pixmap) belonging to a GdkWindow. </summary>
|
||||||
/// <remarks> XID gdk_x11_window_get_xid(GdkWindow *drawable); </remarks>
|
/// <remarks> XID gdk_x11_window_get_xid(GdkWindow *drawable); </remarks>
|
||||||
/// <param name="gdkDisplay"> The GdkDrawable. </param>
|
/// <param name="gdkDisplay"> The GdkDrawable. </param>
|
||||||
/// <returns> The ID of window's X resource. </returns>
|
/// <returns> The ID of window's X resource. </returns>
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
|
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
|
||||||
private static extern IntPtr gdk_x11_window_get_xid(IntPtr gdkDisplay);
|
private static extern IntPtr gdk_x11_window_get_xid(IntPtr gdkDisplay);
|
||||||
#else
|
#else
|
||||||
/// <summary> Returns the X resource (window or pixmap) belonging to a GdkDrawable. </summary>
|
/// <summary> Returns the X resource (window or pixmap) belonging to a GdkDrawable. </summary>
|
||||||
/// <remarks> XID gdk_x11_drawable_get_xid(GdkDrawable *drawable); </remarks>
|
/// <remarks> XID gdk_x11_drawable_get_xid(GdkDrawable *drawable); </remarks>
|
||||||
/// <param name="gdkDisplay"> The GdkDrawable. </param>
|
/// <param name="gdkDisplay"> The GdkDrawable. </param>
|
||||||
/// <returns> The ID of drawable's X resource. </returns>
|
/// <returns> The ID of drawable's X resource. </returns>
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
|
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
|
||||||
static extern IntPtr gdk_x11_drawable_get_xid(IntPtr gdkDisplay);
|
static extern IntPtr gdk_x11_drawable_get_xid(IntPtr gdkDisplay);
|
||||||
#endif
|
#endif
|
||||||
/// <summary> Returns the X display of a GdkDisplay. </summary>
|
/// <summary> Returns the X display of a GdkDisplay. </summary>
|
||||||
/// <remarks> Display* gdk_x11_display_get_xdisplay(GdkDisplay *display); </remarks>
|
/// <remarks> Display* gdk_x11_display_get_xdisplay(GdkDisplay *display); </remarks>
|
||||||
/// <param name="gdkDisplay"> The GdkDrawable. </param>
|
/// <param name="gdkDisplay"> The GdkDrawable. </param>
|
||||||
/// <returns> The X Display of the GdkDisplay. </returns>
|
/// <returns> The X Display of the GdkDisplay. </returns>
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
|
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGdkName)]
|
||||||
private static extern IntPtr gdk_x11_display_get_xdisplay(IntPtr gdkDisplay);
|
private static extern IntPtr gdk_x11_display_get_xdisplay(IntPtr gdkDisplay);
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGLName)]
|
[SuppressUnmanagedCodeSecurity, DllImport(UnixLibGLName)]
|
||||||
private static extern IntPtr glXChooseVisual(IntPtr display, int screen, int[] attr);
|
private static extern IntPtr glXChooseVisual(IntPtr display, int screen, int[] attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue