Simple Metal Sample Project

I am an amateur coder and write programs for fun. I have recently set myself the task of learning Metal. In this endeavor I found the gap between Apple's "Hello Triangle" sample code and the "Deferred Lighting" sample code to be rather large. I found it a challenge to get a simple 3D model up and visible on the display. Finally I produced a simple program which defines vertex data for the five platonic solids and displays them in a MTKView. I was thinking others might be interest in seeing how I approached this problem. I have uploaded the XCode project to github where it is available for download. I hope others in the same boat as I was a week ago might benefit from this. Also, I would be receptive to any criticism. If I am doing something dumb I would like to know about it.


https://github.com/BDMackenzie/Metal_Sample_Code



Next I plan to tackle lighting and applying textures to the model.

Replies

I am no graphics expert but have used OpenGL, DirectX 11 and Vulkan to varying extents and I find Metal to be simplest API of them all.


I found Warren Moore's Metal By Example useful too.


Good luck to you!

You're supposed to add the source code to github, not a zip of the project 🙂 Then we can take a look at the code without having to mess about. (It'll also mean you can track changes you make to the code, roll things back if necessary etc.)

I pefer to keep to keep the project repository private and upload snapshots of the project to the sample code repository.

Hey, thanks for the link. Picking is something on my list and he has a how to on that. I think I'll find the site very useful.

I have added texturing and a lighting model to my sample code project. The new version, Play_Tonic 2.zip may be downloaded at the link cited in the original post. I found creating textures from image files to be quite straightforward. For the lighting model I ported Example 7.4: Point-Light Source Lighting from the book OpenGL Programming Guide, Ninth Edition.