gzorin / sdl-metal-cpp-example

Use Metal's C++ interface to draw a triangle in a SDL window

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sdl-metal-cpp-example

This project is an example of using the Metal API's C++ interface to draw a triangle. The project uses SDL 2 to create the window.

I've added a few things to Apple's C++ bindings:

  • CAMetalLayer.hpp provides a C++ binding for Core Animation's CAMetalLayer. Note that the included example uses this extension, and will therefore not work with the upstream version of 'metal-cpp'.

    Apple has since added this.

  • shared_ptr.hpp is an implementation of the standard C++ shared_ptr that calls retain() and release() to manage the lifetime of the object.

    Assigning a NSObject, or passing it into the constructor, will always increase the object's reference count. To manage the lifetime of a newly-created NSObject, which presumably has its reference count set to 1, use the function make_owned(), which creates a new shared_ptr without increasing the object's reference count.

    Apple has since added NS::SharedPtr, but I'm leaving mine in since it resembles the standard C++ shared_ptr.

About

Use Metal's C++ interface to draw a triangle in a SDL window

License:Apache License 2.0


Languages

Language:C++ 98.5%Language:Python 0.9%Language:CMake 0.3%Language:Metal 0.2%Language:C 0.1%