Skip to content

gzorin/sdl-metal-cpp-example

Repository files navigation

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages