diff --git a/README.md b/README.md index b6af9a2c91..c424651845 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 ----- diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index d360cac485..015dfe2d82 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]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; @@ -209,17 +209,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 diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.h b/panda/src/cocoadisplay/cocoaPandaAppDelegate.h index b4af5deb55..4fdb5483e9 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.h +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.h @@ -14,9 +14,17 @@ #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; +- (BOOL)applicationShouldTerminate:(NSApplication *)app; +- (void)applicationWillTerminate:(NSNotification *)notification; @end diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm index dbb5452c75..5855c3025b 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm @@ -12,12 +12,44 @@ */ #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]; } +- (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(); +} + @end diff --git a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h index 5e28caaf6b..490db59ee8 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h +++ b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h @@ -30,6 +30,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 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::