Making datatype for color channels of color type and texture generic

This commit is contained in:
Stephan Rehfeld 2026-05-27 18:47:57 +02:00
parent 3ea1a7c5aa
commit 5a23f49eae

View File

@ -4,21 +4,21 @@ use hello::math::{Mat4x4, Point3, Vector3};
use std::rc::Rc; use std::rc::Rc;
#[derive(Clone)] #[derive(Clone)]
struct RGB { struct RGB<T> {
red: f64, red: T,
green: f64, green: T,
blue: f64, blue: T,
} }
#[derive(Clone)] #[derive(Clone)]
struct Texture { struct Texture<T> {
width: usize, width: usize,
height: usize, height: usize,
pixel: Vec<RGB>, pixel: Vec<RGB<T>>,
} }
impl Texture { impl Texture<f64> {
fn load_texture() -> Texture { fn load_texture() -> Texture<f64> {
let width = 640; let width = 640;
let height = 480; let height = 480;
@ -45,11 +45,11 @@ impl Texture {
struct RenderableGeometry { struct RenderableGeometry {
transform: Mat4x4, transform: Mat4x4,
geometry: Geometry, geometry: Geometry,
texture: Rc<Texture>, texture: Rc<Texture<f64>>,
} }
impl RenderableGeometry { impl RenderableGeometry {
fn new(transform: Mat4x4, geometry: Geometry, texture: Rc<Texture>) -> RenderableGeometry { fn new(transform: Mat4x4, geometry: Geometry, texture: Rc<Texture<f64>>) -> RenderableGeometry {
RenderableGeometry { RenderableGeometry {
transform, transform,
geometry, geometry,