mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
Added screenshot thing
This commit is contained in:
parent
9b54c46a9b
commit
2d93cea389
@ -43,6 +43,21 @@ ConfigVariableBool pview_test_hack
|
|||||||
"Enable the '0' key in pview to run whatever hacky test happens to be in "
|
"Enable the '0' key in pview to run whatever hacky test happens to be in "
|
||||||
"there right now.");
|
"there right now.");
|
||||||
|
|
||||||
|
bool
|
||||||
|
output_screenshot(Filename &fn)
|
||||||
|
{
|
||||||
|
// Only one frame crashes.
|
||||||
|
framework.do_frame();
|
||||||
|
framework.do_frame();
|
||||||
|
|
||||||
|
WindowFramework *wf = framework.get_window(0);
|
||||||
|
bool ok = wf->get_graphics_window()->save_screenshot(fn);
|
||||||
|
if (!ok) {
|
||||||
|
cerr << "Could not generate screenshot " << fn << "\n";
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
event_W(CPT_Event, void *) {
|
event_W(CPT_Event, void *) {
|
||||||
// shift-W: open a new window on the same scene.
|
// shift-W: open a new window on the same scene.
|
||||||
@ -188,6 +203,10 @@ help() {
|
|||||||
" displayed in the window. The default is not to open the window\n"
|
" displayed in the window. The default is not to open the window\n"
|
||||||
" until all models are loaded.\n\n"
|
" until all models are loaded.\n\n"
|
||||||
|
|
||||||
|
" -s filename\n"
|
||||||
|
" After displaying the models, immediately take a screenshot and
|
||||||
|
" exit.\n\n"
|
||||||
|
|
||||||
" -h\n"
|
" -h\n"
|
||||||
" Display this help text.\n\n";
|
" Display this help text.\n\n";
|
||||||
}
|
}
|
||||||
@ -199,10 +218,12 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
bool auto_center = false;
|
bool auto_center = false;
|
||||||
bool show_loading = false;
|
bool show_loading = false;
|
||||||
|
bool auto_screenshot = false;
|
||||||
|
Filename screenshotfn;
|
||||||
|
|
||||||
// extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind;
|
extern int optind;
|
||||||
static const char *optflags = "clh";
|
static const char *optflags = "clhs:";
|
||||||
int flag = getopt(argc, argv, optflags);
|
int flag = getopt(argc, argv, optflags);
|
||||||
|
|
||||||
while (flag != EOF) {
|
while (flag != EOF) {
|
||||||
@ -218,9 +239,16 @@ main(int argc, char *argv[]) {
|
|||||||
case 'h':
|
case 'h':
|
||||||
help();
|
help();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
auto_screenshot = true;
|
||||||
|
screenshotfn = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cerr << "Unhandled switch: " << flag << endl;
|
cerr << "Unhandled switch: " << flag << endl;
|
||||||
break;
|
break;
|
||||||
@ -270,6 +298,10 @@ main(int argc, char *argv[]) {
|
|||||||
window->center_trackball(framework.get_models());
|
window->center_trackball(framework.get_models());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto_screenshot) {
|
||||||
|
return(output_screenshot(screenshotfn) ? 0:1);
|
||||||
|
}
|
||||||
|
|
||||||
framework.enable_default_keys();
|
framework.enable_default_keys();
|
||||||
framework.define_key("shift-w", "open a new window", event_W, NULL);
|
framework.define_key("shift-w", "open a new window", event_W, NULL);
|
||||||
framework.define_key("alt-enter", "toggle between window/fullscreen", event_Enter, NULL);
|
framework.define_key("alt-enter", "toggle between window/fullscreen", event_Enter, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user