-
I'm not 100% ready to dig super deep into this, but I wanted to open the discussion to get any extra context that might help if/when I get into this soon. For Bevy Retro, the library that I want to use RAUI with, because it is focused on delivering low-resolution, pixel-perfect games, it uses integers for all of it's screen coordinates, which are relative to the low-resolution framebuffer that the scene is rendered to. I would like to be able to use Do you see any way that it would make sense to use integer coords in RAUI or does it just make more sense for my backend RAUI renderer to round all of the coordinates before rendering or something like that? When it comes to things like animations and lerping, it might make more sense to use floats anyway, so maybe it is better just to use floats for the UI anyway. Honestly I'm not 100% sure its the best idea to use integer coordinates for Bevy Retro either, but I had a "feeling" like rounding floats would get me in trouble one day for some reason. I guess that's slightly off topic, but if you have any thoughts on whether or not that is even a good idea I'd love to hear it @PsichiX . 😁 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
oh actually that you mention it, i had similar problems with few pixel based demos, i've played with the idea of integer coords and abandoned it because there were problems on the layouting side, precision related bc of multiplying and dividing big and small numbers, a lot of mess iirc (integer idea was bad from the get go but i wanted to test it anyway to confirm that it is problematic). #[derive(Ignite, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserInterfaceApproxRectValues {
Exact,
Round,
RoundDown,
RoundUp,
RoundInside,
RoundOutside,
}
impl Default for UserInterfaceApproxRectValues {
fn default() -> Self {
Self::Exact
}
}
impl UserInterfaceApproxRectValues {
pub fn calculate(self, rect: Rect) -> Rect {
match self {
Self::Exact => rect,
Self::Round => Rect {
x: rect.x.round(),
y: rect.y.round(),
w: rect.w.round(),
h: rect.h.round(),
},
Self::RoundDown => Rect {
x: rect.x.floor(),
y: rect.y.floor(),
w: rect.w.floor(),
h: rect.h.floor(),
},
Self::RoundUp => Rect {
x: rect.x.ceil(),
y: rect.y.ceil(),
w: rect.w.ceil(),
h: rect.h.ceil(),
},
Self::RoundInside => Rect {
x: rect.x.ceil(),
y: rect.y.ceil(),
w: rect.w.floor(),
h: rect.h.floor(),
},
Self::RoundOutside => Rect {
x: rect.x.floor(),
y: rect.y.floor(),
w: rect.w.ceil(),
h: rect.h.ceil(),
},
}
}
} then in renderer i grab virtual-space rects from processed layout, convert them from virtual-space to ui-space rects using coords mapping and that ui-space rect i put to this (this code uses Rect from oxygengine, not from RAUI, because at the time
|
Beta Was this translation helpful? Give feedback.
oh actually that you mention it, i had similar problems with few pixel based demos, i've played with the idea of integer coords and abandoned it because there were problems on the layouting side, precision related bc of multiplying and dividing big and small numbers, a lot of mess iirc (integer idea was bad from the get go but i wanted to test it anyway to confirm that it is problematic).
then i've played with rounding scalar numbers and i've found out that if you leave all virtual-space coords calculations as it does now, and round coords only on the renderer side then all values are prefectly aligned with pixels - i've working example in oxygengine, i'm even working with it at this very…