not-fl3 / macroquad

Cross-platform game engine in Rust.
Apache License 2.0
3.27k stars 317 forks source link

draw_text_ex consumes params? #737

Closed maxpiepenbrink closed 3 months ago

maxpiepenbrink commented 3 months ago

There's probably a totally reasonable explanation for this, but I'm unclear as to why draw_text_ex needs to consume the params argument instead of referencing it. Not a huge cost to pay to keep building TextParams every draw, all things considered, but I thought it was odd and wasn't sure how intentional this was.

Some example code from trying to generalize some text rendering:

impl Displayable for Header {
    fn draw(&self, context: &MenuContext) {
        let measure = measure_text(
            &self.text,
            context.text_params.font,
            context.text_params.font_size,
            context.text_params.font_scale,
        );
        draw_text_ex(&self.text, self.xpos, self.ypos, &context.text_params); // <-- i have to clone() text_params instead of referencing it here
    }
}
maxpiepenbrink commented 3 months ago

Decided to just throw up a PR to talk about it instead: https://github.com/not-fl3/macroquad/pull/738