From 83d54bcdafc9ba5ed9108e8f0619544f4d275c75 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2016 22:57:53 +0100 Subject: [PATCH 1/2] Try to preserve refresh rate when switching display mode on Windows --- doc/ReleaseNotes | 1 + panda/src/windisplay/winGraphicsWindow.cxx | 27 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index b7462a97d6..a288196f72 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -48,6 +48,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix exception when trying to pickle NodePathCollection objects * Fix error when trying to raise vectors to a power * GLSL: fix error when legacy matrix generator inputs are mat3 +* Now tries to preserve refresh rate when switching fullscreen on Windows ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index f270a70f61..0f7e33dc75 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -2357,7 +2357,15 @@ hide_or_show_cursor(bool hide_cursor) { bool WinGraphicsWindow:: find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, DEVMODE &dm) { + + // Get the current mode. We'll try to match the refresh rate. + DEVMODE cur_dm; + ZeroMemory(&cur_dm, sizeof(cur_dm)); + cur_dm.dmSize = sizeof(cur_dm); + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &cur_dm); + int modenum = 0; + int saved_modenum = -1; while (1) { ZeroMemory(&dm, sizeof(dm)); @@ -2369,11 +2377,28 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, if ((dm.dmPelsWidth == dwWidth) && (dm.dmPelsHeight == dwHeight) && (dm.dmBitsPerPel == bpp)) { - return true; + // If this also matches in refresh rate, we're done here. Otherwise, + // save this as a second choice for later. + if (dm.dmDisplayFrequency == cur_dm.dmDisplayFrequency) { + return true; + } else if (saved_modenum == -1) { + saved_modenum = modenum; + } } modenum++; } + // Failed to find an exact match, but we do have a match that didn't match + // the refresh rate. + if (saved_modenum != -1) { + ZeroMemory(&dm, sizeof(dm)); + dm.dmSize = sizeof(dm); + + if (EnumDisplaySettings(NULL, saved_modenum, &dm)) { + return true; + } + } + return false; } From a1338b9ac6171b2fc37f088b8130e5d22b378b54 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2016 23:00:06 +0100 Subject: [PATCH 2/2] Backport to 1.9: fix for distance sorting with gl-coordinate-system changed --- doc/ReleaseNotes | 1 + panda/src/display/graphicsStateGuardian.cxx | 4 ++++ panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 13 ------------- panda/src/glstuff/glGraphicsStateGuardian_src.h | 2 -- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index a288196f72..03d2dcf92a 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -49,6 +49,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix error when trying to raise vectors to a power * GLSL: fix error when legacy matrix generator inputs are mat3 * Now tries to preserve refresh rate when switching fullscreen on Windows +* Fix back-to-front sorting when gl-coordinate-system is changed ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 0a2ae03c1e..d3557fa390 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -148,6 +148,10 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, _coordinate_system = CS_invalid; _internal_transform = TransformState::make_identity(); + if (internal_coordinate_system == CS_default) { + _internal_coordinate_system = get_default_coordinate_system(); + } + set_coordinate_system(get_default_coordinate_system()); _data_reader = (GeomVertexDataPipelineReader *)NULL; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index b70552a032..575d6e202c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -5485,19 +5485,6 @@ make_geom_munger(const RenderState *state, Thread *current_thread) { return GeomMunger::register_munger(munger, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::compute_distance_to -// Access: Public, Virtual -// Description: This function will compute the distance to the -// indicated point, assumed to be in eye coordinates, -// from the camera plane. The point is assumed to be -// in the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// -PN_stdfloat CLP(GraphicsStateGuardian):: -compute_distance_to(const LPoint3 &point) const { - return -point[2]; -} - //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::framebuffer_copy_to_texture // Access: Public, Virtual diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index f8ec534eb2..27fd475724 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -336,8 +336,6 @@ public: virtual PT(GeomMunger) make_geom_munger(const RenderState *state, Thread *current_thread); - virtual PN_stdfloat compute_distance_to(const LPoint3 &point) const; - virtual void clear(DrawableRegion *region); virtual bool framebuffer_copy_to_texture