projects
/
mandelwow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sRGB correction for C64 palette.
[mandelwow.git]
/
text.rs
diff --git
a/text.rs
b/text.rs
index bf19aa2ad273aff0eb9cd544153cac4a90bf0982..abcd9b40f17b3235fcf230883f1e57f8c686b28e 100644
(file)
--- a/
text.rs
+++ b/
text.rs
@@
-1,10
+1,26
@@
use cgmath::conv::array4x4;
use cgmath::conv::array4x4;
-use cgmath::{Matrix4,
One
};
+use cgmath::{Matrix4,
Vector3
};
use glium;
use glium::{Surface, texture};
use image;
use std;
use glium;
use glium::{Surface, texture};
use image;
use std;
+fn gamma<T>(x: T) -> f32
+where
+ f32: From<T>,
+ T: Copy,
+{
+ ((f32::from(x)) / 255.).powf(2.2)
+}
+
+fn srgb<T>(c: [T; 3]) -> [f32; 4]
+where
+ f32: From<T>,
+ T: Copy,
+{
+ [gamma(c[0]), gamma(c[1]), gamma(c[2]), 0.0]
+}
+
#[derive(Copy, Clone)]
struct Vertex {
position: [f32; 2],
#[derive(Copy, Clone)]
struct Vertex {
position: [f32; 2],
@@
-124,7
+140,7
@@
impl<'a> Text<'a> {
};
Text {
};
Text {
- model: Matrix4::
one(
),
+ model: Matrix4::
from_translation(Vector3::unit_z() * (-1.0)
),
tex: tex,
vertex_buffer: vertex_buffer,
index_buffer: index_buffer,
tex: tex,
vertex_buffer: vertex_buffer,
index_buffer: index_buffer,
@@
-142,8
+158,8
@@
impl<'a> Text<'a> {
.magnify_filter(glium::uniforms::MagnifySamplerFilter::Nearest),
index: 'C' as i32,
// RGB values from http://unusedino.de/ec64/technical/misc/vic656x/colors/
.magnify_filter(glium::uniforms::MagnifySamplerFilter::Nearest),
index: 'C' as i32,
// RGB values from http://unusedino.de/ec64/technical/misc/vic656x/colors/
- bgcolor:
[ 53./255., 40./255., 121./255., 0.0/255. ] as [f32; 4],
- fgcolor:
[ 120./255., 106./255., 255./255., 188.0/255. ] as [f32; 4],
+ bgcolor:
srgb([ 64, 50, 133u8]), // 6 - blue
+ fgcolor:
srgb([120, 106, 189u8]), // 14 - light blue
};
frame
.draw(
};
frame
.draw(