Resolution changing now works ok under windows.

This commit is contained in:
the_fiddler 2006-10-16 00:04:42 +00:00
parent f0f03d58db
commit 5728bf0aa5
4 changed files with 64 additions and 13 deletions

View file

@ -113,7 +113,7 @@ namespace OpenTK.Frameworks
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.UserPaint, true); // We'll Handle Painting Ourselves
this.Width = width;
this.Height = height;
Fullscreen = Implementation.ToggleFullscreen(fullscreen);
this.Size = new Size(width, height);
Fullscreen = Implementation.SetResolution(fullscreen);
this.Size = new Size(width, height); // Force the window to change to the requested resolution.
if (title == null)
title = "OpenTK Windows application";

View file

@ -15,11 +15,12 @@ namespace OpenTK.Frameworks
{
internal abstract class FrameworkImplementation
{
abstract public void OnHandleCreated(object sender, EventArgs args);
abstract public bool IsIdle();
abstract public void Setup();
public abstract void OnHandleCreated(object sender, EventArgs args);
public abstract bool IsIdle();
public abstract void Setup();
//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);
}
}
}

View file

@ -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)
{
@ -61,7 +107,7 @@ namespace OpenTK.Frameworks
ScreenSettings.Size = (short)Marshal.SizeOf(ScreenSettings); // Size Of The Devmode Structure
ScreenSettings.PelsWidth = framework.Width; // Selected Screen Width
ScreenSettings.PelsHeight = framework.Height; // Selected Screen Height
ScreenSettings.BitsPerPel = framework.ColorDepth.Alpha + // Selected Bits Per Pixel
ScreenSettings.BitsPerPel = framework.ColorDepth.Alpha + // Selected Bits Per Pixel
framework.ColorDepth.Red +
framework.ColorDepth.Green +
framework.ColorDepth.Blue;
@ -76,7 +122,7 @@ namespace OpenTK.Frameworks
framework.FormBorderStyle = FormBorderStyle.None;
framework.StartPosition = FormStartPosition.Manual;
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.SetTopLevel(true);
Cursor.Hide();

View file

@ -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.");
}