-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement screenshot feature #2074
base: master
Are you sure you want to change the base?
Conversation
69c3356
to
30d7a1d
Compare
9d75fe3
to
9f2f055
Compare
nice work! I'm kinda surprised how easy this was to implement. |
src/xenia/app/emulator_window.cc
Outdated
} | ||
|
||
void EmulatorWindow::ExportImage(const xe::ui::RawImage& image) { | ||
auto path = std::filesystem::path("screenshot.png"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be desirable to save the screenshots somewhere in a more user-faced directory. The best default location would likely be a subdirectory (preferably something like Xenia/game name
with characters not supported in paths on the host file system filtered out, or Xenia/title ID
if there's no game name provided in the XEX) in the user images directory in the OS. Other non-default options may be a directory specified in the config, and the executable directory in case the emulator was launched in the portable mode.
Thanks! I was honestly surprised too. It helped that the project already included a third-party library that would save image files and that there was already a method to capture the raw render output. Also, GitHub Copilot sleuthed about half of the solution, and I deduced the rest to get it working. Otherwise, I wouldn't have even known about the I'll see about making the filename more descriptive, probably something like And yeah, I can add a message box with imgui to say "Screenshot saved to [screenshot path]". |
8a39e38
to
65cb39b
Compare
Maybe something like ISO 8601? So the date format is something like |
You used github copilot for this? How did that process work? A message box might be too intrusive. maybe if imgui has no notification widget (that doesn't get in the way/steal context) you could add |
Yeah, GitHub Copilot is surprisingly helpful in finding the missing pieces to a solution at times. Especially in this case where the answer was just sitting right in front of me but I hadn't noticed it yet. In this case, I didn't know the project had a save-to-PNG method, but GitHub Copilot did, which saved me a lot of time. The only way I would have known about that would have been by searching through every file in the project until I randomly stumbled upon it. Github.Copilot.mp4GitHub Copilot will use the context of the rest of your project to help find what you're looking for, and it does it remarkably quickly. It doesn't always work perfectly, and won't always give you what you're looking for. Most of the time you still need to fill in the rest or make changes. Overall, it's still very useful and I'd recommend it. I'll see about changing the title instead of showing a message box when a screenshot is saved. |
Wow that's actually pretty insane. This is the first time I've seen github copilot be used for anything other than hello world or basic algorithms |
I've seen it construct some really advanced functions that would've taken me hours or days to figure out. This is actually a pretty decent example of a practical use for it in the real world. |
Does it still have the issue of randomly spitting out chunks of other people's code? Or has it been trained enough for it to be genericized |
I've personally never seen that happen, but I have the "suggestions matching public code" option disabled so maybe that's why? Either way, it's pretty good at coming up with original solutions, as is the case in this example. As I said, it favors using the context of your project and what it already has for methods to come up with a solution over just randomly yoinking one from the internet. For the most part, it just constructs a generic method based on the prompt or context of the current and previous lines. |
@@ -928,6 +937,68 @@ void EmulatorWindow::ToggleFullscreen() { | |||
SetFullscreen(!window_->IsFullscreen()); | |||
} | |||
|
|||
void EmulatorWindow::TakeScreenshot() { | |||
xe::ui::RawImage image; | |||
if (!GetGraphicsSystemPresenter()->CaptureGuestOutput(image) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that not all games output the image with the same aspect ratio as the display. Halo 3, for example, presents a 1152x640 image, which has an aspect ratio of 16.2:9 rather than 16:9, so it may appear slightly stretched horizontally. Also, we apply FXAA before writing to the guest output image (for simplicity, as it needs to work at the game's resolution), but CAS or FSR after that — so this will include just the FXAA-processed image with the size provided by the game.
Added a screenshot functionality based on this pr xenia-project#2074 and added some minor adjustments. GUI wise, "take screenshot" is under the Display menu and the keyboard shortcut to take it is F10 The screenshots folder will save to where xenia.exe or xenia_canary.exe is located. As for save paths, it will only use the id of the game due to illegal characters in some titles.
This pull request adds the ability to take screenshots from within the emulator.
It will save the screenshot and name the file using this format:
"Screenshot - [Title_Name or Title_ID] - [Datetime] - [Time in nanoseconds since epoch].png"
. The menu button is found underDisplay > Take Screenshot
and can also be activated by pressingF12
.Screenshots are saved to
Documents\Xenia\Screenshots\{Game Title or Game ID}
by default.Xenia.Screenshot.Feature.V2.mp4
Resolves: #2049, #2039