vurtun / nuklear

A single-header ANSI C gui library
13.7k stars 1.11k forks source link

[request] Add Mac OS X demo (7$) #747

Open DeXP opened 6 years ago

DeXP commented 6 years ago

It would be nice to have a demo on native Mac OS X facilities. For example, create OpenGL window by Cocoa. The demo should not use SDL/GLFW or other crossplatform libraries (since these demos exist already).

7$ bounty

ghost commented 5 years ago

OpenGL

Apple has recently deprecated OpenGL.

Which is why i'll have to do this eventually.

Rather than create 2 separate drivers (opengl,metal), it might be better to do this with Quartz/CoreGraphics.

CoreGraphics is hardware accelerated, C API, and part of all macOS 10.0-present, and iOS 2.0-present.

Font handling changes from ATSU -> CoreText at OS 10.5, after which it can load TTF from memory like GDI. Prior to that it could load only system fonts (see cairo-quartz-font.c and ATSUFindFontFromName). -- Edit: For <10.5, could either force Lucida Grande, or borrow the typesetting code from the rawfb driver. That's what the legacy Xlib driver should be doing imo.

There is no longer an [official] Apple API to create a window in pure C.

That would mean breaking Nuklear's strict C89 rule to use Objective-C, unless you work with the obj-c runtime directly like C-Macs.

I don't know how stable that ABI is expected to be.

DeXP commented 5 years ago

I mentioned OpenGL because it could be easy to port. Another native graphics output is fine for me too, but it have to support images and ttf.

TTF loading with fallback on older systems is fine too.

The demo itself should not be pure C. It should use native technologies for a platform. So resulting application will have a good productivity and a small size. So Objective-C for window creation is totally fine.