Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from Carbon to Cocoa #18

Merged
merged 7 commits into from
Jan 10, 2019
Merged

Conversation

cochrane
Copy link
Contributor

The Carbon API was unofficially retired in 2007 (meaning it was not ported to 64 bit at the time), and officially deprecated in 2012. There is no excuse for an app written in 2016 to still use it.

This commit switches the code to use the Cocoa API instead. This amounts pretty much to a full rewrite of the main.cpp file since Cocoa has rather particular structure requirements. No game-specific parts were touched, however.

This pull request includes all the changes from pull request #17, so if you decide to accept this one then you can just close the other.

As the comment says: In Compatibility mode (used by including gl.h instead of gl3.h), OS X only supports OpenGL 2 with some extensions. VAOs, which are an OpenGL 3 feature, are not available under their OpenGL 3 name. Instead they are exposed through an Apple-specific extension that works identically in all respects that matter. With this, it is possible to build and run the program without any trouble.
The Microseconds function is a leftover from the days of Carbon and
deprecated since 10.8.
Yes, that does amount to pretty much a rewrite of the main.cpp. Don’t
worry, it’s not that long. It also got renamed to main.mm because it’s
an Objective-C++ file now.

There are still a few rough edges, since I didn’t want to add a nib to
any of this. Among other things, the display link probably starts a
tiny bit too early, resulting in gameplay noises being heard before the
game is actually visible. Resizing may leave white flashes; not quite
sure what that’s about but they are brief. Finally, no menus of any
kind. At least a system and window menu would be necessary (to support
Cmd+Q).
The OS X code did not create a main menu. While it arguably doesn’t
really need one, it’s considered impolite to forgo it on this platform,
especially since all standard key commands interact with the menu bar
(they quickly highlight the menu item that has the actual
user-selectable command to provide some feedback).

With this menu added, the Command+Q shortcut to quit the application
now also works.
I’m not sure what to actually return here anyway, but apparently this
symbol does not always exist.
@cochrane cochrane mentioned this pull request Nov 19, 2016
40 tasks
@XProger XProger merged commit 8769bdb into XProger:master Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants