+use glium::{Display, Program, Surface, texture};
+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]
+}
+
+#[cfg(feature = "image")]
+fn c64_font() -> (u32, u32, Vec<u8>) {
+ use image;
+ let image = image::load_from_memory_with_format(
+ &include_bytes!("textures/c64-font.png")[..],
+ image::PNG,
+ ).unwrap()
+ .to_luma();
+ let (w, h) = image.dimensions();
+ (w, h, image.into_raw())
+}
+
+#[cfg(not(feature = "image"))]
+fn c64_font() -> (u32, u32, Vec<u8>) {
+ let pixels = &include_bytes!("textures/c64-font.gray")[..];
+ (128, 128, Vec::from(pixels))
+}
+
+pub fn text_program(display: &Display) -> Program {
+ //load_program(display, "shaders/text.vert", "shaders/text.frag");
+ let vertex_shader_src = include_str!("shaders/text.vert");
+ let fragment_shader_src = include_str!("shaders/text.frag");
+ Program::from_source(display, vertex_shader_src, fragment_shader_src, None).unwrap()
+}