Consider splitting up top screen into two types?
ian-h-chamberlain opened this issue · comments
As I've been trying to work on rust3ds/citro3d-rs#4, it occurred to me that it might make sense for us to break out the top-left and top-right screen into their own structs. Currently, it's a bit challenging to write code that's generic for both screens, since you can't get the raw frame buffer, so you have to write something like:
impl Thing {
pub fn new_top(screen: TopScreen, side: Side);
pub fn new_bottom(screen: BottomScreen);
}
I was thinking, maybe we could separate the top screen into two types, and add frame buffer helpers to Screen
instead, like:
pub trait Screen {
/// Returns the libctru value for the Screen kind
fn as_raw(&self) -> ctru_sys::gfxScreen_t;
/// Returns the raw frame buffer for rendering to the Screen
fn get_raw_framebuffer(&mut self) -> RawFrameBuffer;
}
This way, it would be a bit easier to have separate ownership of the top-left and top-right screens, in case e.g. you wanted to have separate render targets:
let top_left = render::Target::new(gfx.top_left_screen.borrow_mut());
let top_right = render::Target::new(gfx.top_right_screen.borrow_mut());
For simplicity, maybe we could also have a helper struct/method in case you want to render to both sides, although I don't think it could implement Screen
so it may have limited uses. Perhaps a helper like that would be more useful in render code than in gfx
itself.
I think this implementation would be more consistent with e.g. the CAM implementation in #65 and would make it a bit easier to write generic code against screens. @Meziu @AzureMarker what are your thoughts?
That makes sense. They have different framebuffers and work in a parallel way. The only issue would be when rendering in wide mode, since both sides are used as one (i believe). For everything else it should be pretty straightforward.
Sounds good, my only concern is about how code using both sides like Console will look. Do you have an example of what creating a top screen console would look like with this change?