Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port 3ds-Example: graphics bitmap #29

Merged
merged 5 commits into from
Jan 30, 2022

Conversation

ian-h-chamberlain
Copy link
Member

@ian-h-chamberlain ian-h-chamberlain commented Jan 28, 2022

Ref #18

I modified the framebuffer API a bit since I don't think it makes sense to allow arbitrary Side for the bottom screen.

Also, the frame buffer returning a tuple (*mut u8, u16, u16) seems a little odd to me and maybe a struct would be preferable? Let me know what you think.

Finally – do we want to roughly match the directory structure of 3ds-examples? There are a lot of graphics examples and it might make sense to group them in a directory, as long as they still have unique names I think they are still easily runnable with cargo 3ds link --example $name. If so I can move this to a subdirectory.

Edit: screenshot! The colors on my device look a bit off, so I might try to play around with it to get a cleaner looking output... Also, for some reason, Luma screenshot isn't capturing the text on the top screen, but it is displayed there. Will investigate that.

ferris

@AzureMarker
Copy link
Member

Also, the frame buffer returning a tuple (*mut u8, u16, u16) seems a little odd to me and maybe a struct would be preferable? Let me know what you think.

A struct would be nice, yeah.

Finally – do we want to roughly match the directory structure of 3ds-examples?

Cargo doesn't automatically infer examples unless they're in the examples directory (not a sub-directory):
https://users.rust-lang.org/t/run-examples-in-subfolders-using-cargo/18154/2

If there are examples with more than just one file though, they can be in sub folders with a main.rs.

/// Note that the pointer returned by this function can change after each call to this function
/// if double buffering is enabled
pub fn get_raw_framebuffer(&mut self, side: Side) -> (*mut u8, u16, u16) {
let mut width: u16 = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Just a personal preference, but you don't need any of the local variable types in these functions. They get inferred from the return type.

@AzureMarker
Copy link
Member

Luma screenshot isn't capturing the text on the top screen, but it is displayed there. Will investigate that.

I also found weird things with Luma and Console printing. It was just a black screen for me, like your top screen.

This looks more correct on the device to my eye and is a bit simpler.
@Meziu
Copy link
Member

Meziu commented Jan 28, 2022

Finally – do we want to roughly match the directory structure of 3ds-examples?

We can't make directories for examples. We can only group them by name (instead of a folder, put the folder name as a prefix to the file). It's not a big issue anyways.

I chose the name RawFrameBuffer in case we'd like to provide a "safer"
alternative API at some point.
@ian-h-chamberlain
Copy link
Member Author

ian-h-chamberlain commented Jan 29, 2022

Cargo doesn't automatically infer examples unless they're in the examples directory (not a sub-directory):
https://users.rust-lang.org/t/run-examples-in-subfolders-using-cargo/18154/2

If there are examples with more than just one file though, they can be in sub folders with a main.rs.

We can't make directories for examples. We can only group them by name (instead of a folder, put the folder name as a prefix to the file). It's not a big issue anyways.

Ah, I forgot these details... I suppose if it gets out of hand we could make [[example]] entries in Cargo.toml, but for now I think this convention works.


New changes I'm pushing:

  • Added a struct RawFrameBuffer

  • Different conversion process for the image, which looks more correct. I guess the instructions from 3ds-examples were outdated. Note: it's hard to see if you use something like f.lux, which I had to turn off to notice a difference on my computer. On the device is more noticeable, although Luma filters might impact this the same way.

Screenshots

Before

ferris_yellow

After

ferris


I'll open a new issue for the Luma screenshot thing, since I think it might be something we can workaround on the ctru-rs side (I vaguely recall a code change I had which let me screenshot the console)

ctru-rs/src/gfx.rs Outdated Show resolved Hide resolved
ctru-rs/src/gfx.rs Outdated Show resolved Hide resolved
ctru-rs/src/gfx.rs Outdated Show resolved Hide resolved
ctru-rs/src/gfx.rs Show resolved Hide resolved
Keep RawFrameBuffer alive as long as the Screen is, to ensure the Gfx is
not dropped while the FrameBuffer is alive.
@Meziu Meziu merged commit 8ba1bb2 into rust3ds:master Jan 30, 2022
@ian-h-chamberlain ian-h-chamberlain deleted the example/graphics-bitmap branch February 24, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants