PistonDevelopers / graphics

A library for 2D graphics, written in Rust, that works with multiple back-ends
MIT License
479 stars 55 forks source link

Fix type mismatch for conrod_piston::draw::Context fields #1159

Closed lubosmudrak closed 3 years ago

lubosmudrak commented 3 years ago

This pull request fixes a type mismatch for fields "view" and "transform" in conrod_piston::draw::Context fields.

bvssvni commented 3 years ago

This is incorrect. What is the background for this change?

lubosmudrak commented 3 years ago

I am using conrod_piston as a backend for drawing a window. With current latesf official versions of conrod_core(0.73.0) and piston_window(0.120.0) I get the following error:

error[E0308]: mismatched types
   --> src\gui.rs:103:17
    |
103 |                 context,
    |                 ^^^^^^^ expected struct `conrod_piston::draw::Context`, found struct `piston_window::Context`

    |
    = note: perhaps two different versions of crate `graphics` are being used?

conrod_piston backend in Conrod and piston_window crate do indeed use a diferrent versions of piston2d-graphics, versions 0.37.0 and 0.40.0. After updating dependecy to piston2d-graphics in both crates to the same version the compiler started to complain that fields "view" and "transform" have incorrect types so I changed them and then my code compiled.

Should I provide a minimal example to be tested?

Also could you please elaborate why is changing the type of those two fields from Matrix2d to [[f64; 3]; 2] incorrect?

EDIT: I dont remember where in the code was type [[f64; 3]; 2] demanded because I made this change a long time ago so I would be able to continue with my work, but if you need this info, I will look it up.

Thank you for your feedback.

bvssvni commented 3 years ago

It is incorrect because the Scalar is used to define e.g. Matrix2d.

Could there be 3 different versions?

lubosmudrak commented 3 years ago

Issue disappeared after fetching latest version of repository with conrod and using that as a dependency for my app. Whatever caused it in the past is fixed and this pull request is therefore unnecessary now. Sorry for inconvenience I caused, I will now close this pull request.

bvssvni commented 3 years ago

@lubosmudrak no problem!