mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 18:45:36 +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.Right)));
|
||||
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.Size = new System.Drawing.Size(629, 225);
|
||||
this.glControl1.TabIndex = 0;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Control = System.Windows.Forms.Control;
|
||||
|
||||
namespace OpenTK.Platform.MacOS
|
||||
{
|
||||
|
@ -101,28 +102,38 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
void SetBufferRect(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
if (carbonWindow.IsControl)
|
||||
{
|
||||
Rect rect = API.GetControlBounds(carbonWindow.WindowRef);
|
||||
HIRect hirect = API.HIViewGetFrame(carbonWindow.WindowRef);
|
||||
if (carbonWindow.IsControl == false)
|
||||
return;
|
||||
|
||||
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.");
|
||||
Debug.Print("Rect: {0}", rect);
|
||||
Debug.Print("HIRect: {0}", hirect);
|
||||
|
||||
int[] glrect = new int[4];
|
||||
rect.X = (short)ctrl.Left;
|
||||
rect.Y = (short)ctrl.Top;
|
||||
|
||||
Debug.Print("Setting buffer_rect for control.");
|
||||
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[1] = rect.Top;
|
||||
glrect[2] = rect.Width;
|
||||
glrect[3] = rect.Height;
|
||||
glrect[0] = rect.X;
|
||||
glrect[1] = rect.Y;
|
||||
glrect[2] = rect.Width;
|
||||
glrect[3] = rect.Height;
|
||||
|
||||
Agl.aglSetInteger(contextRef, Agl.ParameterNames.AGL_BUFFER_RECT, glrect);
|
||||
MyAGLReportError();
|
||||
Agl.aglSetInteger(contextRef, Agl.ParameterNames.AGL_BUFFER_RECT, glrect);
|
||||
MyAGLReportError();
|
||||
|
||||
Agl.aglEnable(contextRef, Agl.ParameterNames.AGL_BUFFER_RECT);
|
||||
MyAGLReportError();
|
||||
}
|
||||
Agl.aglEnable(contextRef, Agl.ParameterNames.AGL_BUFFER_RECT);
|
||||
MyAGLReportError();
|
||||
|
||||
}
|
||||
void SetDrawable(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
|
|
|
@ -26,26 +26,54 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct Rect
|
||||
{
|
||||
internal short Top;
|
||||
internal short Left;
|
||||
internal short Bottom;
|
||||
internal short Right;
|
||||
short top;
|
||||
short left;
|
||||
short bottom;
|
||||
short right;
|
||||
|
||||
internal Rect(short _left, short _top, short _width, short _height)
|
||||
{
|
||||
Top = _top;
|
||||
Left = _left;
|
||||
Bottom = (short)(_top + _height);
|
||||
Right = (short)(_left + _width);
|
||||
top = _top;
|
||||
left = _left;
|
||||
bottom = (short)(_top + _height);
|
||||
right = (short)(_left + _width);
|
||||
}
|
||||
|
||||
internal short Width { get { return (short)(Right - Left); } }
|
||||
internal short Height { get { return (short)(Bottom - Top); } }
|
||||
internal short X
|
||||
{
|
||||
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()
|
||||
{
|
||||
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();
|
||||
|
||||
mWidth = (short)(region.Right - region.Left);
|
||||
mHeight = (short)(region.Bottom - region.Top);
|
||||
mWidth = (short)(region.Width);
|
||||
mHeight = (short)(region.Height);
|
||||
}
|
||||
|
||||
protected virtual void OnQueryWindowClose(CancelEventArgs e)
|
||||
|
|
Loading…
Reference in a new issue