From 6ceaf63c7d7155b0a74182a6193d12892b91d292 Mon Sep 17 00:00:00 2001 From: Ed Swartz Date: Fri, 1 May 2015 09:57:56 -0500 Subject: [PATCH 1/2] Add -L (lighting) and -P options to pview --- doc/man/pview.1 | 11 ++++++++++- panda/src/testbed/pview.cxx | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/doc/man/pview.1 b/doc/man/pview.1 index a45fb8110f..7b5a5520c0 100644 --- a/doc/man/pview.1 +++ b/doc/man/pview.1 @@ -1,4 +1,4 @@ -.TH PVIEW 1 "27 December 2014" "" Panda3D +.TH PVIEW 1 "1 May 2015" "" Panda3D .SH NAME pview \- quickly view a Panda model and/or animation .SH SYNOPSIS @@ -43,6 +43,15 @@ exit. Delete the model files after loading them (presumably this option will only be used when loading a temporary model file). .TP +.B \-L +Enable lighting in the scene. This can also be achieved with +the 'l' hotkey at runtime. +.TP +.BI "\-P " pipename +Select the given graphics pipe for the window, rather than using +the platform default. The allowed values for are those +from the Config.prc variables 'load-display' and 'aux-display'. +.TP .B \-V Report the current version of Panda, and exit. .TP diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index 5d5b9ba113..e92df5d220 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -26,6 +26,7 @@ #include "virtualFileSystem.h" #include "panda_getopt.h" #include "preprocess_argv.h" +#include "graphicsPipeSelection.h" // By including checkPandaVersion.h, we guarantee that runtime // attempts to run pview will fail if it inadvertently links with the @@ -209,6 +210,15 @@ help() { " Delete the model files after loading them (presumably this option\n" " will only be used when loading a temporary model file).\n\n" + " -L\n" + " Enable lighting in the scene. This can also be achieved with\n" + " the 'l' hotkey at runtime.\n\n" + + " -P \n" + " Select the given graphics pipe for the window, rather than using\n" + " the platform default. The allowed values for are those\n" + " from the Config.prc variables 'load-display' and 'aux-display'.\n\n" + " -V\n" " Report the current version of Panda, and exit.\n\n" @@ -241,10 +251,12 @@ main(int argc, char **argv) { PartGroup::HMF_ok_anim_extra; Filename screenshotfn; bool delete_models = false; + bool apply_lighting = false; + PointerTo pipe = NULL; extern char *optarg; extern int optind; - static const char *optflags = "acls:DVhi"; + static const char *optflags = "acls:DVhiLP:"; int flag = getopt(argc, argv, optflags); while (flag != EOF) { @@ -275,6 +287,19 @@ main(int argc, char **argv) { delete_models = true; break; + case 'L': + apply_lighting = true; + break; + + case 'P': { + pipe = GraphicsPipeSelection::get_global_ptr()->make_module_pipe(optarg); + if (!pipe) { + cerr << "No such pipe '" << optarg << "' available." << endl; + return 1; + } + break; + } + case 'V': report_version(); return 1; @@ -296,7 +321,7 @@ main(int argc, char **argv) { argc -= (optind - 1); argv += (optind - 1); - WindowFramework *window = framework.open_window(); + WindowFramework *window = framework.open_window(pipe, NULL); if (window != (WindowFramework *)NULL) { // We've successfully opened a window. @@ -348,6 +373,10 @@ main(int argc, char **argv) { loading_np.remove_node(); + if (apply_lighting) { + window->set_lighting(true); + } + if (auto_center) { window->center_trackball(framework.get_models()); } From c292d3bc65b3ab7899911ad9ce5ab464aeb391b3 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 3 May 2015 20:47:29 +0200 Subject: [PATCH 2/2] Allow deactivating GPU timers, disable Draw:Primitive:Draw collectors --- panda/src/display/pStatGPUTimer.I | 6 +++--- .../src/glstuff/glGraphicsStateGuardian_src.cxx | 17 ++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/panda/src/display/pStatGPUTimer.I b/panda/src/display/pStatGPUTimer.I index 27f4938917..4493f4ab9b 100644 --- a/panda/src/display/pStatGPUTimer.I +++ b/panda/src/display/pStatGPUTimer.I @@ -25,7 +25,7 @@ PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector) : PStatTimer(collector), _gsg(gsg) { - if (gsg->get_timer_queries_active()) { + if (gsg->get_timer_queries_active() && collector.is_active()) { gsg->issue_timer_query(collector.get_index()); //cerr << "issuing " << collector << " active " << collector.is_active() << "\n"; } @@ -41,7 +41,7 @@ PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector, Thread *cur PStatTimer(collector, current_thread), _gsg(gsg) { - if (gsg->get_timer_queries_active()) { + if (gsg->get_timer_queries_active() && collector.is_active()) { gsg->issue_timer_query(collector.get_index()); } } @@ -53,7 +53,7 @@ PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector, Thread *cur //////////////////////////////////////////////////////////////////// INLINE PStatGPUTimer:: ~PStatGPUTimer() { - if (_gsg->get_timer_queries_active()) { + if (_gsg->get_timer_queries_active() && _collector.is_active()) { _gsg->issue_timer_query(_collector.get_index() | 0x8000); } } diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index d24448189f..37dff91eea 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -3772,7 +3772,7 @@ disable_standard_vertex_arrays() { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -3839,7 +3839,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); report_my_gl_errors(); @@ -3966,7 +3966,8 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() << "draw_trifans: " << *(reader->get_object()) << "\n"; @@ -4046,7 +4047,7 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_patches(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -4122,7 +4123,8 @@ draw_patches(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() << "draw_lines: " << *(reader->get_object()) << "\n"; @@ -4186,7 +4188,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); report_my_gl_errors(); @@ -4310,7 +4312,8 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: draw_points(const GeomPrimitivePipelineReader *reader, bool force) { - PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() << "draw_points: " << *(reader->get_object()) << "\n";