Hello,
omar wrote:I finally decided to get rid of dealing with stupid bootloaders
Modern boot loaders incorporate many of the fundamental operating system concepts including memory management and drivers; some of which are as complex as little operating systems themselves. It is highly recommended to change this tone if you want to survive in this field.
omar wrote:so I just got GRUB and all is going good. A wrote a hello world kernel in C and it loads and everything is working great.
But is there a way to make a graphical user interface in assembly?
Obviously, yes. If it was not possible in assembly language, it certainly would not be possible in higher level languages. Graphical user interfaces however are
really complex and are tailored to object oriented design.
omar wrote:I mean, I wouldn't like my OS to have a text based interface.
Why not? Providing a text based console is
very important and provides scripting functionality and command line tools that are more suitable and simpler to use as back-end tools rather then integrated in a single graphical application.
omar wrote:Any help anyone? Thanks
If you have to ask, you are not ready. Seriously.
Your original question (How to make graphics) also has nothing to do with graphical user interfaces at all. There are many layers of software to be written, including but not limited to,
1. Video driver
2. Driver communication and command control
3. Higher level Graphics Device Interface
4. Window Manager and GUI services
The video driver would communicate with the device itself or the firmware and provide video controller services such as frame buffer and vertex buffer command lists, video memory mapping and supported video modes. Note that video modes may be available that the monitor does not support. You would need to implement this through
Extended Display Identification Data (EDID) to get monitor device information. The video driver may also use the firmware and provide
Video BIOS services such as
VESA Bios Extensions (VBE) that may be used.
Hobby operating systems typically just set the video mode during boot time however you can also use firmware services yourself.
Of course, you would need a way to send
command lists to the video driver. This would be handed by means of Inter-Process Communication and how the operating system sends
Requests Packets. Of course, the driver should be able to use other operating system services as needed, such as allocating a
heap store or
mapping memory and device registers.
In your case I would just tell GrUB to set a video mode for now and write a video driver around that for now. This would of course mean that you cannot change video modes and also ties your operating system to GrUB.
The
Graphics Device Interface should provide abstract graphics services that are independent of the graphics driver. And the
Window Manager is your
Graphical User Interface. It is responsible for using the GDI to perform device independent rendering to the active video driver across monitors and mapping
window coordinates to
normalized device coordinates.
In other words,
slow down. If you try to jump into graphics too early, you will not make it. Build a strong foundation first before attempting graphics. You could hack it pretty easily, but if you want to write a good graphical user interface you
really need to plan properly.
To actually render, the program sends the request to the operating system which passes it to the GDI. The GDI translates the coordinates to device coordinates, builds the command list and sends it to the device driver for render. The device driver renders the contents to the frame buffer which is what you see on screen (well, a part of the frame buffer main window, anyways.)
The video driver renders to the frame buffer by just writing or reading to it as its mapped to the address space. For example, if the video card is configured in VGA mode, the frame buffer will be mapped to
0xa0000 linear. Higher video modes are mapped between the 2GB-3GB range in the
physical address space. VBE gives you this info, but if you use GrUB, GrUB will pass this to you so you can render. Most video cards use
linear frame buffers (LFB) for high resolution modes so reading and writing them is pretty straight forward - however not always which is why abstraction is important.
Rendering of graphics primitives is a completely different topic of its own so wont discuss that here unless requested.