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;
#[derive(Clone)]
struct RGB {
red: f64,
green: f64,
blue: f64,
struct RGB<T> {
red: T,
green: T,
blue: T,
}
#[derive(Clone)]
struct Texture {
struct Texture<T> {
width: usize,
height: usize,
pixel: Vec<RGB>,
pixel: Vec<RGB<T>>,
}
impl Texture {
fn load_texture() -> Texture {
impl Texture<f64> {
fn load_texture() -> Texture<f64> {
let width = 640;
let height = 480;
@ -45,11 +45,11 @@ impl Texture {
struct RenderableGeometry {
transform: Mat4x4,
geometry: Geometry,
texture: Rc<Texture>,
texture: Rc<Texture<f64>>,
}
impl RenderableGeometry {
fn new(transform: Mat4x4, geometry: Geometry, texture: Rc<Texture>) -> RenderableGeometry {
fn new(transform: Mat4x4, geometry: Geometry, texture: Rc<Texture<f64>>) -> RenderableGeometry {
RenderableGeometry {
transform,
geometry,