high "Make current" with cocoa/fullscreen

I’ve switched my OSX build from using carbon to cocoa, which solved a problem I was having with the mouse cursor jumping around whenever the mouse wheel was used. The problem now is that the game runs very slowly in fullscreen now, with the vast majority of the time being spent in “Make current” in pstats. In a window, it runs just as well as when the build was using carbon. Any ideas why this might be?

I remember having a lot of trouble getting fullscreen to work right on Cocoa, so I’m not entirely surprised that it’s still a bit iffy.

“Make current” refers to all of CocoaGraphicsWindow::begin_frame. This method is supposed to prepare the window and graphics context for being rendered to. This includes getting a lock on the context, updating the context, and the magic [NSOpenGLContext setFullscreen] call, and indeed the actual makeCurrentContext call.

Hey, now that I’m taking a fresh look at the code, I’m noticing that it calls setFullscreen every frame. I’m not really sure if that’s supposed to happen every frame; if not, that may be what’s causing the slowdown. Would you mind trying to see if calling it only once (and storing the fullscreen state in a member boolean) does the trick?

Hmm, I must have messed something up, I’m just getting a black screen even in windowed mode now.
Probably something silly, I’ll give it another go later.

That’s exactly the type of problem that got me stuck for weeks, too.

In any case, it appears that using setFullscreen on the NSOpenGLContext is now deprecated. It is now recommended to simply create a view that spans the entire screen and is undecorated:
developer.apple.com/library/mac … 1987-CH210

I suppose I’d have to change the desktop resolution somehow then, if I wanted to have a fullscreen window at a resolution other than the current one.

Changing resolution is a separate process from making the window fullscreen. It’s done by CGDisplaySetDisplayMode, in do_switch_fullscreen.