https://github.com/rust-osdev/vga
Library to program vga hardware.
https://github.com/rust-osdev/vga
Last synced: 7 months ago
JSON representation
Library to program vga hardware.
- Host: GitHub
- URL: https://github.com/rust-osdev/vga
- Owner: rust-osdev
- License: apache-2.0
- Created: 2020-03-12T15:07:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-12T22:21:28.000Z (over 2 years ago)
- Last Synced: 2025-06-11T04:26:19.919Z (8 months ago)
- Language: Rust
- Size: 185 KB
- Stars: 58
- Watchers: 4
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
[](https://github.com/rust-osdev/vga/actions?query=workflow%3ABuild) [](https://docs.rs/vga/)
# vga
This crate provides vga specific functions, data structures,
and access to various registers.
Memory addresses `0xA0000 -> 0xBFFFF` must be readable and writeable
this crate to work properly.
**Note: This crate is currently experimental and subject to change since it's in active development.**
## Text Mode
```rust
use vga::colors::{Color16, TextModeColor};
use vga::writers::{ScreenCharacter, TextWriter, Text80x25};
let text_mode = Text80x25::new();
let color = TextModeColor::new(Color16::Yellow, Color16::Black);
let screen_character = ScreenCharacter::new(b'T', color);
text_mode.set_mode();
text_mode.clear_screen();
text_mode.write_character(0, 0, screen_character);
```
## Graphics Mode
```rust
use vga::colors::Color16;
use vga::writers::{Graphics640x480x16, GraphicsWriter};
let mode = Graphics640x480x16::new();
mode.set_mode();
mode.clear_screen(Color16::Black);
mode.draw_line((80, 60), (80, 420), Color16::White);
mode.draw_line((80, 60), (540, 60), Color16::White);
mode.draw_line((80, 420), (540, 420), Color16::White);
mode.draw_line((540, 420), (540, 60), Color16::White);
mode.draw_line((80, 90), (540, 90), Color16::White);
for (offset, character) in "Hello World!".chars().enumerate() {
mode.draw_character(270 + offset * 8, 72, character, Color16::White)
}
```