blog_os icon indicating copy to clipboard operation
blog_os copied to clipboard

Add links to resources about drawing on the screen

Open nebrelbug opened this issue 6 years ago • 14 comments

I'm following through the tutorials and have started modifying and adding my own features. One thing that I can't find at all on the web, though, is how to display graphics on the screen. Do you write to a specific memory location, or use an I/O port? Are there OpenGL libraries that work on baremetal or that we could make work? I'd love to see some links to good resources on that topic.

nebrelbug avatar Jun 07 '18 09:06 nebrelbug

By drawing on the screen, I mean like individual pixels and shapes, not VGA.

nebrelbug avatar Jun 07 '18 09:06 nebrelbug

The VGA text buffer is relatively special by working on characters instead of pixels. A normal framebuffer operates on individual pixels and this mode is supported by VGA too.

Personally I only used the text buffer, so I can't give you good links. But the VGA Hardware page of the OSDev wiki looks useful to learn about the different VGA modes. Also, you could look at how the Redox project does it.

For the blog, I plan to eventually switch to using a framebuffer instead of text mode eventually, because the text mode is not supported for UEFI booting. See https://github.com/phil-opp/blog_os/issues/349#issuecomment-385271776.

phil-opp avatar Jun 07 '18 09:06 phil-opp

@phil-opp Thanks! Do operating systems like Apple, Windows, etc. use a VGA framebuffer or do they do something different?

nebrelbug avatar Jun 07 '18 11:06 nebrelbug

@nebrelbug real OSs tend to have specialised support for the graphics chipset or discrete graphics card, but it’s difficult and a huge time investment to develop drivers for them

IsaacWoods avatar Jun 07 '18 12:06 IsaacWoods

Cool! Well, I'll work on figuring them out and maybe someday I'll write a tutorial and make a pull request :)

nebrelbug avatar Jun 11 '18 04:06 nebrelbug

@nebrelbug Cool, good luck! A tutorial on this topic would be great!

phil-opp avatar Jun 11 '18 14:06 phil-opp

@phil-opp just from the limited research I've done, it looks like it'd be way easier to do with a UEFI kernel set up first, since VESA and VBE (I think?) only work with 16-bit code? I'm going to see if I can get a UEFI kernel running.

nebrelbug avatar Jun 14 '18 07:06 nebrelbug

Cool! Maybe https://github.com/phil-opp/blog_os/issues/349#issuecomment-373184383 and https://github.com/phil-opp/blog_os/issues/349#issuecomment-381360289 help.

phil-opp avatar Jun 14 '18 08:06 phil-opp

For the blog, I plan to eventually switch to using a framebuffer instead of text mode eventually, because the text mode is not supported for UEFI booting.

Actually, a memory mapped VGA text buffer is so much beginner-friendly. Meaning, there is no need explaining the Bresenheim's algorithm (one for drawing the line and another variation for the arc) and other CG (Computer Graphics) entry level stuff.

@phil-opp , any chance you would not deprecate its description completely?

dodikk avatar Jul 04 '18 15:07 dodikk

The plan is to use a bitmap font, so we wouldn't need to do any rasterization. That said, there aren't any concrete plans yet, so if it turns out to be too complicated I will think of a different solution (maybe keep the text buffer post and insert an additional framebuffer post).

phil-opp avatar Jul 05 '18 10:07 phil-opp

@phil-opp any updates on using a framebuffer?

nebrelbug avatar Nov 24 '18 01:11 nebrelbug

@nebrelbug I'm looking into it right now. I was already able to configure the vga hardware to use a 640x480 pixel buffer and output some pixels to the screen. Now I'm working on making this a cargo feature of the bootloader.

phil-opp avatar Nov 25 '18 14:11 phil-opp

@nebrelbug I added initial support for a small 320x200 VGA framebuffer to the bootloader in https://github.com/rust-osdev/bootloader/pull/35.

phil-opp avatar Nov 25 '18 17:11 phil-opp

Have there been any updates to this? I was curious about adding graphics to my fork and I wasn't sure if the bootimage crate in the tutorial would support this and if not, how I would go about adding it.

C-Loftus avatar Nov 05 '21 03:11 C-Loftus