mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-06 13:00:42 +00:00
Correct position of buffer rect to be within the GLControl.
This commit is contained in:
parent
11430665f3
commit
d3001f8a26
|
@ -73,7 +73,7 @@ namespace Examples.WinForms
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.glControl1.BackColor = System.Drawing.SystemColors.ControlDarkDark;
|
this.glControl1.BackColor = System.Drawing.SystemColors.ControlDarkDark;
|
||||||
this.glControl1.Location = new System.Drawing.Point(10, 10);
|
this.glControl1.Location = new System.Drawing.Point(10, 30);
|
||||||
this.glControl1.Name = "glControl1";
|
this.glControl1.Name = "glControl1";
|
||||||
this.glControl1.Size = new System.Drawing.Size(629, 225);
|
this.glControl1.Size = new System.Drawing.Size(629, 225);
|
||||||
this.glControl1.TabIndex = 0;
|
this.glControl1.TabIndex = 0;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using Control = System.Windows.Forms.Control;
|
||||||
|
|
||||||
namespace OpenTK.Platform.MacOS
|
namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
|
@ -101,28 +102,38 @@ namespace OpenTK.Platform.MacOS
|
||||||
}
|
}
|
||||||
void SetBufferRect(CarbonWindowInfo carbonWindow)
|
void SetBufferRect(CarbonWindowInfo carbonWindow)
|
||||||
{
|
{
|
||||||
if (carbonWindow.IsControl)
|
if (carbonWindow.IsControl == false)
|
||||||
{
|
return;
|
||||||
Rect rect = API.GetControlBounds(carbonWindow.WindowRef);
|
|
||||||
HIRect hirect = API.HIViewGetFrame(carbonWindow.WindowRef);
|
System.Windows.Forms.Control ctrl = Control.FromHandle(carbonWindow.WindowRef);
|
||||||
|
|
||||||
|
if (ctrl.TopLevelControl == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Rect rect = API.GetControlBounds(carbonWindow.WindowRef);
|
||||||
|
|
||||||
Debug.Print("Setting buffer_rect for control.");
|
rect.X = (short)ctrl.Left;
|
||||||
Debug.Print("Rect: {0}", rect);
|
rect.Y = (short)ctrl.Top;
|
||||||
Debug.Print("HIRect: {0}", hirect);
|
|
||||||
|
Debug.Print("Setting buffer_rect for control.");
|
||||||
int[] glrect = new int[4];
|
Debug.Print("MacOS Coordinate Rect: {0}", rect);
|
||||||
|
|
||||||
|
rect.Y = (short)(ctrl.TopLevelControl.ClientSize.Height - rect.Y - rect.Height);
|
||||||
|
Debug.Print(" AGL Coordinate Rect: {0}", rect);
|
||||||
|
|
||||||
|
int[] glrect = new int[4];
|
||||||
|
|
||||||
glrect[0] = rect.Left;
|
glrect[0] = rect.X;
|
||||||
glrect[1] = rect.Top;
|
glrect[1] = rect.Y;
|
||||||
glrect[2] = rect.Width;
|
glrect[2] = rect.Width;
|
||||||
glrect[3] = rect.Height;
|
glrect[3] = rect.Height;
|
||||||
|
|
||||||
Agl.aglSetInteger(contextRef, Agl.ParameterNames.AGL_BUFFER_RECT, glrect);
|
Agl.aglSetInteger(contextRef, Agl.ParameterNames.AGL_BUFFER_RECT, glrect);
|
||||||
MyAGLReportError();
|
MyAGLReportError();
|
||||||
|
|
||||||
Agl.aglEnable(contextRef, Agl.ParameterNames.AGL_BUFFER_RECT);
|
Agl.aglEnable(contextRef, Agl.ParameterNames.AGL_BUFFER_RECT);
|
||||||
MyAGLReportError();
|
MyAGLReportError();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void SetDrawable(CarbonWindowInfo carbonWindow)
|
void SetDrawable(CarbonWindowInfo carbonWindow)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,26 +26,54 @@ namespace OpenTK.Platform.MacOS.Carbon
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
internal struct Rect
|
internal struct Rect
|
||||||
{
|
{
|
||||||
internal short Top;
|
short top;
|
||||||
internal short Left;
|
short left;
|
||||||
internal short Bottom;
|
short bottom;
|
||||||
internal short Right;
|
short right;
|
||||||
|
|
||||||
internal Rect(short _left, short _top, short _width, short _height)
|
internal Rect(short _left, short _top, short _width, short _height)
|
||||||
{
|
{
|
||||||
Top = _top;
|
top = _top;
|
||||||
Left = _left;
|
left = _left;
|
||||||
Bottom = (short)(_top + _height);
|
bottom = (short)(_top + _height);
|
||||||
Right = (short)(_left + _width);
|
right = (short)(_left + _width);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal short Width { get { return (short)(Right - Left); } }
|
internal short X
|
||||||
internal short Height { get { return (short)(Bottom - Top); } }
|
{
|
||||||
|
get { return left; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
short width = Width;
|
||||||
|
left = value;
|
||||||
|
right = (short)(left + width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal short Y
|
||||||
|
{
|
||||||
|
get { return top; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
short height = Height;
|
||||||
|
top = value;
|
||||||
|
bottom = (short)(top + height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal short Width
|
||||||
|
{
|
||||||
|
get { return (short)(right - left); }
|
||||||
|
set { right = (short)(left + value); }
|
||||||
|
}
|
||||||
|
internal short Height
|
||||||
|
{
|
||||||
|
get { return (short)(bottom - top); }
|
||||||
|
set { bottom = (short)(top + value); }
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format(
|
return string.Format(
|
||||||
"Rect: [{0}, {1}, {2}, {3}]", Top, Left, Width, Height);
|
"Rect: [{0}, {1}, {2}, {3}]", X, Y, Width, Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -482,8 +482,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
Rect region = GetRegion();
|
Rect region = GetRegion();
|
||||||
|
|
||||||
mWidth = (short)(region.Right - region.Left);
|
mWidth = (short)(region.Width);
|
||||||
mHeight = (short)(region.Bottom - region.Top);
|
mHeight = (short)(region.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnQueryWindowClose(CancelEventArgs e)
|
protected virtual void OnQueryWindowClose(CancelEventArgs e)
|
||||||
|
|
Loading…
Reference in a new issue