From dcdd504e3fe31ec7613fab0d3b0e91d03f28904c Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 17:15:49 +0100 Subject: [PATCH 1/6] ode: Fix warnings when copying OdeTriMeshGeom --- panda/src/ode/odeTriMeshGeom.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/ode/odeTriMeshGeom.cxx b/panda/src/ode/odeTriMeshGeom.cxx index 257dbef3bb..27dc505775 100644 --- a/panda/src/ode/odeTriMeshGeom.cxx +++ b/panda/src/ode/odeTriMeshGeom.cxx @@ -35,8 +35,8 @@ OdeTriMeshGeom(OdeSpace &space, OdeTriMeshData &data) : OdeTriMeshGeom:: OdeTriMeshGeom(const OdeTriMeshGeom ©) : - OdeGeom(dCreateTriMesh(nullptr, copy.get_data_id(), nullptr, nullptr, nullptr)) { - OdeTriMeshData::link_data(_id, copy.get_data()); + OdeGeom(dCreateTriMesh(nullptr, copy.get_tri_mesh_data_id(), nullptr, nullptr, nullptr)) { + OdeTriMeshData::link_data(_id, copy.get_tri_mesh_data()); } OdeTriMeshGeom:: From 2a65f583d0b31505cfbb20e10521f5030994a030 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 17:16:18 +0100 Subject: [PATCH 2/6] cocoadisplay: Small tweak to fullscreen fix --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 044329608c..3921f06a25 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -211,17 +211,15 @@ begin_frame(FrameMode mode, Thread *current_thread) { cocoagsg->lock_context(); // Set the drawable. - if (_properties.get_fullscreen()) { + if (_properties.get_fullscreen() && !is_arm64_mac()) { // Fullscreen. Note that this call doesn't work with the newer // Metal-based OpenGL drivers. - if (!is_arm64_mac()) { - CGLError err = CGLSetFullScreenOnDisplay((CGLContextObj) [cocoagsg->_context CGLContextObj], CGDisplayIDToOpenGLDisplayMask(_display)); - if (err != kCGLNoError) { - cocoadisplay_cat.error() - << "Failed call to CGLSetFullScreenOnDisplay with display mask " - << CGDisplayIDToOpenGLDisplayMask(_display) << ": " << CGLErrorString(err) << "\n"; - return false; - } + CGLError err = CGLSetFullScreenOnDisplay((CGLContextObj) [cocoagsg->_context CGLContextObj], CGDisplayIDToOpenGLDisplayMask(_display)); + if (err != kCGLNoError) { + cocoadisplay_cat.error() + << "Failed call to CGLSetFullScreenOnDisplay with display mask " + << CGDisplayIDToOpenGLDisplayMask(_display) << ": " << CGLErrorString(err) << "\n"; + return false; } } else { // Although not recommended, it is technically possible to use the same From c85cc8f2e8c14e2bd27136907e8fcbb0ae7e08ed Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 17:20:41 +0100 Subject: [PATCH 3/6] cocoadisplay: fix unprotected debug/spam prints --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 3921f06a25..2e6c2a3685 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -230,8 +230,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { _context_needs_update = true; [cocoagsg->_context setView:_view]; - cocoadisplay_cat.spam() - << "Switching context to view " << _view << "\n"; + if (cocoadisplay_cat.is_spam()) { + cocoadisplay_cat.spam() + << "Switching context to view " << _view << "\n"; + } } } @@ -1070,8 +1072,11 @@ set_properties_now(WindowProperties &properties) { frame.origin.x = x; frame.origin.y = container.size.height - y - frame.size.height; - cocoadisplay_cat.debug() - << "Setting window content origin to " << frame.origin.x << ", " << frame.origin.y << "\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Setting window content origin to " + << frame.origin.x << ", " << frame.origin.y << "\n"; + } if (_window != nil) { [_window setFrame:[_window frameRectForContentRect:frame] display:NO]; @@ -1739,16 +1744,20 @@ handle_close_request() { // and process it directly. throw_event(close_request_event); - cocoadisplay_cat.debug() - << "Window requested close. Rejecting, throwing event " - << close_request_event << " instead\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Window requested close. Rejecting, throwing event " + << close_request_event << " instead\n"; + } // Prevent the operating system from closing the window. return false; } - cocoadisplay_cat.debug() - << "Window requested close, accepting\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Window requested close, accepting\n"; + } // Let the operating system close the window normally. return true; @@ -1759,7 +1768,9 @@ handle_close_request() { */ void CocoaGraphicsWindow:: handle_close_event() { - cocoadisplay_cat.debug() << "Window is about to close\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() << "Window is about to close\n"; + } _window = nil; @@ -1995,15 +2006,19 @@ handle_mouse_button_event(int button, bool down) { _input->button_down(MouseButton::button(button)); #ifndef NDEBUG - cocoadisplay_cat.spam() - << "Mouse button " << button << " down\n"; + if (cocoadisplay_cat.is_spam()) { + cocoadisplay_cat.spam() + << "Mouse button " << button << " down\n"; + } #endif } else { _input->button_up(MouseButton::button(button)); #ifndef NDEBUG - cocoadisplay_cat.spam() - << "Mouse button " << button << " up\n"; + if (cocoadisplay_cat.is_spam()) { + cocoadisplay_cat.spam() + << "Mouse button " << button << " up\n"; + } #endif } } From 5fa3f3eb6880bab9dd4d99310427f56ddfef7404 Mon Sep 17 00:00:00 2001 From: LD Date: Sat, 11 Jun 2022 22:31:40 +0200 Subject: [PATCH 4/6] cocoadisplay: Call remove_all_windows() when the application is about to close Part of #1321 --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 2 +- panda/src/cocoadisplay/cocoaPandaAppDelegate.h | 11 +++++++++-- panda/src/cocoadisplay/cocoaPandaAppDelegate.mm | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 2e6c2a3685..40d6a6ea5f 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -99,7 +99,7 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, if (NSApp == nil) { [CocoaPandaApp sharedApplication]; - CocoaPandaAppDelegate *delegate = [[CocoaPandaAppDelegate alloc] init]; + CocoaPandaAppDelegate *delegate = [[CocoaPandaAppDelegate alloc] initWithEngine:engine]; [NSApp setDelegate:delegate]; #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.h b/panda/src/cocoadisplay/cocoaPandaAppDelegate.h index b4af5deb55..6dd56b68e5 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.h +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.h @@ -14,9 +14,16 @@ #import #import -// Cocoa is picky about where and when certain methods are called in the initialization process. -@interface CocoaPandaAppDelegate : NSObject +class GraphicsEngine; +// Cocoa is picky about where and when certain methods are called in the initialization process. +@interface CocoaPandaAppDelegate : NSObject { + @private + GraphicsEngine *_engine; +} + +- (id) initWithEngine:(GraphicsEngine *)engine; - (void)applicationDidFinishLaunching:(NSNotification *)notification; +- (void)applicationWillTerminate:(NSNotification *)notification; @end diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm index dbb5452c75..1906e15d44 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm @@ -12,12 +12,28 @@ */ #import "cocoaPandaAppDelegate.h" +#include "graphicsEngine.h" @implementation CocoaPandaAppDelegate +- (id) initWithEngine:(GraphicsEngine *)engine { + + if (self = [super init]) { + _engine = engine; + } + + return self; +} + - (void)applicationDidFinishLaunching:(NSNotification *)notification { // This only seems to work when called here. [NSApp activateIgnoringOtherApps:YES]; } +- (void)applicationWillTerminate:(NSNotification *)notification { + // The application is about to be closed, tell the graphics engine to close + // all the windows. + _engine->remove_all_windows(); +} + @end From 4979a8ba3f8560abbf4b490865c16aa1fb16f218 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 17:48:33 +0100 Subject: [PATCH 5/6] cocoadisplay: More graceful application termination behavior See #1321 --- panda/src/cocoadisplay/cocoaPandaAppDelegate.h | 1 + panda/src/cocoadisplay/cocoaPandaAppDelegate.mm | 16 ++++++++++++++++ .../src/cocoadisplay/cocoaPandaWindowDelegate.h | 1 + .../src/cocoadisplay/cocoaPandaWindowDelegate.mm | 16 ++++++++++++---- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.h b/panda/src/cocoadisplay/cocoaPandaAppDelegate.h index 6dd56b68e5..4fdb5483e9 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.h +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.h @@ -24,6 +24,7 @@ class GraphicsEngine; - (id) initWithEngine:(GraphicsEngine *)engine; - (void)applicationDidFinishLaunching:(NSNotification *)notification; +- (BOOL)applicationShouldTerminate:(NSApplication *)app; - (void)applicationWillTerminate:(NSNotification *)notification; @end diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm index 1906e15d44..5855c3025b 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm @@ -30,9 +30,25 @@ [NSApp activateIgnoringOtherApps:YES]; } +- (BOOL)applicationShouldTerminate:(NSApplication *)app { + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Received applicationShouldTerminate, closing all Cocoa windows\n"; + } + // Call performClose on all the windows. This should make ShowBase shut down. + for (NSWindow *window in [app windows]) { + [window performClose:nil]; + } + return FALSE; +} + - (void)applicationWillTerminate:(NSNotification *)notification { // The application is about to be closed, tell the graphics engine to close // all the windows. + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Received applicationWillTerminate, removing all windows\n"; + } _engine->remove_all_windows(); } diff --git a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h index 93d5b7b35b..c71b1d509d 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h +++ b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h @@ -34,6 +34,7 @@ class CocoaGraphicsWindow; - (void)windowDidBecomeKey:(NSNotification *)notification; - (void)windowDidResignKey:(NSNotification *)notification; - (BOOL)windowShouldClose:(id)sender; +- (void)windowWillClose:(id)sender; // TODO: handle fullscreen on Lion. diff --git a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm index 17fae241f3..dbbbe8e5b2 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm @@ -51,11 +51,19 @@ } - (BOOL) windowShouldClose:(id)sender { - bool should_close = _graphicsWindow->handle_close_request(); - if (should_close) { - _graphicsWindow->handle_close_event(); + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Received windowShouldClose for window " << _graphicsWindow << "\n"; } - return should_close; + return _graphicsWindow->handle_close_request(); +} + +- (void) windowWillClose:(id)sender { + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Received windowWillClose for window " << _graphicsWindow << "\n"; + } + _graphicsWindow->handle_close_event(); } @end From 02a1e116f99bae0b34fb3fed7d2864b5eafabe3a Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 17:55:58 +0100 Subject: [PATCH 6/6] readme: Minor wording tweaks Closes #1319 Co-authored-by: IsakTheHacker <67378443+IsakTheHacker@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8801356188..47ef68448d 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,10 @@ makepanda\makepanda.bat --everything --installer --msvc-version=14.3 --windows-s When the build succeeds, it will produce an .exe file that you can use to install Panda3D on your system. -Note: you may choose to remove --no-eigen and build with Eigen support in +**Note:** you may choose to remove `--no-eigen` and build with Eigen support in order to improve runtime performance. However, this will cause the build to take hours to complete, as Eigen is a heavily template-based library, and the -the MSVC compiler does not perform well under these circumstances. +MSVC compiler does not perform well under those circumstances. Linux -----