https://github.com/teascade/glerminal
A lightweight terminal made with OpenGL
https://github.com/teascade/glerminal
opengl rust terminal
Last synced: about 1 year ago
JSON representation
A lightweight terminal made with OpenGL
- Host: GitHub
- URL: https://github.com/teascade/glerminal
- Owner: Teascade
- License: mit
- Created: 2018-03-13T18:48:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-21T20:25:28.000Z (over 6 years ago)
- Last Synced: 2025-02-02T18:26:29.259Z (over 1 year ago)
- Topics: opengl, rust, terminal
- Language: Rust
- Homepage:
- Size: 1.09 MB
- Stars: 25
- Watchers: 4
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# GLerminal, an OpenGL terminal
[](https://travis-ci.org/Teascade/glerminal)
[](https://docs.rs/glerminal)
[](https://crates.io/crates/glerminal)
Read our [Code of Conduct](CODE_OF_CONDUCT.md) and join our [Discord server](https://discord.gg/Wg6D2Rk) if you want to chat!
A lightweight terminal made with OpenGL from the ground-up.
With this terminal, you're able to make the terminal applications or games you've always wanted, but with a terminal that looks the same for everyone, because it's made with OpenGL and doesn't use the computer's native terminal!
Currently supported features include:
- Moving the cursor within the Terminal
- Changing foreground and background colors to whatever you want!
- Shaking text
- A text-parser that will make it easy to write whatever you want and make it look cool!
- Parseable text example: `"Hello, [fg=red]this is red[/fg] and [shake=1.0]this is shaking[/shake]."`
- Drawing of multiple text buffers (grids of text) on top of eachother
- A menu system that allows for easy creation and usage of menus for selecting and pressing stuff! (See docs for more)
- Requires the `menu_systems` optional feature to be enabled
- Write any characters up to 16-bits that your font supports
***Note: Requires OpenGL 3.3+ support***
### Table of Contents
- [How to use](#how-to-use)
- [Custom font?](#custom-font)
- [Contributing & Code of Conduct](#contributing-&-code-of-conduct)
- [License](#license)
### How to use
Extensive documentation can be found at: [docs.rs][docs].
Just add the following line to your `Cargo.toml`:
```toml
[dependencies]
glerminal = "0.3"
```
And then using this crate is quite simple:
```rust
extern crate glerminal; // Not required if running 2018 edition
use glerminal::terminal::TerminalBuilder;
use glerminal::text_buffer::TextBuffer;
fn main() {
let terminal = TerminalBuilder::new()
.with_title("Hello GLerminal!")
.with_dimensions((1280, 720))
.build();
let mut text_buffer;
match TextBuffer::create(&terminal, (80, 24)) {
Ok(buffer) => text_buffer = buffer,
Err(error) => panic!(format!("Failed to initialize text buffer: {}", error)),
}
text_buffer.write("Hello, GLerminal!");
terminal.flush(&mut text_buffer);
while terminal.refresh() {
terminal.draw(&text_buffer);
}
}
```

### Custom font?
The default font that comes with GLerminal is a render of [Source Code Pro][scp_font] and only includes a few more popular unicode blocks, to save space on the end product (the default font is compiled into the library).
The following blocks are included in the default font:
- [`Basic latin`][basic_latin]
- [`Latin-1 supplement`][latin_1_supplement]
- [`Latin Extended-A`][latin_extended_a]
- [`Currency Symbols`][currency_symbols]
- [`Box Drawing`][box_drawing]
- [`Block Elements`][block_elements]
To make a custom font, you have to use either the [`BMFont standard / .fnt`][bmfont_standard], or `.sfl`,
and software that can produce such files are [BMFont][bmfont] (can produce only `.fnt`), or [Fontbuilder][fontbuilder] (can produce both).
The font image **needs** to be RGBA PNG.
It is advised to use [Fontbuilder][fontbuilder], as (at least after some testing) the png font images generated by [BMFont][bmfont] (and their antialiasing) are sub-par compared to [Fontbuilder][fontbuilder], though Fontbuilder might be difficult to build on windows devices (It is possible with MinGW though).
**Note** If using Fontbuilder, it is highly recommended to use [this fork][teascade_fontbuilder] as it contains a critical fix for .sfl font exporting.
After that it is advisable to look at glerminal [font documentation][font_docs] on how a custom font is then loaded to use.
### Contributing & Code of Conduct
You are welcome to contribute to this project, but before do review the [Contributing guidelines](CONTRIBUTING.md).
A Code of Conduct can also be found in the repository as [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md),
please review it before interacting with the community.
### License
This crate is distributed under the terms of [the MIT License][license].
This crate also uses a font as a default font, called [Source Code Pro][scp_font], which is distributed under the terms of [SIL OFL Version 1.1][scp_license].
[docs]: https://docs.rs/glerminal
[license]: LICENSE.md
[scp_font]: https://github.com/adobe-fonts/source-code-pro
[scp_license]: LICENSE_SOURCE_CODE_PRO.md
[bmfont]: http://www.angelcode.com/products/bmfont/
[bmfont_standard]: http://www.angelcode.com/products/bmfont/doc/render_text.html
[fontbuilder]: https://github.com/andryblack/fontbuilder
[teascade_fontbuilder]: https://github.com/Teascade/fontbuilder
[font_docs]: https://docs.rs/glerminal/0.3.0/glerminal/struct.Font.html
[basic_latin]: https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
[latin_1_supplement]: https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
[latin_extended_a]: https://en.wikipedia.org/wiki/Latin_Extended-A
[currency_symbols]: https://en.wikipedia.org/wiki/Currency_Symbols_(Unicode_block)
[box_drawing]: https://en.wikipedia.org/wiki/Box_Drawing
[block_elements]: https://en.wikipedia.org/wiki/Block_Elements