|
@@ -65,6 +65,16 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|
|
_fullscreen_mode = NULL;
|
|
_fullscreen_mode = NULL;
|
|
|
_windowed_mode = NULL;
|
|
_windowed_mode = NULL;
|
|
|
|
|
|
|
|
|
|
+ // Now that we know for sure we want a window, we can create the Cocoa app.
|
|
|
|
|
+ // This will cause the application icon to appear and start bouncing.
|
|
|
|
|
+ if (NSApp == nil) {
|
|
|
|
|
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
|
|
|
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
|
|
|
+#endif
|
|
|
|
|
+ [NSApp finishLaunching];
|
|
|
|
|
+ [NSApp activateIgnoringOtherApps:YES];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
GraphicsWindowInputDevice device =
|
|
GraphicsWindowInputDevice device =
|
|
|
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
|
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
|
|
add_input_device(device);
|
|
add_input_device(device);
|
|
@@ -144,7 +154,7 @@ begin_frame(FrameMode mode, Thread *current_thread) {
|
|
|
nassertr(_view != nil, false);
|
|
nassertr(_view != nil, false);
|
|
|
|
|
|
|
|
// Place a lock on the context.
|
|
// Place a lock on the context.
|
|
|
- CGLLockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->lock_context();
|
|
|
|
|
|
|
|
// Set the drawable.
|
|
// Set the drawable.
|
|
|
if (_properties.get_fullscreen()) {
|
|
if (_properties.get_fullscreen()) {
|
|
@@ -210,7 +220,7 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|
|
CocoaGraphicsStateGuardian *cocoagsg;
|
|
CocoaGraphicsStateGuardian *cocoagsg;
|
|
|
DCAST_INTO_V(cocoagsg, _gsg);
|
|
DCAST_INTO_V(cocoagsg, _gsg);
|
|
|
|
|
|
|
|
- CGLUnlockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->unlock_context();
|
|
|
|
|
|
|
|
if (mode == FM_render) {
|
|
if (mode == FM_render) {
|
|
|
// end_render_texture();
|
|
// end_render_texture();
|
|
@@ -239,7 +249,7 @@ end_flip() {
|
|
|
CocoaGraphicsStateGuardian *cocoagsg;
|
|
CocoaGraphicsStateGuardian *cocoagsg;
|
|
|
DCAST_INTO_V(cocoagsg, _gsg);
|
|
DCAST_INTO_V(cocoagsg, _gsg);
|
|
|
|
|
|
|
|
- CGLLockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->lock_context();
|
|
|
|
|
|
|
|
// Swap the front and back buffer.
|
|
// Swap the front and back buffer.
|
|
|
[cocoagsg->_context flushBuffer];
|
|
[cocoagsg->_context flushBuffer];
|
|
@@ -247,7 +257,7 @@ end_flip() {
|
|
|
// Flush the window
|
|
// Flush the window
|
|
|
[[_view window] flushWindow];
|
|
[[_view window] flushWindow];
|
|
|
|
|
|
|
|
- CGLUnlockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->unlock_context();
|
|
|
}
|
|
}
|
|
|
GraphicsWindow::end_flip();
|
|
GraphicsWindow::end_flip();
|
|
|
}
|
|
}
|
|
@@ -399,6 +409,16 @@ open_window() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Iterate over the screens to find the one with our display ID.
|
|
|
|
|
+ NSScreen *screen;
|
|
|
|
|
+ NSEnumerator *e = [[NSScreen screens] objectEnumerator];
|
|
|
|
|
+ while (screen = (NSScreen *) [e nextObject]) {
|
|
|
|
|
+ NSNumber *num = [[screen deviceDescription] objectForKey: @"NSScreenNumber"];
|
|
|
|
|
+ if (cocoa_pipe->_display == (CGDirectDisplayID) [num longValue]) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Center the window if coordinates were set to -1 or -2 TODO: perhaps in
|
|
// Center the window if coordinates were set to -1 or -2 TODO: perhaps in
|
|
|
// future, in the case of -1, it should use the origin used in a previous
|
|
// future, in the case of -1, it should use the origin used in a previous
|
|
|
// run of Panda
|
|
// run of Panda
|
|
@@ -406,7 +426,7 @@ open_window() {
|
|
|
if (parent_nsview != NULL) {
|
|
if (parent_nsview != NULL) {
|
|
|
container = [parent_nsview bounds];
|
|
container = [parent_nsview bounds];
|
|
|
} else {
|
|
} else {
|
|
|
- container = [cocoa_pipe->_screen frame];
|
|
|
|
|
|
|
+ container = [screen frame];
|
|
|
container.origin = NSMakePoint(0, 0);
|
|
container.origin = NSMakePoint(0, 0);
|
|
|
}
|
|
}
|
|
|
int x = _properties.get_x_origin();
|
|
int x = _properties.get_x_origin();
|
|
@@ -453,7 +473,7 @@ open_window() {
|
|
|
_window = [[CocoaPandaWindow alloc]
|
|
_window = [[CocoaPandaWindow alloc]
|
|
|
initWithContentRect: rect
|
|
initWithContentRect: rect
|
|
|
styleMask:windowStyle
|
|
styleMask:windowStyle
|
|
|
- screen:cocoa_pipe->_screen
|
|
|
|
|
|
|
+ screen:screen
|
|
|
window:this];
|
|
window:this];
|
|
|
|
|
|
|
|
if (_window == nil) {
|
|
if (_window == nil) {
|
|
@@ -464,7 +484,7 @@ open_window() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Lock the context, so we can safely operate on it.
|
|
// Lock the context, so we can safely operate on it.
|
|
|
- CGLLockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->lock_context();
|
|
|
|
|
|
|
|
// Create the NSView to render to.
|
|
// Create the NSView to render to.
|
|
|
NSRect rect = NSMakeRect(0, 0, _properties.get_x_size(), _properties.get_y_size());
|
|
NSRect rect = NSMakeRect(0, 0, _properties.get_x_size(), _properties.get_y_size());
|
|
@@ -588,7 +608,7 @@ open_window() {
|
|
|
cocoagsg->reset_if_new();
|
|
cocoagsg->reset_if_new();
|
|
|
|
|
|
|
|
// Release the context.
|
|
// Release the context.
|
|
|
- CGLUnlockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->unlock_context();
|
|
|
|
|
|
|
|
if (!cocoagsg->is_valid()) {
|
|
if (!cocoagsg->is_valid()) {
|
|
|
close_window();
|
|
close_window();
|
|
@@ -637,9 +657,9 @@ close_window() {
|
|
|
cocoagsg = DCAST(CocoaGraphicsStateGuardian, _gsg);
|
|
cocoagsg = DCAST(CocoaGraphicsStateGuardian, _gsg);
|
|
|
|
|
|
|
|
if (cocoagsg != NULL && cocoagsg->_context != nil) {
|
|
if (cocoagsg != NULL && cocoagsg->_context != nil) {
|
|
|
- CGLLockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->lock_context();
|
|
|
[cocoagsg->_context clearDrawable];
|
|
[cocoagsg->_context clearDrawable];
|
|
|
- CGLUnlockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->unlock_context();
|
|
|
}
|
|
}
|
|
|
_gsg.clear();
|
|
_gsg.clear();
|
|
|
}
|
|
}
|
|
@@ -1429,9 +1449,9 @@ handle_close_event() {
|
|
|
cocoagsg = DCAST(CocoaGraphicsStateGuardian, _gsg);
|
|
cocoagsg = DCAST(CocoaGraphicsStateGuardian, _gsg);
|
|
|
|
|
|
|
|
if (cocoagsg != NULL && cocoagsg->_context != nil) {
|
|
if (cocoagsg != NULL && cocoagsg->_context != nil) {
|
|
|
- CGLLockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->lock_context();
|
|
|
[cocoagsg->_context clearDrawable];
|
|
[cocoagsg->_context clearDrawable];
|
|
|
- CGLUnlockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
|
|
|
|
|
|
+ cocoagsg->unlock_context();
|
|
|
}
|
|
}
|
|
|
_gsg.clear();
|
|
_gsg.clear();
|
|
|
}
|
|
}
|