A command-line-compilable example of Metal.
Objective-C++ Makefile C
Switch branches/tags
Nothing to show
Clone or download
Latest commit 887456f Oct 17, 2015
Failed to load latest commit information.
.gitignore Work in progress. Oct 5, 2015
Makefile Complete. Oct 12, 2015
common.h Work in progress. Oct 5, 2015
main.mm Fixed bug. Oct 12, 2015
readme.md Update readme.md Oct 17, 2015
result.png Added result image. Oct 17, 2015
shaders.metal Complete. Oct 12, 2015


Metal Programming without Xcode

A simple example of Metal written in Objective-C++ which can be compiled in command-line. result.png

How to pre-compile Metal shaders

Export PATH for Metal compiler

export PATH="$PATH:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin


echo 'export PATH="$PATH:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin"' >> ~/.bashrc


Just run the following command:

make shaders.metallib

or, if you want to do it manually:

Compile .metal file into .air

metal -std=osx-metal1.1 -o shaders.air shaders.metal

Archive .air into .metal-ar

metal-ar r shaders.metal-ar shaders.air

Make .metallib from metal-ar

metallib -o shaders.metallib shaders.metal-ar