mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 16:05:32 +00:00
Resolution changing now works ok under windows.
This commit is contained in:
parent
f0f03d58db
commit
5728bf0aa5
|
@ -113,7 +113,7 @@ namespace OpenTK.Frameworks
|
||||||
|
|
||||||
public Framework()
|
public Framework()
|
||||||
{
|
{
|
||||||
Setup(null, 640, 480, new OpenTK.OpenGL.ColorDepth(8, 8, 8, 8), 16, 0, true);
|
Setup(null, 640, 480, new OpenTK.OpenGL.ColorDepth(8, 8, 8, 8), 16, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,10 +172,9 @@ namespace OpenTK.Frameworks
|
||||||
//this.SetStyle(ControlStyles.ResizeRedraw, true); // Redraw On Resize
|
//this.SetStyle(ControlStyles.ResizeRedraw, true); // Redraw On Resize
|
||||||
this.SetStyle(ControlStyles.UserPaint, true); // We'll Handle Painting Ourselves
|
this.SetStyle(ControlStyles.UserPaint, true); // We'll Handle Painting Ourselves
|
||||||
|
|
||||||
this.Width = width;
|
this.Size = new Size(width, height);
|
||||||
this.Height = height;
|
Fullscreen = Implementation.SetResolution(fullscreen);
|
||||||
|
this.Size = new Size(width, height); // Force the window to change to the requested resolution.
|
||||||
Fullscreen = Implementation.ToggleFullscreen(fullscreen);
|
|
||||||
|
|
||||||
if (title == null)
|
if (title == null)
|
||||||
title = "OpenTK Windows application";
|
title = "OpenTK Windows application";
|
||||||
|
|
|
@ -15,11 +15,12 @@ namespace OpenTK.Frameworks
|
||||||
{
|
{
|
||||||
internal abstract class FrameworkImplementation
|
internal abstract class FrameworkImplementation
|
||||||
{
|
{
|
||||||
abstract public void OnHandleCreated(object sender, EventArgs args);
|
public abstract void OnHandleCreated(object sender, EventArgs args);
|
||||||
abstract public bool IsIdle();
|
public abstract bool IsIdle();
|
||||||
abstract public void Setup();
|
public abstract void Setup();
|
||||||
//abstract public void CloseWindow();
|
//abstract public void CloseWindow();
|
||||||
abstract public bool ToggleFullscreen(bool fullscreen);
|
public abstract bool SetResolution(int width, int height, OpenTK.OpenGL.ColorDepth color, bool fullscreen);
|
||||||
|
public abstract bool SetResolution(bool fullscreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,53 @@ namespace OpenTK.Frameworks
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ToggleFullscreen(bool fullscreen)
|
public override bool SetResolution(int width, int height, OpenTK.OpenGL.ColorDepth color, bool fullscreen)
|
||||||
|
{
|
||||||
|
if (fullscreen)
|
||||||
|
{
|
||||||
|
Application.Idle -= framework.OnIdle;
|
||||||
|
//framework.Context.Dispose();
|
||||||
|
|
||||||
|
Api.DeviceMode ScreenSettings = new Api.DeviceMode(); // Device Mode
|
||||||
|
ScreenSettings.Size = (short)Marshal.SizeOf(ScreenSettings); // Size Of The Devmode Structure
|
||||||
|
ScreenSettings.PelsWidth = width; // Selected Screen Width
|
||||||
|
ScreenSettings.PelsHeight = height; // Selected Screen Height
|
||||||
|
ScreenSettings.BitsPerPel = color.Alpha + // Selected Bits Per Pixel
|
||||||
|
color.Red +
|
||||||
|
color.Green +
|
||||||
|
color.Blue;
|
||||||
|
ScreenSettings.Fields = Api.Constants.DM_BITSPERPEL | Api.Constants.DM_PELSWIDTH | Api.Constants.DM_PELSHEIGHT;
|
||||||
|
|
||||||
|
//framework.Context = GLContext.Create(framework, framework.ColorDepth, 16, 0);
|
||||||
|
Application.Idle += framework.OnIdle;
|
||||||
|
|
||||||
|
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
|
||||||
|
if (Api.ChangeDisplaySettings(ref ScreenSettings, Api.Constants.CDS_FULLSCREEN) == Api.Constants.DISP_CHANGE_SUCCESSFUL)
|
||||||
|
{
|
||||||
|
framework.FormBorderStyle = FormBorderStyle.None;
|
||||||
|
framework.StartPosition = FormStartPosition.Manual;
|
||||||
|
framework.Location = new System.Drawing.Point(0, 0);
|
||||||
|
//framework.Region = new Region(new Rectangle(0, 0, width, height));
|
||||||
|
framework.Capture = true;
|
||||||
|
framework.SetTopLevel(true);
|
||||||
|
Cursor.Hide();
|
||||||
|
|
||||||
|
framework.Size = new Size(width, height);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
framework.Size = new Size(width, height);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool SetResolution(bool fullscreen)
|
||||||
{
|
{
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +122,7 @@ namespace OpenTK.Frameworks
|
||||||
framework.FormBorderStyle = FormBorderStyle.None;
|
framework.FormBorderStyle = FormBorderStyle.None;
|
||||||
framework.StartPosition = FormStartPosition.Manual;
|
framework.StartPosition = FormStartPosition.Manual;
|
||||||
framework.Location = new System.Drawing.Point(0, 0);
|
framework.Location = new System.Drawing.Point(0, 0);
|
||||||
//this.Region = new Region(new Rectangle(0, 0, width, height));
|
//framework.Region = new Region(new Rectangle(0, 0, width, height));
|
||||||
framework.Capture = true;
|
framework.Capture = true;
|
||||||
framework.SetTopLevel(true);
|
framework.SetTopLevel(true);
|
||||||
Cursor.Hide();
|
Cursor.Hide();
|
||||||
|
|
|
@ -44,7 +44,12 @@ namespace OpenTK.Frameworks
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ToggleFullscreen(bool fullscreen)
|
public override bool SetResolution(int width, int height, OpenTK.OpenGL.ColorDepth color, bool fullscreen)
|
||||||
|
{
|
||||||
|
throw new Exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool SetResolution(bool fullscreen)
|
||||||
{
|
{
|
||||||
throw new Exception("The method or operation is not implemented.");
|
throw new Exception("The method or operation is not implemented.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue