Update FullScreenCanvas.cs

This commit is contained in:
Arawn Davies 2018-02-22 11:57:13 +00:00 committed by GitHub
parent d61cfa6c06
commit 359f8ea974
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,7 +18,8 @@ namespace Cosmos.System.Graphics
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)
@ -30,20 +31,23 @@ namespace Cosmos.System.Graphics
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);
}
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 istance simple change its mode */
/* We have already got a VideoDriver instance, simply change its mode */
MyVideoDriver.Mode = mode;
return MyVideoDriver;
}