-
Notifications
You must be signed in to change notification settings - Fork 569
Creating a GUI The basics
Updated by ShiningLea as of April the 6th of 2020. NOTE: There is the Cosmos Graphics Subsystem, but right now you can't do much with it. This tutorial will use a proper VGA driver instead of CGS.
Creating a GUI in Cosmos is hard. The code itself is easy to understand, but most of the tutorials out there are quite outdated and no longer work. Once you have a screen object, the rest is quite simple but most people get stuck at the first hurdle.
First, we need a VGA Driver. This is the core of every GUI. Here, we will use VMware's SVGA II driver. To do so, add a line in your code like so:
public static void InitGUI()
{
Cosmos.HAL.Drivers.PCI.Video.VMWareSVGAII driver = new Cosmos.HAL.Drivers.PCI.Video.VMWareSVGAII();
}
Well done. Let's now set a Mode
for our driver. It will basically set the resolution of your screen.
int width = 800;
int height = 600;
driver.SetMode(width, height);
Please note that the driver we're using has a 32-bit only color depth. And now, let's clear the screen with blue:
System.Drawing.Color color = System.Drawing.Color.Blue;
driver.Clear((uint)color.ToArgb());
Now to call your method in the Run()
method of your kernel, and... BOOM! A working SVGAII driver with a blue screen.
Well done! You now have a working SVGAII driver, ready to be used. It's way more complete than CGS for now, and so is better to use.
On the next page, you'll learn how to properly make a flawlessly moving mouse!
~ ShiningLea