bootloader icon indicating copy to clipboard operation
bootloader copied to clipboard

Framebuffer Unclear

Open tux7k opened this issue 4 years ago • 15 comments

I know it's possible to increase the brightness of pixels but how can you change the color, I see it's possible in logger.rs but way to hard to understand. Does anyone know how to use the framebuffer?

tux7k avatar Jul 29 '21 19:07 tux7k

With VGA text mode, the VGA bios is responsible for turning the color codes into full rgb colors. It seems to be possible to reconfigure this pallette using a specific port write: https://forum.osdev.org/viewtopic.php?f=1&t=23753

bjorn3 avatar Jul 29 '21 19:07 bjorn3

idk if you understand but i'm talking about the uefi framebuffer in boot_info.rs not vga text mode

tux7k avatar Jul 29 '21 20:07 tux7k

I see. In that case I think changing the following two lines would be enough: https://github.com/rust-osdev/bootloader/blob/bc6c1bd62de697dc090ff8e7131cc36b91a531f4/src/binary/logger.rs#L130-L131

In the first case the array values are the red, green amd blue amount padded with a 0. In the second case it is first blue, then green, then red.

bjorn3 avatar Jul 29 '21 20:07 bjorn3

how could i create a pixel though? that's more of what i'm asking about

tux7k avatar Jul 30 '21 16:07 tux7k

The code I referenced is what determines the color. The pixel is written at https://github.com/rust-osdev/bootloader/blob/bc6c1bd62de697dc090ff8e7131cc36b91a531f4/src/binary/logger.rs#L136-L137

The code is a bit harder to read due to the fact that bytes_per_pixel may differ depending on the exact format the pixel data is in (rgb,bgr,greyscale), but it basically writes the pixel data to the right offset in the framebuffer slice.

bjorn3 avatar Jul 30 '21 16:07 bjorn3

so how could i adapt that code to buffer_mut() in boot_info.rs

tux7k avatar Jul 30 '21 16:07 tux7k

I think that somebody needs to create a dedicated guide about explaining this and how it works. Yeah, the OSDev folks have an article about it, but I don't think another would hurt, particularly related to this particular bootloader. It seems like I'm not the only one tripping up on this issue.

On 7/30/21, Exeon @.***> wrote:

so how could i adapt that code to buffer_mut() in boot_info.rs

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rust-osdev/bootloader/issues/187#issuecomment-890014199

-- Signed, Ethin D. Probst

ethindp avatar Jul 30 '21 23:07 ethindp

I found out how you can get it to work. I think I'll document it somewhere

tux7k avatar Jul 31 '21 18:07 tux7k

@actuallyexeon did you manage to write up that document?

spanishpear avatar Apr 09 '22 07:04 spanishpear

@actuallyexeon did you manage to write up that document?

What do you mean by that?

tux7k avatar Apr 09 '22 14:04 tux7k

Ah I was referring to

I think I'll document that somewhere

Did you end up documenting it

spanishpear avatar Apr 09 '22 14:04 spanishpear

Ah I was referring to

I think I'll document that somewhere

Did you end up documenting it

No, but there is a piece of code by @anellie here that you can look at for reference https://github.com/anellie/yacuri/blob/main/kernel/src/graphics/mod.rs and you can also look at this https://github.com/cherrydevs/cherrykernel/blob/master/src/video/mod.rs that I made a while back using anellies code

tux7k avatar Apr 13 '22 16:04 tux7k

Thanks :partying_face:

spanishpear avatar Apr 15 '22 06:04 spanishpear

I tried to change the pixel colour via changing: PixelFormat::BGR => [intensity / 2, intensity, intensity, 0] But I see the colour that I put but no letters only a big line. How can I fix it?

asensio-project avatar Aug 07 '22 01:08 asensio-project