mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-10 18:21:20 +00:00
Re-write of GetFullScreenCanvas
This commit is contained in:
parent
beb48f29fd
commit
efa36d1600
1 changed files with 60 additions and 40 deletions
|
|
@ -12,55 +12,75 @@ namespace Cosmos.System.Graphics
|
|||
//VGADriver,
|
||||
VBEDriver
|
||||
}
|
||||
|
||||
|
||||
private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter);
|
||||
|
||||
|
||||
private static bool SVGAIIExists = SVGAIIDevice.DeviceExists;
|
||||
|
||||
|
||||
private static VideoDriver videoDevice;
|
||||
|
||||
|
||||
// Created null - NullReferenceException when calling GetFullScreenCanvas() with 0 overloads
|
||||
private static Canvas MyVideoDriver = null;
|
||||
|
||||
public static Canvas GetFullScreenCanvas(Mode mode)
|
||||
{
|
||||
Global.mDebugger.SendInternal("GetFullScreenCanvas() with mode " + mode);
|
||||
|
||||
/* Use SVGAII When Exists in PCI */
|
||||
if(SVGAIIExists)
|
||||
videoDevice = VideoDriver.VMWareSVGAIIDriver;
|
||||
|
||||
// If there's no instance of a video driver created (which there isn't), create it:
|
||||
if (MyVideoDriver == null)
|
||||
{
|
||||
// If running on VMWare and using SVGAII, then use that driver:
|
||||
if (videoDevice == VideoDriver.VMWareSVGAIIDriver)
|
||||
{
|
||||
// Creates the instance
|
||||
return MyVideoDriver = new SVGAIIScreen(mode);
|
||||
}
|
||||
// If not running on VMWare, then use the VESA BIOS Extensions:
|
||||
else if (videoDevice == VideoDriver.VBEDriver)
|
||||
{
|
||||
// Creates the instance
|
||||
return MyVideoDriver = new VBEScreen(mode);
|
||||
}
|
||||
}
|
||||
|
||||
/* We have already got a VideoDriver instance, simply change its mode */
|
||||
MyVideoDriver.Mode = mode;
|
||||
return MyVideoDriver;
|
||||
}
|
||||
|
||||
public static Canvas GetFullScreenCanvas()
|
||||
{
|
||||
Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode");
|
||||
// If MyVideoDriver is null (hasn't checked if VMWare SVGA exists),
|
||||
// Do necessary check and set to default gfx mode
|
||||
if (MyVideoDriver == null)
|
||||
{
|
||||
return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode);
|
||||
}
|
||||
// If it's not null, simply change graphics mode */
|
||||
else
|
||||
{
|
||||
MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode;
|
||||
return MyVideoDriver;
|
||||
}
|
||||
// Old check left for reference
|
||||
/*
|
||||
if (videoDevice == VideoDriver.VMWareSVGAIIDriver)
|
||||
{
|
||||
|
||||
/*
|
||||
WARNING: MyVideoDriver is initiated as null - needs changing!
|
||||
We have already got a VideoDriver instance
|
||||
- reset its mode to DefaultGraphicMode */
|
||||
return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
public static Canvas GetFullScreenCanvas(Mode mode)
|
||||
{
|
||||
Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode");
|
||||
// If MyVideoDriver is null (hasn't checked if VMWare SVGA exists),
|
||||
// Do necessary check and set gfx mode as specified (mode)
|
||||
if (MyVideoDriver == null)
|
||||
{
|
||||
if (SVGAIIExists)
|
||||
{
|
||||
// Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode
|
||||
// MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set.
|
||||
// returns MyVideoDriver as the Canvas
|
||||
videoDevice = VideoDriver.VMWareSVGAIIDriver;
|
||||
MyVideoDriver = new SVGAIIScreen(mode);
|
||||
MyVideoDriver.Mode = mode;
|
||||
return MyVideoDriver;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards)
|
||||
videoDevice = VideoDriver.VBEDriver;
|
||||
MyVideoDriver = new VBEScreen(mode);
|
||||
MyVideoDriver.Mode = mode;
|
||||
return MyVideoDriver;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If MyVideoDriver has been initialized before (Graphics mode has previously been set)
|
||||
// Change the graphics mode to the mode specified
|
||||
MyVideoDriver.Mode = mode;
|
||||
return MyVideoDriver;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue