mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-06-21 22:07:51 +00:00
Moved GraphicsMode to IGraphicsContext as it is universally useful.
Implemented GraphicsMode property on X11 and Mac OS X. Replaced tabs with spaces in AglContext.cs.
This commit is contained in:
parent
9e9e33e73f
commit
93a467a11f
|
@ -330,7 +330,7 @@ namespace OpenTK
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public GraphicsMode GraphicsMode
|
public GraphicsMode GraphicsMode
|
||||||
{
|
{
|
||||||
get { return (Context as IGraphicsContextInternal).GraphicsMode; }
|
get { return Context.GraphicsMode; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -385,7 +385,7 @@ namespace OpenTK.Graphics
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GraphicsMode GraphicsMode
|
public GraphicsMode GraphicsMode
|
||||||
{
|
{
|
||||||
get { return (implementation as IGraphicsContextInternal).GraphicsMode; }
|
get { return implementation.GraphicsMode; }
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
|
|
|
@ -51,6 +51,9 @@ namespace OpenTK.Graphics
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="window"></param>
|
/// <param name="window"></param>
|
||||||
void Update(IWindowInfo window);
|
void Update(IWindowInfo window);
|
||||||
|
|
||||||
|
/// <summary>Gets the GraphicsMode of this instance.</summary>
|
||||||
|
GraphicsMode GraphicsMode { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate void DestroyEvent<T>(T sender, EventArgs e);
|
public delegate void DestroyEvent<T>(T sender, EventArgs e);
|
||||||
|
@ -87,9 +90,6 @@ namespace OpenTK.Graphics
|
||||||
// </summary>
|
// </summary>
|
||||||
//IWindowInfo Info { get; }
|
//IWindowInfo Info { get; }
|
||||||
|
|
||||||
/// <summary>Gets the GraphicsMode of the context.</summary>
|
|
||||||
GraphicsMode GraphicsMode { get; }
|
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the
|
///// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the
|
||||||
///// calling thread, or IntPtr.Zero if no OpenGL context is current.
|
///// calling thread, or IntPtr.Zero if no OpenGL context is current.
|
||||||
|
|
|
@ -31,9 +31,9 @@ namespace OpenTK.Platform.MacOS
|
||||||
bool mVSync = false;
|
bool mVSync = false;
|
||||||
IntPtr displayID;
|
IntPtr displayID;
|
||||||
|
|
||||||
GraphicsMode mode;
|
GraphicsMode graphics_mode;
|
||||||
CarbonWindowInfo carbonWindow;
|
CarbonWindowInfo carbonWindow;
|
||||||
IntPtr shareContextRef;
|
IntPtr shareContextRef;
|
||||||
|
|
||||||
static AglContext()
|
static AglContext()
|
||||||
{
|
{
|
||||||
|
@ -45,13 +45,13 @@ namespace OpenTK.Platform.MacOS
|
||||||
Debug.Print("Context Type: {0}", shareContext);
|
Debug.Print("Context Type: {0}", shareContext);
|
||||||
Debug.Print("Window info: {0}", window);
|
Debug.Print("Window info: {0}", window);
|
||||||
|
|
||||||
this.mode = mode;
|
this.graphics_mode = mode;
|
||||||
this.carbonWindow = (CarbonWindowInfo)window;
|
this.carbonWindow = (CarbonWindowInfo)window;
|
||||||
|
|
||||||
if (shareContext is AglContext)
|
if (shareContext is AglContext)
|
||||||
shareContextRef = ((AglContext)shareContext).contextRef;
|
shareContextRef = ((AglContext)shareContext).contextRef;
|
||||||
|
|
||||||
CreateContext(mode, carbonWindow, shareContextRef, true);
|
CreateContext(mode, carbonWindow, shareContextRef, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
IntPtr shareContextRef, bool fullscreen)
|
IntPtr shareContextRef, bool fullscreen)
|
||||||
{
|
{
|
||||||
List<int> aglAttributes = new List<int>();
|
List<int> aglAttributes = new List<int>();
|
||||||
|
|
||||||
Debug.Print("AGL pixel format attributes:");
|
Debug.Print("AGL pixel format attributes:");
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
|
||||||
|
@ -97,10 +97,10 @@ namespace OpenTK.Platform.MacOS
|
||||||
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_ALPHA_SIZE, mode.AccumulatorFormat.Alpha);
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_ALPHA_SIZE, mode.AccumulatorFormat.Alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_FULLSCREEN);
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_FULLSCREEN);
|
||||||
}
|
}
|
||||||
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_NONE);
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_NONE);
|
||||||
|
|
||||||
Debug.Unindent();
|
Debug.Unindent();
|
||||||
|
@ -113,19 +113,19 @@ namespace OpenTK.Platform.MacOS
|
||||||
AGLPixelFormat myAGLPixelFormat;
|
AGLPixelFormat myAGLPixelFormat;
|
||||||
|
|
||||||
// Choose a pixel format with the attributes we specified.
|
// Choose a pixel format with the attributes we specified.
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
IntPtr gdevice;
|
IntPtr gdevice;
|
||||||
|
|
||||||
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(
|
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(
|
||||||
QuartzDisplayDeviceDriver.MainDisplay, out gdevice, false);
|
QuartzDisplayDeviceDriver.MainDisplay, out gdevice, false);
|
||||||
|
|
||||||
if (status != OSStatus.NoError)
|
if (status != OSStatus.NoError)
|
||||||
throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
|
throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
|
||||||
|
|
||||||
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
||||||
ref gdevice, 1,
|
ref gdevice, 1,
|
||||||
aglAttributes.ToArray());
|
aglAttributes.ToArray());
|
||||||
|
|
||||||
Agl.AglError err = Agl.GetError();
|
Agl.AglError err = Agl.GetError();
|
||||||
|
|
||||||
|
@ -137,16 +137,16 @@ namespace OpenTK.Platform.MacOS
|
||||||
CreateContext(mode, carbonWindow, shareContextRef, false);
|
CreateContext(mode, carbonWindow, shareContextRef, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
||||||
IntPtr.Zero, 0,
|
IntPtr.Zero, 0,
|
||||||
aglAttributes.ToArray());
|
aglAttributes.ToArray());
|
||||||
|
|
||||||
MyAGLReportError("aglChoosePixelFormat");
|
MyAGLReportError("aglChoosePixelFormat");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// create the context and share it with the share reference.
|
// create the context and share it with the share reference.
|
||||||
this.contextRef = Agl.aglCreateContext(myAGLPixelFormat, shareContextRef);
|
this.contextRef = Agl.aglCreateContext(myAGLPixelFormat, shareContextRef);
|
||||||
|
@ -160,8 +160,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
SetDrawable(carbonWindow);
|
SetDrawable(carbonWindow);
|
||||||
SetBufferRect(carbonWindow);
|
SetBufferRect(carbonWindow);
|
||||||
Update(carbonWindow);
|
Update(carbonWindow);
|
||||||
|
|
||||||
MakeCurrent(carbonWindow);
|
MakeCurrent(carbonWindow);
|
||||||
|
|
||||||
Debug.Print("context: {0}", contextRef);
|
Debug.Print("context: {0}", contextRef);
|
||||||
|
@ -170,17 +170,17 @@ namespace OpenTK.Platform.MacOS
|
||||||
void SetBufferRect(CarbonWindowInfo carbonWindow)
|
void SetBufferRect(CarbonWindowInfo carbonWindow)
|
||||||
{
|
{
|
||||||
if (carbonWindow.IsControl == false)
|
if (carbonWindow.IsControl == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
System.Windows.Forms.Control ctrl = Control.FromHandle(carbonWindow.WindowRef);
|
System.Windows.Forms.Control ctrl = Control.FromHandle(carbonWindow.WindowRef);
|
||||||
|
|
||||||
if (ctrl.TopLevelControl == null)
|
if (ctrl.TopLevelControl == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Rect rect = API.GetControlBounds(carbonWindow.WindowRef);
|
Rect rect = API.GetControlBounds(carbonWindow.WindowRef);
|
||||||
|
|
||||||
rect.X = (short)ctrl.Left;
|
rect.X = (short)ctrl.Left;
|
||||||
rect.Y = (short)ctrl.Top;
|
rect.Y = (short)ctrl.Top;
|
||||||
|
|
||||||
Debug.Print("Setting buffer_rect for control.");
|
Debug.Print("Setting buffer_rect for control.");
|
||||||
Debug.Print("MacOS Coordinate Rect: {0}", rect);
|
Debug.Print("MacOS Coordinate Rect: {0}", rect);
|
||||||
|
@ -202,15 +202,15 @@ namespace OpenTK.Platform.MacOS
|
||||||
MyAGLReportError("aglEnable");
|
MyAGLReportError("aglEnable");
|
||||||
|
|
||||||
}
|
}
|
||||||
void SetDrawable(CarbonWindowInfo carbonWindow)
|
void SetDrawable(CarbonWindowInfo carbonWindow)
|
||||||
{
|
{
|
||||||
IntPtr windowPort = GetWindowPortForWindowInfo(carbonWindow);
|
IntPtr windowPort = GetWindowPortForWindowInfo(carbonWindow);
|
||||||
|
|
||||||
Agl.aglSetDrawable(contextRef, windowPort);
|
Agl.aglSetDrawable(contextRef, windowPort);
|
||||||
|
|
||||||
MyAGLReportError("aglSetDrawable");
|
MyAGLReportError("aglSetDrawable");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetWindowPortForWindowInfo(CarbonWindowInfo carbonWindow)
|
private static IntPtr GetWindowPortForWindowInfo(CarbonWindowInfo carbonWindow)
|
||||||
{
|
{
|
||||||
|
@ -230,8 +230,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window;
|
CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window;
|
||||||
|
|
||||||
SetDrawable(carbonWindow);
|
SetDrawable(carbonWindow);
|
||||||
SetBufferRect(carbonWindow);
|
SetBufferRect(carbonWindow);
|
||||||
|
|
||||||
Agl.aglUpdateContext(contextRef);
|
Agl.aglUpdateContext(contextRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,23 +274,23 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
#region IGraphicsContext Members
|
#region IGraphicsContext Members
|
||||||
|
|
||||||
bool firstSwap = false;
|
bool firstSwap = false;
|
||||||
public void SwapBuffers()
|
public void SwapBuffers()
|
||||||
{
|
{
|
||||||
// this is part of the hack to avoid dropping the first frame when
|
// this is part of the hack to avoid dropping the first frame when
|
||||||
// using multiple GLControls.
|
// using multiple GLControls.
|
||||||
if (firstSwap == false && carbonWindow.IsControl)
|
if (firstSwap == false && carbonWindow.IsControl)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("--> Resetting drawable. <--");
|
Debug.WriteLine("--> Resetting drawable. <--");
|
||||||
firstSwap = true;
|
firstSwap = true;
|
||||||
SetDrawable(carbonWindow);
|
SetDrawable(carbonWindow);
|
||||||
Update(carbonWindow);
|
Update(carbonWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
Agl.aglSwapBuffers(contextRef);
|
Agl.aglSwapBuffers(contextRef);
|
||||||
MyAGLReportError("aglSwapBuffers");
|
MyAGLReportError("aglSwapBuffers");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MakeCurrent(IWindowInfo window)
|
public void MakeCurrent(IWindowInfo window)
|
||||||
{
|
{
|
||||||
if (Agl.aglSetCurrentContext(contextRef) == false)
|
if (Agl.aglSetCurrentContext(contextRef) == false)
|
||||||
|
@ -331,6 +331,11 @@ namespace OpenTK.Platform.MacOS
|
||||||
mVSync = value;
|
mVSync = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GraphicsMode IGraphicsContext.GraphicsMode
|
||||||
|
{
|
||||||
|
get { return graphics_mode; }
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -405,11 +410,6 @@ namespace OpenTK.Platform.MacOS
|
||||||
get { return (ContextHandle)contextRef; }
|
get { return (ContextHandle)contextRef; }
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsMode IGraphicsContextInternal.GraphicsMode
|
|
||||||
{
|
|
||||||
get { throw new Exception("The method or operation is not implemented."); }
|
|
||||||
}
|
|
||||||
|
|
||||||
void IGraphicsContextInternal.RegisterForDisposal(IDisposable resource)
|
void IGraphicsContextInternal.RegisterForDisposal(IDisposable resource)
|
||||||
{
|
{
|
||||||
throw new Exception("The method or operation is not implemented.");
|
throw new Exception("The method or operation is not implemented.");
|
||||||
|
|
|
@ -221,6 +221,15 @@ namespace OpenTK.Platform.Windows
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region GraphicsMode IGLContext.GraphicsMode
|
||||||
|
|
||||||
|
GraphicsMode IGraphicsContext.GraphicsMode
|
||||||
|
{
|
||||||
|
get { return format; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public event DestroyEvent<IGraphicsContext> Destroy;
|
public event DestroyEvent<IGraphicsContext> Destroy;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -268,15 +277,6 @@ namespace OpenTK.Platform.Windows
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GraphicsMode IGLContextInternal.GraphicsMode
|
|
||||||
|
|
||||||
GraphicsMode IGraphicsContextInternal.GraphicsMode
|
|
||||||
{
|
|
||||||
get { return format; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public IntPtr GetAddress(string function_string)
|
#region public IntPtr GetAddress(string function_string)
|
||||||
|
|
||||||
public IntPtr GetAddress(string function_string)
|
public IntPtr GetAddress(string function_string)
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace OpenTK.Platform.X11
|
||||||
bool vsync_supported;
|
bool vsync_supported;
|
||||||
int vsync_interval;
|
int vsync_interval;
|
||||||
bool glx_loaded;
|
bool glx_loaded;
|
||||||
|
GraphicsMode graphics_mode;
|
||||||
|
|
||||||
bool disposed;
|
bool disposed;
|
||||||
|
|
||||||
|
@ -147,6 +148,8 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
if (!Glx.IsDirect(currentWindow.Display, context.Handle))
|
if (!Glx.IsDirect(currentWindow.Display, context.Handle))
|
||||||
Debug.Print("Warning: Context is not direct.");
|
Debug.Print("Warning: Context is not direct.");
|
||||||
|
|
||||||
|
graphics_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -279,6 +282,15 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region public DisplayMode Mode
|
||||||
|
|
||||||
|
GraphicsMode IGraphicsContext.GraphicsMode
|
||||||
|
{
|
||||||
|
get { return graphics_mode; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void RegisterForDisposal(IDisposable resource)
|
public void RegisterForDisposal(IDisposable resource)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException("Use OpenTK.GraphicsContext instead.");
|
throw new NotSupportedException("Use OpenTK.GraphicsContext instead.");
|
||||||
|
@ -315,15 +327,6 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public DisplayMode Mode
|
|
||||||
|
|
||||||
GraphicsMode IGraphicsContextInternal.GraphicsMode
|
|
||||||
{
|
|
||||||
get { return null; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ContextHandle IGLContextInternal.Context
|
#region ContextHandle IGLContextInternal.Context
|
||||||
|
|
||||||
ContextHandle IGraphicsContextInternal.Context
|
ContextHandle IGraphicsContextInternal.Context
|
||||||
|
|
Loading…
Reference in a new issue