Permalink
Browse files

add some terminus fonts to the text renderer

it's wtf anyway, but that should be expected.
  • Loading branch information...
1 parent e5a02da commit 6c2fb90ef58628b0e12d017f9d5ac4322cdeb09f @penma committed Jun 3, 2011
Showing with 106 additions and 8 deletions.
  1. +105 −7 TextRender.pm
  2. +1 −1 wtf
View
@@ -1,4 +1,4 @@
-package TextRender;;
+package TextRender;
use strict;
use warnings;
@@ -7,12 +7,12 @@ use OpenGL qw(:all);
use OpenGL::State;
sub mc {
- my ($va, $vb) = @_;
- my $glyph = [[], [], [], [], [], [], [], []];
+ my $glyph = [];
- for (my $x = 31; $x >= 0; $x--) {
- $glyph->[ int($x / 8)]->[$x % 8] = ($va >> $x) & 1;
- $glyph->[4 + int($x / 8)]->[$x % 8] = ($vb >> $x) & 1;
+ for my $r (0 .. (@_ - 1)) {
+ for (my $x = 31; $x >= 0; $x--) {
+ $glyph->[4 * $r + int($x / 8)]->[$x % 8] = ($_[$r] >> $x) & 1;
+ }
}
return $glyph;
@@ -93,7 +93,105 @@ my %fonts = (
"z" => mc(0x203c0000, 0x003c0810), "{" => mc(0x04080830, 0x00300808),
"|" => mc(0x10101010, 0x00101010), "}" => mc(0x2010100c, 0x000c1010),
"~" => mc(0x920c0000, 0x00000060),
- }
+ }, ter16 => {
+ " " => mc(0x00000000, 0x00000000, 0x00000000, 0x00000000), "!" => mc(0x08080000, 0x08080808, 0x08080008, 0x00000000),
+ '"' => mc(0x24242400, 0x00000000, 0x00000000, 0x00000000), "#" => mc(0x24240000, 0x24247e24, 0x2424247e, 0x00000000),
+ '$' => mc(0x3e080800, 0x3e090949, 0x3e494848, 0x00000808), "%" => mc(0x29260000, 0x08081016, 0x324a3404, 0x00000000),
+ "&" => mc(0x24180000, 0x520c1824, 0x5c222222, 0x00000000), "'" => mc(0x08080800, 0x00000000, 0x00000000, 0x00000000),
+ "(" => mc(0x08100000, 0x04040404, 0x10080404, 0x00000000), ")" => mc(0x08040000, 0x10101010, 0x04081010, 0x00000000),
+ "*" => mc(0x00000000, 0x7e182400, 0x00002418, 0x00000000), "+" => mc(0x00000000, 0x3e080800, 0x00000808, 0x00000000),
+ "," => mc(0x00000000, 0x00000000, 0x08080000, 0x00000004), "-" => mc(0x00000000, 0x7e000000, 0x00000000, 0x00000000),
+ "." => mc(0x00000000, 0x00000000, 0x08080000, 0x00000000), "/" => mc(0x20200000, 0x08081010, 0x02020404, 0x00000000),
+ "0" => mc(0x423c0000, 0x4a526242, 0x3c424246, 0x00000000), "1" => mc(0x18100000, 0x10101014, 0x7c101010, 0x00000000),
+ "2" => mc(0x423c0000, 0x10204042, 0x7e020408, 0x00000000), "3" => mc(0x423c0000, 0x40384042, 0x3c424240, 0x00000000),
+ "4" => mc(0x60400000, 0x42444850, 0x4040407e, 0x00000000), "5" => mc(0x027e0000, 0x403e0202, 0x3c424040, 0x00000000),
+ "6" => mc(0x04380000, 0x423e0202, 0x3c424242, 0x00000000), "7" => mc(0x407e0000, 0x10202040, 0x08080810, 0x00000000),
+ "8" => mc(0x423c0000, 0x423c4242, 0x3c424242, 0x00000000), "9" => mc(0x423c0000, 0x7c424242, 0x1c204040, 0x00000000),
+ ":" => mc(0x00000000, 0x00080800, 0x08080000, 0x00000000), ";" => mc(0x00000000, 0x00080800, 0x08080000, 0x00000004),
+ "<" => mc(0x20000000, 0x02040810, 0x20100804, 0x00000000), "=" => mc(0x00000000, 0x00007e00, 0x0000007e, 0x00000000),
+ ">" => mc(0x02000000, 0x20100804, 0x02040810, 0x00000000), "?" => mc(0x423c0000, 0x10204242, 0x10100010, 0x00000000),
+ "@" => mc(0x413e0000, 0x45454579, 0x7e015965, 0x00000000), "A" => mc(0x423c0000, 0x7e424242, 0x42424242, 0x00000000),
+ "B" => mc(0x423e0000, 0x423e4242, 0x3e424242, 0x00000000), "C" => mc(0x423c0000, 0x02020242, 0x3c424202, 0x00000000),
+ "D" => mc(0x221e0000, 0x42424242, 0x1e224242, 0x00000000), "E" => mc(0x027e0000, 0x021e0202, 0x7e020202, 0x00000000),
+ "F" => mc(0x027e0000, 0x021e0202, 0x02020202, 0x00000000), "G" => mc(0x423c0000, 0x72020242, 0x3c424242, 0x00000000),
+ "H" => mc(0x42420000, 0x427e4242, 0x42424242, 0x00000000), "I" => mc(0x081c0000, 0x08080808, 0x1c080808, 0x00000000),
+ "J" => mc(0x20700000, 0x20202020, 0x1c222220, 0x00000000), "K" => mc(0x22420000, 0x06060a12, 0x4222120a, 0x00000000),
+ "L" => mc(0x02020000, 0x02020202, 0x7e020202, 0x00000000), "M" => mc(0x63410000, 0x41494955, 0x41414141, 0x00000000),
+ "N" => mc(0x42420000, 0x524a4642, 0x42424262, 0x00000000), "O" => mc(0x423c0000, 0x42424242, 0x3c424242, 0x00000000),
+ "P" => mc(0x423e0000, 0x3e424242, 0x02020202, 0x00000000), "Q" => mc(0x423c0000, 0x42424242, 0x3c524242, 0x00000040),
+ "R" => mc(0x423e0000, 0x3e424242, 0x4222120a, 0x00000000), "S" => mc(0x423c0000, 0x403c0202, 0x3c424240, 0x00000000),
+ "T" => mc(0x087f0000, 0x08080808, 0x08080808, 0x00000000), "U" => mc(0x42420000, 0x42424242, 0x3c424242, 0x00000000),
+ "V" => mc(0x42420000, 0x24424242, 0x18182424, 0x00000000), "W" => mc(0x41410000, 0x49414141, 0x41635549, 0x00000000),
+ "X" => mc(0x42420000, 0x18182424, 0x42422424, 0x00000000), "Y" => mc(0x41410000, 0x08142222, 0x08080808, 0x00000000),
+ "Z" => mc(0x407e0000, 0x08102040, 0x7e020204, 0x00000000), "[" => mc(0x041c0000, 0x04040404, 0x1c040404, 0x00000000),
+ "\\"=> mc(0x02020000, 0x08080404, 0x20201010, 0x00000000), "]" => mc(0x101c0000, 0x10101010, 0x1c101010, 0x00000000),
+ "^" => mc(0x22140800, 0x00000000, 0x00000000, 0x00000000), "_" => mc(0x00000000, 0x00000000, 0x00000000, 0x00007e00),
+ "`" => mc(0x00001008, 0x00000000, 0x00000000, 0x00000000), "a" => mc(0x00000000, 0x7c403c00, 0x7c424242, 0x00000000),
+ "b" => mc(0x02020000, 0x42423e02, 0x3e424242, 0x00000000), "c" => mc(0x00000000, 0x02423c00, 0x3c420202, 0x00000000),
+ "d" => mc(0x40400000, 0x42427c40, 0x7c424242, 0x00000000), "e" => mc(0x00000000, 0x42423c00, 0x3c02027e, 0x00000000),
+ "f" => mc(0x08700000, 0x08083e08, 0x08080808, 0x00000000), "g" => mc(0x00000000, 0x42427c00, 0x7c424242, 0x003c4040),
+ "h" => mc(0x02020000, 0x42423e02, 0x42424242, 0x00000000), "i" => mc(0x08080000, 0x08080c00, 0x1c080808, 0x00000000),
+ "j" => mc(0x20200000, 0x20203000, 0x20202020, 0x001c2222), "k" => mc(0x02020000, 0x12224202, 0x4222120e, 0x00000000),
+ "l" => mc(0x080c0000, 0x08080808, 0x1c080808, 0x00000000), "m" => mc(0x00000000, 0x49493f00, 0x49494949, 0x00000000),
+ "n" => mc(0x00000000, 0x42423e00, 0x42424242, 0x00000000), "o" => mc(0x00000000, 0x42423c00, 0x3c424242, 0x00000000),
+ "p" => mc(0x00000000, 0x42423e00, 0x3e424242, 0x00020202), "q" => mc(0x00000000, 0x42427c00, 0x7c424242, 0x00404040),
+ "r" => mc(0x00000000, 0x02067a00, 0x02020202, 0x00000000), "s" => mc(0x00000000, 0x02027c00, 0x3e40403c, 0x00000000),
+ "t" => mc(0x08080000, 0x08083e08, 0x70080808, 0x00000000), "u" => mc(0x00000000, 0x42424200, 0x7c424242, 0x00000000),
+ "v" => mc(0x00000000, 0x42424200, 0x18182424, 0x00000000), "w" => mc(0x00000000, 0x49414100, 0x3e494949, 0x00000000),
+ "x" => mc(0x00000000, 0x24424200, 0x42422418, 0x00000000), "y" => mc(0x00000000, 0x42424200, 0x7c424242, 0x003c4040),
+ "z" => mc(0x00000000, 0x10207e00, 0x7e020408, 0x00000000), "{" => mc(0x08300000, 0x08040808, 0x30080808, 0x00000000),
+ "|" => mc(0x08080000, 0x08080808, 0x08080808, 0x00000000), "}" => mc(0x100c0000, 0x10201010, 0x0c101010, 0x00000000),
+ "~" => mc(0x31494600, 0x00000000, 0x00000000, 0x00000000),
+ }, ter16b => {
+ " " => mc(0x00000000, 0x00000000, 0x00000000, 0x00000000), "!" => mc(0x18180000, 0x18181818, 0x18180018, 0x00000000),
+ '"' => mc(0x66666600, 0x00000000, 0x00000000, 0x00000000), "#" => mc(0x36360000, 0x36367f36, 0x3636367f, 0x00000000),
+ '$' => mc(0x3e080800, 0x3e0b0b6b, 0x3e6b6868, 0x00000808), "%" => mc(0x6b660000, 0x18183036, 0x66d66c0c, 0x00000000),
+ "&" => mc(0x361c0000, 0x3b6e1c36, 0x6e3b3333, 0x00000000), "'" => mc(0x18181800, 0x00000000, 0x00000000, 0x00000000),
+ "(" => mc(0x18300000, 0x0c0c0c0c, 0x30180c0c, 0x00000000), ")" => mc(0x180c0000, 0x30303030, 0x0c183030, 0x00000000),
+ "*" => mc(0x00000000, 0x7f1c3600, 0x0000361c, 0x00000000), "+" => mc(0x00000000, 0x7e181800, 0x00001818, 0x00000000),
+ "," => mc(0x00000000, 0x00000000, 0x18180000, 0x0000000c), "-" => mc(0x00000000, 0x7f000000, 0x00000000, 0x00000000),
+ "." => mc(0x00000000, 0x00000000, 0x18180000, 0x00000000), "/" => mc(0x60600000, 0x18183030, 0x06060c0c, 0x00000000),
+ "0" => mc(0x633e0000, 0x6f7b7363, 0x3e636367, 0x00000000), "1" => mc(0x1c180000, 0x1818181e, 0x7e181818, 0x00000000),
+ "2" => mc(0x633e0000, 0x18306063, 0x7f03060c, 0x00000000), "3" => mc(0x633e0000, 0x603c6063, 0x3e636360, 0x00000000),
+ "4" => mc(0x70600000, 0x63666c78, 0x6060607f, 0x00000000), "5" => mc(0x037f0000, 0x603f0303, 0x3e636060, 0x00000000),
+ "6" => mc(0x063c0000, 0x633f0303, 0x3e636363, 0x00000000), "7" => mc(0x607f0000, 0x18303060, 0x0c0c0c18, 0x00000000),
+ "8" => mc(0x633e0000, 0x633e6363, 0x3e636363, 0x00000000), "9" => mc(0x633e0000, 0x7e636363, 0x1e306060, 0x00000000),
+ ":" => mc(0x00000000, 0x00181800, 0x18180000, 0x00000000), ";" => mc(0x00000000, 0x00181800, 0x18180000, 0x0000000c),
+ "<" => mc(0x60000000, 0x060c1830, 0x6030180c, 0x00000000), "=" => mc(0x00000000, 0x00007f00, 0x0000007f, 0x00000000),
+ ">" => mc(0x06000000, 0x6030180c, 0x060c1830, 0x00000000), "?" => mc(0x633e0000, 0x18306363, 0x18180018, 0x00000000),
+ "@" => mc(0x633e0000, 0x6b6b6b73, 0x7e03736b, 0x00000000), "A" => mc(0x633e0000, 0x7f636363, 0x63636363, 0x00000000),
+ "B" => mc(0x633f0000, 0x633f6363, 0x3f636363, 0x00000000), "C" => mc(0x633e0000, 0x03030363, 0x3e636303, 0x00000000),
+ "D" => mc(0x331f0000, 0x63636363, 0x1f336363, 0x00000000), "E" => mc(0x037f0000, 0x031f0303, 0x7f030303, 0x00000000),
+ "F" => mc(0x037f0000, 0x031f0303, 0x03030303, 0x00000000), "G" => mc(0x633e0000, 0x7b030363, 0x3e636363, 0x00000000),
+ "H" => mc(0x63630000, 0x637f6363, 0x63636363, 0x00000000), "I" => mc(0x183c0000, 0x18181818, 0x3c181818, 0x00000000),
+ "J" => mc(0x30780000, 0x30303030, 0x1e333330, 0x00000000), "K" => mc(0x63630000, 0x0f0f1b33, 0x6363331b, 0x00000000),
+ "L" => mc(0x03030000, 0x03030303, 0x7f030303, 0x00000000), "M" => mc(0x63410000, 0x636b7f77, 0x63636363, 0x00000000),
+ "N" => mc(0x63630000, 0x7b6f6763, 0x63636373, 0x00000000), "O" => mc(0x633e0000, 0x63636363, 0x3e636363, 0x00000000),
+ "P" => mc(0x633f0000, 0x3f636363, 0x03030303, 0x00000000), "Q" => mc(0x633e0000, 0x63636363, 0x3e7b6363, 0x00000060),
+ "R" => mc(0x633f0000, 0x3f636363, 0x63331b0f, 0x00000000), "S" => mc(0x633e0000, 0x603e0303, 0x3e636360, 0x00000000),
+ "T" => mc(0x18ff0000, 0x18181818, 0x18181818, 0x00000000), "U" => mc(0x63630000, 0x63636363, 0x3e636363, 0x00000000),
+ "V" => mc(0x63630000, 0x36636363, 0x1c1c3636, 0x00000000), "W" => mc(0x63630000, 0x6b636363, 0x4163777f, 0x00000000),
+ "X" => mc(0x63630000, 0x1c1c3636, 0x63633636, 0x00000000), "Y" => mc(0xc3c30000, 0x183c6666, 0x18181818, 0x00000000),
+ "Z" => mc(0x607f0000, 0x0c183060, 0x7f030306, 0x00000000), "[" => mc(0x0c3c0000, 0x0c0c0c0c, 0x3c0c0c0c, 0x00000000),
+ "\\"=> mc(0x06060000, 0x18180c0c, 0x60603030, 0x00000000), "]" => mc(0x303c0000, 0x30303030, 0x3c303030, 0x00000000),
+ "^" => mc(0x663c1800, 0x00000000, 0x00000000, 0x00000000), "_" => mc(0x00000000, 0x00000000, 0x00000000, 0x00007f00),
+ "`" => mc(0x0000180c, 0x00000000, 0x00000000, 0x00000000), "a" => mc(0x00000000, 0x7e603e00, 0x7e636363, 0x00000000),
+ "b" => mc(0x03030000, 0x63633f03, 0x3f636363, 0x00000000), "c" => mc(0x00000000, 0x03633e00, 0x3e630303, 0x00000000),
+ "d" => mc(0x60600000, 0x63637e60, 0x7e636363, 0x00000000), "e" => mc(0x00000000, 0x63633e00, 0x3e03037f, 0x00000000),
+ "f" => mc(0x0c780000, 0x0c0c3f0c, 0x0c0c0c0c, 0x00000000), "g" => mc(0x00000000, 0x63637e00, 0x7e636363, 0x003e6060),
+ "h" => mc(0x03030000, 0x63633f03, 0x63636363, 0x00000000), "i" => mc(0x18180000, 0x18181c00, 0x3c181818, 0x00000000),
+ "j" => mc(0x60600000, 0x60607000, 0x60606060, 0x003c6666), "k" => mc(0x03030000, 0x1b336303, 0x63331b0f, 0x00000000),
+ "l" => mc(0x181c0000, 0x18181818, 0x3c181818, 0x00000000), "m" => mc(0x00000000, 0x6b6b3f00, 0x6b6b6b6b, 0x00000000),
+ "n" => mc(0x00000000, 0x63633f00, 0x63636363, 0x00000000), "o" => mc(0x00000000, 0x63633e00, 0x3e636363, 0x00000000),
+ "p" => mc(0x00000000, 0x63633f00, 0x3f636363, 0x00030303), "q" => mc(0x00000000, 0x63637e00, 0x7e636363, 0x00606060),
+ "r" => mc(0x00000000, 0x070f7b00, 0x03030303, 0x00000000), "s" => mc(0x00000000, 0x03037e00, 0x3f60603e, 0x00000000),
+ "t" => mc(0x0c0c0000, 0x0c0c3f0c, 0x780c0c0c, 0x00000000), "u" => mc(0x00000000, 0x63636300, 0x7e636363, 0x00000000),
+ "v" => mc(0x00000000, 0x63636300, 0x1c1c3636, 0x00000000), "w" => mc(0x00000000, 0x6b636300, 0x3e6b6b6b, 0x00000000),
+ "x" => mc(0x00000000, 0x36636300, 0x6363361c, 0x00000000), "y" => mc(0x00000000, 0x63636300, 0x7e636363, 0x003e6060),
+ "z" => mc(0x00000000, 0x18307f00, 0x7f03060c, 0x00000000), "{" => mc(0x0c380000, 0x0c060c0c, 0x380c0c0c, 0x00000000),
+ "|" => mc(0x18180000, 0x18181818, 0x18181818, 0x00000000), "}" => mc(0x180e0000, 0x18301818, 0x0e181818, 0x00000000),
+ "~" => mc(0x73dbce00, 0x00000000, 0x00000000, 0x00000000),
+ },
);
sub _window_pos {
View
2 wtf
@@ -130,7 +130,7 @@ sub r_render {
TextRender::render_text(x => 10, y => 10, text => "o Hai", scale => 3);
if ($cam_moving) {
- TextRender::render_text(x => 10, y => 40, color => [ 1, 0, 0 ], text => "OW!", scale => 4);
+ TextRender::render_text(x => 10, y => 40, color => [ 1, 0, 0 ], text => "OW!", scale => 2, font => "ter16b");
}
}

0 comments on commit 6c2fb90

Please sign in to comment.