mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 15:05:41 +00:00
Made GraphicsMode.Index public, as it is necessary when extending OpenTK.
Removed OpenTK.Platform.Utilities.CreateWindowInfo and made the platform-specific CreateWindowInfo methods public (e.g. CreateX11WindowInfo). Moved Mono Windows.Forms-specific code into X11GLControl. Removed OpenTK.Platform.Utilities.IsIdle. Removed obsolete methods from OpenTK.Platform.Utilities. Marked OpenTK.Platform.Utilities.CreateGraphicsContext as obsolete (use GraphicsContext constructor instead). Made IWindowInfo implementations private.
This commit is contained in:
parent
c5fe1bcafd
commit
8b60cc2018
|
@ -68,7 +68,7 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Utilities.CreateWindowInfo(mode, control.Handle, true);
|
return Utilities.CreateDummyWindowInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace OpenTK
|
||||||
|
|
||||||
public IWindowInfo WindowInfo
|
public IWindowInfo WindowInfo
|
||||||
{
|
{
|
||||||
get { return Utilities.CreateWindowInfo(null, IntPtr.Zero, true); }
|
get { return Utilities.CreateDummyWindowInfo(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
|
||||||
window_info = Utilities.CreateWindowInfo(mode, control.Handle, true);
|
window_info = Utilities.CreateWindowsWindowInfo(control.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -22,7 +22,39 @@ namespace OpenTK
|
||||||
#region P/Invokes
|
#region P/Invokes
|
||||||
|
|
||||||
[DllImport("libX11")]
|
[DllImport("libX11")]
|
||||||
public extern static int XPending(IntPtr diplay);
|
static extern IntPtr XCreateColormap(IntPtr display, IntPtr window, IntPtr visual, int alloc);
|
||||||
|
|
||||||
|
[DllImport("libX11", EntryPoint = "XGetVisualInfo")]
|
||||||
|
static extern IntPtr XGetVisualInfoInternal(IntPtr display, IntPtr vinfo_mask, ref XVisualInfo template, out int nitems);
|
||||||
|
|
||||||
|
static IntPtr XGetVisualInfo(IntPtr display, int vinfo_mask, ref XVisualInfo template, out int nitems)
|
||||||
|
{
|
||||||
|
return XGetVisualInfoInternal(display, (IntPtr)vinfo_mask, ref template, out nitems);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("libX11")]
|
||||||
|
extern static int XPending(IntPtr diplay);
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
struct XVisualInfo
|
||||||
|
{
|
||||||
|
public IntPtr Visual;
|
||||||
|
public IntPtr VisualID;
|
||||||
|
public int Screen;
|
||||||
|
public int Depth;
|
||||||
|
public int Class;
|
||||||
|
public long RedMask;
|
||||||
|
public long GreenMask;
|
||||||
|
public long blueMask;
|
||||||
|
public int ColormapSize;
|
||||||
|
public int BitsPerRgb;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return String.Format("id ({0}), screen ({1}), depth ({2}), class ({3})",
|
||||||
|
VisualID, Screen, Depth, Class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -30,6 +62,7 @@ namespace OpenTK
|
||||||
|
|
||||||
GraphicsMode mode;
|
GraphicsMode mode;
|
||||||
IWindowInfo window_info;
|
IWindowInfo window_info;
|
||||||
|
IntPtr display;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -39,10 +72,33 @@ namespace OpenTK
|
||||||
throw new ArgumentNullException("mode");
|
throw new ArgumentNullException("mode");
|
||||||
if (control == null)
|
if (control == null)
|
||||||
throw new ArgumentNullException("control");
|
throw new ArgumentNullException("control");
|
||||||
|
if (!mode.Index.HasValue)
|
||||||
|
throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
|
||||||
|
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
|
||||||
window_info = Utilities.CreateWindowInfo(mode, control.Handle, true);
|
// Use reflection to retrieve the necessary values from Mono's Windows.Forms implementation.
|
||||||
|
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||||
|
if (xplatui == null) throw new PlatformNotSupportedException(
|
||||||
|
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
||||||
|
|
||||||
|
// get the required handles from the X11 API.
|
||||||
|
display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
|
||||||
|
IntPtr rootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
|
||||||
|
int screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
|
||||||
|
|
||||||
|
// get the XVisualInfo for this GraphicsMode
|
||||||
|
XVisualInfo info = new XVisualInfo();
|
||||||
|
info.VisualID = mode.Index.Value;
|
||||||
|
int dummy;
|
||||||
|
IntPtr infoPtr = XGetVisualInfo(display, 1 /* VisualInfoMask.ID */, ref info, out dummy);
|
||||||
|
info = (XVisualInfo)Marshal.PtrToStructure(infoPtr, typeof(XVisualInfo));
|
||||||
|
|
||||||
|
// set the X11 colormap.
|
||||||
|
SetStaticFieldValue(xplatui, "CustomVisual", info.Visual);
|
||||||
|
SetStaticFieldValue(xplatui, "CustomColormap", XCreateColormap(display, rootWindow, info.Visual, 0));
|
||||||
|
|
||||||
|
window_info = Utilities.CreateX11WindowInfo(display, screen, control.Handle, rootWindow, infoPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IGLControl Members
|
#region IGLControl Members
|
||||||
|
@ -54,7 +110,7 @@ namespace OpenTK
|
||||||
|
|
||||||
public bool IsIdle
|
public bool IsIdle
|
||||||
{
|
{
|
||||||
get { return XPending(((Platform.X11.X11WindowInfo)window_info).Display) == 0; }
|
get { return XPending(display) == 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWindowInfo WindowInfo
|
public IWindowInfo WindowInfo
|
||||||
|
@ -66,5 +122,21 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Members
|
||||||
|
|
||||||
|
static object GetStaticFieldValue(Type type, string fieldName)
|
||||||
|
{
|
||||||
|
return type.GetField(fieldName,
|
||||||
|
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetStaticFieldValue(Type type, string fieldName, object value)
|
||||||
|
{
|
||||||
|
type.GetField(fieldName,
|
||||||
|
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(null, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,40 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
#region --- Public Methods ---
|
#region --- Public Methods ---
|
||||||
|
|
||||||
|
#region public IntPtr Index
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a nullable <see cref="System.IntPtr"/> value, indicating the platform-specific index for this GraphicsMode.
|
||||||
|
/// </summary>
|
||||||
|
public IntPtr? Index
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (index == null)
|
||||||
|
{
|
||||||
|
GraphicsMode mode;
|
||||||
|
lock (mode_selection_lock)
|
||||||
|
{
|
||||||
|
mode = implementation.SelectGraphicsMode(ColorFormat, Depth, Stencil, Samples, AccumulatorFormat, Buffers, Stereo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Index = mode.Index;
|
||||||
|
ColorFormat = mode.ColorFormat;
|
||||||
|
Depth = mode.Depth;
|
||||||
|
Stencil = mode.Stencil;
|
||||||
|
Samples = mode.Samples;
|
||||||
|
AccumulatorFormat = mode.AccumulatorFormat;
|
||||||
|
Buffers = mode.Buffers;
|
||||||
|
Stereo = mode.Stereo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
set { index = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region public int ColorFormat
|
#region public int ColorFormat
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -283,41 +317,6 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Internal Methods ---
|
|
||||||
|
|
||||||
#region internal IntPtr Index
|
|
||||||
|
|
||||||
internal IntPtr? Index
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (index == null)
|
|
||||||
{
|
|
||||||
GraphicsMode mode;
|
|
||||||
lock (mode_selection_lock)
|
|
||||||
{
|
|
||||||
mode = implementation.SelectGraphicsMode(ColorFormat, Depth, Stencil, Samples, AccumulatorFormat, Buffers, Stereo);
|
|
||||||
}
|
|
||||||
|
|
||||||
Index = mode.Index;
|
|
||||||
ColorFormat = mode.ColorFormat;
|
|
||||||
Depth = mode.Depth;
|
|
||||||
Stencil = mode.Stencil;
|
|
||||||
Samples = mode.Samples;
|
|
||||||
AccumulatorFormat = mode.AccumulatorFormat;
|
|
||||||
Buffers = mode.Buffers;
|
|
||||||
Stereo = mode.Stereo;
|
|
||||||
}
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
set { index = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region --- Overrides ---
|
#region --- Overrides ---
|
||||||
|
|
||||||
/// <summary>Returns a System.String describing the current GraphicsFormat.</summary>
|
/// <summary>Returns a System.String describing the current GraphicsFormat.</summary>
|
||||||
|
|
|
@ -53,23 +53,6 @@ namespace OpenTK.Platform.Dummy
|
||||||
public override void MakeCurrent(IWindowInfo info) { }
|
public override void MakeCurrent(IWindowInfo info) { }
|
||||||
public override bool IsCurrent { get { return true; } }
|
public override bool IsCurrent { get { return true; } }
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public event DestroyEvent<IGraphicsContext> Destroy;
|
|
||||||
[Obsolete]
|
|
||||||
void OnDestroy() { if (Destroy != null) Destroy(this, EventArgs.Empty); }
|
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public void RegisterForDisposal(IDisposable resource)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("Use the general GraphicsContext class instead.");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public void DisposeResources()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("Use the general GraphicsContext class instead.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IntPtr GetAddress(string function) { return IntPtr.Zero; }
|
public override IntPtr GetAddress(string function) { return IntPtr.Zero; }
|
||||||
|
|
||||||
public override bool VSync { get { return vsync; } set { vsync = value; } }
|
public override bool VSync { get { return vsync; } set { vsync = value; } }
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes a Carbon window.
|
/// Describes a Carbon window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class CarbonWindowInfo : IWindowInfo
|
sealed class CarbonWindowInfo : IWindowInfo
|
||||||
{
|
{
|
||||||
IntPtr windowRef;
|
IntPtr windowRef;
|
||||||
bool ownHandle = false;
|
bool ownHandle = false;
|
||||||
|
|
|
@ -169,50 +169,6 @@ namespace OpenTK.Platform
|
||||||
return @new != null;
|
return @new != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
#region public bool IsIdle
|
|
||||||
|
|
||||||
interface IIsIdle { bool IsIdle { get; } }
|
|
||||||
|
|
||||||
class X11IsIdle : IIsIdle
|
|
||||||
{
|
|
||||||
public bool IsIdle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return X11.API.Pending(IntPtr.Zero) == 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class WindowsIsIdle : IIsIdle
|
|
||||||
{
|
|
||||||
Windows.MSG msg;
|
|
||||||
|
|
||||||
public bool IsIdle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return !Windows.Functions.PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static IIsIdle isIdleImpl =
|
|
||||||
System.Environment.OSVersion.Platform == PlatformID.Unix ?
|
|
||||||
(IIsIdle)new X11IsIdle() : (IIsIdle)new WindowsIsIdle();
|
|
||||||
|
|
||||||
public static bool IsIdle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return isIdleImpl.IsIdle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Creating a Graphics Context ---
|
#region --- Creating a Graphics Context ---
|
||||||
|
@ -226,6 +182,7 @@ namespace OpenTK.Platform
|
||||||
/// <param name="minor">The minor OpenGL version number for this IGraphicsContext.</param>
|
/// <param name="minor">The minor OpenGL version number for this IGraphicsContext.</param>
|
||||||
/// <param name="flags">A bitwise collection of GraphicsContextFlags with specific options for this IGraphicsContext.</param>
|
/// <param name="flags">A bitwise collection of GraphicsContextFlags with specific options for this IGraphicsContext.</param>
|
||||||
/// <returns>A new IGraphicsContext instance.</returns>
|
/// <returns>A new IGraphicsContext instance.</returns>
|
||||||
|
[Obsolete("Call new OpenTK.Graphics.GraphicsContext() directly, instead.")]
|
||||||
public static IGraphicsContext CreateGraphicsContext(
|
public static IGraphicsContext CreateGraphicsContext(
|
||||||
GraphicsMode mode, IWindowInfo window,
|
GraphicsMode mode, IWindowInfo window,
|
||||||
int major, int minor, GraphicsContextFlags flags)
|
int major, int minor, GraphicsContextFlags flags)
|
||||||
|
@ -238,135 +195,76 @@ namespace OpenTK.Platform
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#region CreateX11WindowInfo
|
||||||
/// Creates an IGraphicsContext instance for the specified System.Windows.Forms.Control.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mode">The GraphicsMode for the GraphicsContext.</param>
|
|
||||||
/// <param name="cntrl">A System.Windows.Forms.Control.</param>
|
|
||||||
/// <param name="context">A new IGraphicsContext instance.</param>
|
|
||||||
/// <param name="info">An IWindowInfo instance for the specified cntrl.</param>
|
|
||||||
[Obsolete("Create the IWindowInfo object first by calling CreateWindowInfo, then use the CreateGraphicsContext overload which takes major, minor and flags parameters.")]
|
|
||||||
public static void CreateGraphicsContext(GraphicsMode mode, Control cntrl,
|
|
||||||
out IGraphicsContext context, out IWindowInfo info)
|
|
||||||
{
|
|
||||||
CreateGraphicsContext(mode, cntrl.Handle, out context, out info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an IGraphicsContext instance for the specified System.Windows.Forms.Control.
|
/// Constructs a new IWindowInfo instance for the X11 platform.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mode">The GraphicsMode for the GraphicsContext.</param>
|
/// <param name="display">The display connection.</param>
|
||||||
/// <param name="cntrlHandle">A System.IntPtr that contains the handle for a System.Windows.Forms.Control.</param>
|
/// <param name="screen">The screen.</param>
|
||||||
/// <param name="context">A new IGraphicsContext instance.</param>
|
/// <param name="windowHandle">The handle for the window.</param>
|
||||||
/// <param name="info">An IWindowInfo instance for the specified ctrl.</param>
|
/// <param name="rootWindow">The root window for screen.</param>
|
||||||
[Obsolete("Create the IWindowInfo object first by calling CreateWindowInfo, then use the CreateGraphicsContext overload which takes major, minor and flags parameters.")]
|
/// <param name="visualInfo">A pointer to a XVisualInfo structure obtained through XGetVisualInfo.</param>
|
||||||
public static void CreateGraphicsContext(GraphicsMode mode, IntPtr cntrlHandle,
|
/// <returns>A new IWindowInfo instance.</returns>
|
||||||
out IGraphicsContext context, out IWindowInfo info)
|
public static IWindowInfo CreateX11WindowInfo(IntPtr display, int screen, IntPtr windowHandle, IntPtr rootWindow, IntPtr visualInfo)
|
||||||
{
|
|
||||||
info = CreateWindowInfo(mode, cntrlHandle, true);
|
|
||||||
|
|
||||||
context = new GraphicsContext(mode, info);
|
|
||||||
context.MakeCurrent(info);
|
|
||||||
|
|
||||||
(context as IGraphicsContextInternal).LoadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region --- CreateWindowInfo ---
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates an object which implements the IWindowInfo interface for the platform
|
|
||||||
/// currently running on.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mode">The desired GraphicsMode for this window.</param>
|
|
||||||
/// <param name="controlHandle">The handle to the control, obtained from Control.Handle.</param>
|
|
||||||
/// <param name="isControl">Set to true if this is a Windows.Forms control.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static IWindowInfo CreateWindowInfo(GraphicsMode mode, IntPtr controlHandle, bool isControl)
|
|
||||||
{
|
|
||||||
if (Configuration.RunningOnWindows) return CreateWinWindowInfo(controlHandle);
|
|
||||||
else if (Configuration.RunningOnX11) return CreateX11WindowInfo(mode, controlHandle, isControl);
|
|
||||||
else if (Configuration.RunningOnMacOS) return CreateMacOSCarbonWindowInfo(controlHandle, isControl);
|
|
||||||
else
|
|
||||||
throw new PlatformNotSupportedException("Refer to http://www.opentk.com for more information.");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region --- X11 Platform-specific implementation ---
|
|
||||||
|
|
||||||
private static IWindowInfo CreateX11WindowInfo(GraphicsMode mode, IntPtr controlHandle, bool isControl)
|
|
||||||
{
|
{
|
||||||
Platform.X11.X11WindowInfo window = new OpenTK.Platform.X11.X11WindowInfo();
|
Platform.X11.X11WindowInfo window = new OpenTK.Platform.X11.X11WindowInfo();
|
||||||
window.WindowHandle = controlHandle;
|
window.Display = display;
|
||||||
|
window.Screen = screen;
|
||||||
if (isControl)
|
window.WindowHandle = windowHandle;
|
||||||
{
|
window.RootWindow = rootWindow;
|
||||||
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
window.VisualInfo = (X11.XVisualInfo)Marshal.PtrToStructure(visualInfo, typeof(X11.XVisualInfo));
|
||||||
if (xplatui == null) throw new PlatformNotSupportedException(
|
|
||||||
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
|
||||||
|
|
||||||
// get the required handles from the X11 API.
|
|
||||||
window.Display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
|
|
||||||
window.RootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
|
|
||||||
window.Screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
|
|
||||||
|
|
||||||
// get the X11 Visual info for the display.
|
|
||||||
Platform.X11.XVisualInfo info = new Platform.X11.XVisualInfo();
|
|
||||||
|
|
||||||
if (!mode.Index.HasValue)
|
|
||||||
throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
|
|
||||||
|
|
||||||
info.VisualID = mode.Index.Value;
|
|
||||||
int dummy;
|
|
||||||
window.VisualInfo = (Platform.X11.XVisualInfo)Marshal.PtrToStructure(
|
|
||||||
Platform.X11.Functions.XGetVisualInfo(window.Display, Platform.X11.XVisualInfoMask.ID,
|
|
||||||
ref info, out dummy), typeof(Platform.X11.XVisualInfo));
|
|
||||||
|
|
||||||
// set the X11 colormap.
|
|
||||||
SetStaticFieldValue(xplatui, "CustomVisual", window.VisualInfo.Visual);
|
|
||||||
SetStaticFieldValue(xplatui, "CustomColormap",
|
|
||||||
Platform.X11.Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region --- Windows Platform-specific implementation ---
|
|
||||||
|
|
||||||
private static IWindowInfo CreateWinWindowInfo(IntPtr controlHandle)
|
#region CreateWindowsWindowInfo
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an IWindowInfo instance for the windows platform.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="windowHandle">The handle of the window.</param>
|
||||||
|
/// <returns>A new IWindowInfo instance.</returns>
|
||||||
|
public static IWindowInfo CreateWindowsWindowInfo(IntPtr windowHandle)
|
||||||
{
|
{
|
||||||
return new OpenTK.Platform.Windows.WinWindowInfo(controlHandle, null);
|
return new OpenTK.Platform.Windows.WinWindowInfo(windowHandle, null);
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
#region --- Mac OS X Platform-specific implementation ---
|
|
||||||
|
|
||||||
private static IWindowInfo CreateMacOSCarbonWindowInfo(IntPtr controlHandle, bool isControl)
|
|
||||||
{
|
|
||||||
return new OpenTK.Platform.MacOS.CarbonWindowInfo(controlHandle, false, isControl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Utility functions for reading/writing non-public static fields through reflection ---
|
#region CreateMacOSCarbonWindowInfo
|
||||||
|
|
||||||
private static object GetStaticFieldValue(Type type, string fieldName)
|
/// <summary>
|
||||||
|
/// Creates an IWindowInfo instance for the Mac OS X platform.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="windowHandle">The handle of the window.</param>
|
||||||
|
/// <param name="ownHandle">Ignored. This is reserved for future use.</param>
|
||||||
|
/// <param name="isControl">Set to true if windowHandle corresponds to a System.Windows.Forms control.</param>
|
||||||
|
/// <returns>A new IWindowInfo instance.</returns>
|
||||||
|
public static IWindowInfo CreateMacOSCarbonWindowInfo(IntPtr windowHandle, bool ownHandle, bool isControl)
|
||||||
{
|
{
|
||||||
return type.GetField(fieldName,
|
return new OpenTK.Platform.MacOS.CarbonWindowInfo(windowHandle, false, isControl);
|
||||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
|
||||||
}
|
}
|
||||||
private static void SetStaticFieldValue(Type type, string fieldName, object value)
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CreateDummyWindowInfo
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an IWindowInfo instance for the dummy platform.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A new IWindowInfo instance.</returns>
|
||||||
|
public static IWindowInfo CreateDummyWindowInfo()
|
||||||
{
|
{
|
||||||
type.GetField(fieldName,
|
return new Dummy.DummyWindowInfo();
|
||||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(null, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ using System.Runtime.InteropServices;
|
||||||
namespace OpenTK.Platform.Windows
|
namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
/// <summary>Describes a win32 window.</summary>
|
/// <summary>Describes a win32 window.</summary>
|
||||||
public sealed class WinWindowInfo : IWindowInfo
|
sealed class WinWindowInfo : IWindowInfo
|
||||||
{
|
{
|
||||||
IntPtr handle, dc;
|
IntPtr handle, dc;
|
||||||
WinWindowInfo parent;
|
WinWindowInfo parent;
|
||||||
|
|
|
@ -586,10 +586,8 @@ XF86VidModeGetGammaRampSize(
|
||||||
|
|
||||||
#region internal class XVisualInfo
|
#region internal class XVisualInfo
|
||||||
|
|
||||||
#pragma warning disable 1591
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct XVisualInfo
|
struct XVisualInfo
|
||||||
{
|
{
|
||||||
public IntPtr Visual;
|
public IntPtr Visual;
|
||||||
public VisualID VisualID;
|
public VisualID VisualID;
|
||||||
|
@ -609,8 +607,6 @@ XF86VidModeGetGammaRampSize(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning restore 1591
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region internal class SetWindowAttributes
|
#region internal class SetWindowAttributes
|
||||||
|
|
|
@ -32,7 +32,7 @@ using System.Text;
|
||||||
namespace OpenTK.Platform.X11
|
namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
/// <summary>Describes an X11 window.</summary>
|
/// <summary>Describes an X11 window.</summary>
|
||||||
public sealed class X11WindowInfo : IWindowInfo
|
sealed class X11WindowInfo : IWindowInfo
|
||||||
{
|
{
|
||||||
IntPtr handle, rootWindow, display;
|
IntPtr handle, rootWindow, display;
|
||||||
X11WindowInfo parent;
|
X11WindowInfo parent;
|
||||||
|
|
Loading…
Reference in a new issue