Skip to content

History

Revisions

  • Updated Cosmos Projects (markdown)

    @Meomeowbowow Meomeowbowow committed Dec 31, 2023
    8fd3fa9
  • Add Audio, remove unknown pages, improve formatting

    @ascpixi ascpixi committed Sep 19, 2023
    ffd8d02
  • Destroyed other pages. (markdown)

    @ascpixi ascpixi committed Sep 19, 2023
    d9ff68c
  • Destroyed _Footer (markdown)

    @ascpixi ascpixi committed Sep 19, 2023
    c83b7ce
  • Copy audio page from the docs to the wiki

    @ascpixi ascpixi committed Sep 19, 2023
    630a07c
  • Remove the "message" (you do realize that this is not your personal playground, right?)

    @ascpixi ascpixi committed Sep 19, 2023
    18f62c3
  • Updated _Footer (markdown)

    @Andrey-Pepper Andrey-Pepper committed Aug 20, 2023
    c7714b2
  • Updated _Footer (markdown)

    @Bardia-X Bardia-X committed Aug 15, 2023
    e7c5372
  • Updated _Footer (markdown)

    @szczotapl szczotapl committed Aug 2, 2023
    994e596
  • readded my os... cuz zarlo allowed it

    @PratyushKing PratyushKing committed Jul 30, 2023
    c549d77
  • Updated Cosmos Projects (markdown)

    @PratyushKing PratyushKing committed Jul 30, 2023
    7a4cad3
  • i wanna add my small little falcon os [possibly?]

    @PratyushKing PratyushKing committed Jul 30, 2023
    b54a2ea
  • Created other pages. (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 17, 2023
    ef6ef4d
  • Updated _Sidebar (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 17, 2023
    3bbbf43
  • Updated Cosmos Graphic Subsystem (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 17, 2023
    3cb1daf
  • Updated _Sidebar (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 17, 2023
    b48736d
  • # [look at this Cosmos Graphic Subsystem](https://github.com/CosmosOS/Cosmos/wiki/Cosmos-Graphic-Subsystem) # DO NOT USE THIS CODE IT'S OLD AND OUT OF DATE, IT WILL BE UPDATED SOON # hasn't been updated :/ - gtamasteryt # please update it :( - AnErrupTion # PLEASE UPDATE THE CODE :( -RFN174 # pls update :( -nuppington-bit **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 - The basics 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 COSMOSers get stuck at the first hurdle. ## Rings Rings are a safety feature that COSMOS uses that means the kernel (which runs in RING 3 - USER) can only talk to its own ring an the ones adjacent to it (2 - SYSTEM). This means that it is not possible to create or use a screen in the Kernel or your main COSMOS project, you need to make a new project. This will run in RING 2 - SYSTEM and will thus be able to talk to both the kernel in ring 3 and the hardware ring, where the screen lies, in ring 1 - HAL. To do this right click on your solution on the right hand side and click Add->New Project. Then add a new COSMOS C# OS, call it Hardware. Now you need to both delete the NEW Cosmos boot project (called HardwareBoot) and the Kernel.cs file found within the main Hardware project. The next job is to allow this project to talk to the screen. To do this right click on the references section of the Hardware project->add references. Now search for cosmos and add all the references (by selecting them with shift-click then pressing ENTER) Now go into the AssemblyInfo.cs of the Hardware project file and add the lines bellow: C# ``` using Cosmos.Common; [assembly: Ring(Ring.System)] ``` vb.net ``` Imports Cosmos.Common <Assembly: Ring(Ring.System)> ``` Well done, you now have a project running in Ring 2. ## A display Driver The next step is to actually make a display driver. This is quite self-explanatory. All you need to do is right-click on the hardware project and add a new C# class. Call it DisplayDriver. Now paste this code into the file: C# ## VGA Driver 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: ```c# using Cosmos.HAL; using Sys = Cosmos.System; namespace Display public static void InitGUI() { public class DisplayDriver { protected VGAScreen screen; private int width, height; public DisplayDriver() { screen = new VGAScreen(); } public void init () { screen.SetGraphicsMode(VGAScreen.ScreenSize.Size320x200, VGAScreen.ColorDepth.BitDepth8); screen.Clear(0); width = screen.PixelWidth; height = screen.PixelHeight; } public virtual void setPixel (int x, int y, int c) { if (screen.GetPixel320x200x8((uint)x, (uint)y) != (uint)c) setPixelRaw(x, y, c); } public virtual byte getPixel (int x, int y) { return (byte)screen.GetPixel320x200x8((uint)x, (uint)y); } public virtual void clear () { clear(0); } public virtual void clear (int c) { screen.Clear(c); } public virtual void step() { } public int getWidth() { return width; } public int getHeight() { return height; } public void setPixelRaw (int x, int y, int c) { screen.SetPixel320x200x8((uint)x, (uint)y, (uint)c); } } Cosmos.HAL.Drivers.PCI.Video.VMWareSVGAII driver = new Cosmos.HAL.Drivers.PCI.Video.VMwareSVGAII(); } ``` vb.net ```vb.net Imports Cosmos.HAL Imports Sys = Cosmos.System Namespace Display Public Class DisplayDriver Protected screen As VGAScreen Private width As Integer, height As Integer Public Sub New() screen = New VGAScreen() End Sub Public Sub init() screen.SetGraphicsMode(VGAScreen.ScreenSize.Size320x200, VGAScreen.ColorDepth.BitDepth8) screen.Clear(0) width = screen.PixelWidth height = screen.PixelHeight End Sub Public Overridable Sub setPixel(x As Integer, y As Integer, c As Integer) If screen.GetPixel320x200x8(CUInt(x), CUInt(y)) <> CUInt(c) Then setPixelRaw(x, y, c) End If End Sub Public Overridable Function getPixel(x As Integer, y As Integer) As Byte Return CByte(screen.GetPixel320x200x8(CUInt(x), CUInt(y))) End Function Public Overridable Sub clear() clear(0) End Sub Public Overridable Sub clear(c As Integer) screen.Clear(c) End Sub Public Overridable Sub [step]() End Sub Public Function getWidth() As Integer Return width End Function Public Function getHeight() As Integer Return height End Function Public Sub setPixelRaw(x As Integer, y As Integer, c As Integer) screen.SetPixel320x200x8(CUInt(x), CUInt(y), CUInt(c)) End Sub End Class End Namespace Well done. Let's now set a `Mode` for our driver. It will basically set the resolution of your screen. ```c# driver.SetMode(800, 600); ``` This has all the code you need for making basic screen transactions, but is quite slow and is not buffered. ## Using the driver To use the driver all you need to do is: Please note that the driver we're using has a 32-bit only color depth. And now, let's clear the screen with blue: ```c# driver.Clear(0x255); ``` 1. Add the hardware project as a reference in your main project In order to calculate uint (RRGGBB) colors, you will have to go to this website: `https://www.shodor.org/stella2java/rgbint.html` The format is: `0xRGB INT`. For example, if RR is 0, GG is 0 and BB is 255 (basically pure blue) then it will be: `0x255`. 2. Import the class by adding `using Hardware;` to the top of your kernel Now to call your method in the `Run()` method of your kernel, and... BOOM! A working SVGAII driver with a blue screen. 3. Create a member, `display`, of your kernel class of class `DisplayDriver` Well done! You now have a working VGA (or SVGAII) driver, ready to be used. It's way more complete than CGS for now, and so is better to use. 4. Add this code to your before run function: C# ```c# display = new DisplayDriver(); display.init(); ``` vb.net ```vb.net display = New DisplayDriver() display.init() ``` And you're done, you can now make your own GUI using the `DisplayDriver` On the next page, you'll learn how to properly make a flawlessly moving mouse! --vogon101 ~ ShiningLea

    @kamilthecitratester kamilthecitratester committed Jul 17, 2023
    f36f7bd
  • Updated Creating a GUI The basics (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 17, 2023
    500fca4
  • Updated _Sidebar (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 16, 2023
    75d5bf3
  • Updated Older releases (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 16, 2023
    49b0fa9
  • Created _Footer (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 16, 2023
    bb1a48d
  • Created Cosmos Graphic Subsystem (markdown)

    @kamilthecitratester kamilthecitratester committed Jul 15, 2023
    dbff61c
  • Updated x86 calling convention (markdown)

    @zarlo zarlo committed Feb 9, 2023
    e7c2de8
  • Destroyed ....md ()

    @MishaTy MishaTy committed Jan 24, 2023
    09d05fe
  • Updated Home (markdown)

    @MishaTy MishaTy committed Jan 24, 2023
    a13014f
  • Updated Home (markdown)

    @MishaTy MishaTy committed Jan 24, 2023
    581f912
  • Updated Develop Your Own Operating System in C# or VB.NET (markdown)

    @dashmatic dashmatic committed Oct 21, 2022
    539f5c6
  • Updated _Sidebar (markdown)

    @ascpixi ascpixi committed Aug 31, 2022
    348875b
  • Style improvements, added notice that this guide doesn't work anymore for now

    @ascpixi ascpixi committed Aug 31, 2022
    7fc2303
  • Improve the general style of the document, fix several grammar/stylistic errors

    @ascpixi ascpixi committed Aug 31, 2022
    0066cc6