🎮 C Bindings/Wrappers for Apple's METAL framework

Overview

Apple's Metal for C

C Wrapper for Apple's METAL framework. This library is C bindings of Metal API (MetalGL). Since OpenGL is deprecated, this library may build OpenGL api on this library. This could save old games and apps on macOS platform.

Also since this is C bindings for Metal API, it also can help other languages to use Metal with this library.

Currently this library does not alloc memory for its types. It retains ObjC objects and work on them. This also makes the library very very thin layer on ObjC.

This is NOT generic rendering library. If you need to that, check this one: Graphics Kernel, it is also written in C and provides common rendering techniques. It will be cross platform. Since Graphics Kernel needs to run on macOS, this library will be macOS backend for that purpose.

Design

MT_EXPORT
MT_API_AVAILABLE(mt_macos(10.11), mt_ios(8.0))  /* API AVAILABILITY */
[returnType]
mt[FunctionName]([Params]);

functions are marked with MT_API_AVAILABLE which helps to identify which api available on which platform. The first parameter is minimum macOS version and the second one is the minimum iOS version.

Building and linking

A CMake project is included that builds a shared library. The headers for that library are contained in include/cmt, and are bare-C.

Sample usage:

MtDevice                   *device;
MtCommandQueue             *cmdQueue;
MtRenderPipelineDescriptor *pipDesc;
MtLibrary                  *lib;
MtFunction                 *vertFunc, *fragFunc;
MtRenderPipelineState      *pip;

device   = mtCreateDevice();
lib      = mtDefaultLibrary(device);
cmdQueue = mtCommandQueueCreate(device);
pipDesc  = mtRenderDescCreate(MtPixelFormatBGRA8Unorm);

vertFunc = mtCreateFunc(lib, "vertexShader");
fragFunc = mtCreateFunc(lib, "fragmentShader");

mtSetFunc(pipDesc, vertFunc, MT_FUNC_VERT);
mtSetFunc(pipDesc, fragFunc, MT_FUNC_FRAG);

pip = mtRenderStateCreate(device, pipDesc);
  

Trademarks

Apple name/logo and Metal are trademarks of Apple Inc. This software only provides C bindings for Metal, it is not alternative to Metal.

Issues
  • A fork

    A fork

    Hi Recep,

    I recently got interested in wrapping Metal in Julia to do some GPGPU computing, and started from your repository to write the wrappers to C that I would need.

    I ended up wrapping most of the Compute pipeline, kernel reflection stuff... I think I wrapped most of Metal, except for 3d-rendering-specific stuff because I'm not really interested in it at the moment.

    It's all in my fork, in case you are interested.

    Thanks again for starting this work!

    opened by PhilipVinc 1
Owner
Recep Aslantas
alone with numbers
Recep Aslantas
Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal

Low Level Graphics Library (LLGL) Documentation NOTE: This repository receives bug fixes only, but no major updates. Pull requests may still be accept

Lukas Hermanns 1.4k Jun 19, 2022
OpenGL 4.6 on Metal

MGL OpenGL 4.6 on Metal This is a start for porting OpenGL 4.6 on top of Metal, most of it is functional and has been tested. The tests are functional

null 316 Jun 26, 2022
A header-only C-like shading language compiler that writes Metal, HLSL, GLSL

GPUC A generic shading language compiler that writes metal, HLSL, and GLSL GPUC is a work in progress, not ready for prime time. The primary motivatio

Garett Bass 57 Jun 22, 2022
C++ (with python bindings) library for easily reading/writing/manipulating common animation particle formats such as PDB, BGEO, PTC. See the discussion group @ http://groups.google.com/group/partio-discuss

Partio - A library for particle IO and manipulation This is the initial source code release of partio a tool we used for particle reading/writing. It

Walt Disney Animation Studios 400 Jun 20, 2022
Deno gl - WIP Low-level OpenGL (GLFW) bindings and WebGL API implementation for Deno.

deno_gl WIP Low-level OpenGL (GLFW) bindings and WebGL API implementation for Deno. Building Make dist directory if it doesn't exist. Build gl helper

DjDeveloper 14 Jun 11, 2022
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

bgfx - Cross-platform rendering library GitHub Discussions Discord Chat What is it? Cross-platform, graphics API agnostic, "Bring Your Own Engine/Fram

Бранимир Караџић 11.7k Jun 22, 2022
A modern cross-platform low-level graphics library and rendering framework

Diligent Engine A Modern Cross-Platform Low-Level 3D Graphics Library Diligent Engine is a lightweight cross-platform graphics API abstraction library

Diligent Graphics 2.4k Jun 29, 2022
4K Executable Graphics framework

Blossom ?? Blossom is a small framework for creating 4K Executable Graphics artworks for the demoscene. You are free to use this as the basis for your

Luna 159 Jun 22, 2022
graphics and computational physics framework

atto Graphics and computational physics research framework: aligned memory allocation, string manipulation, file IO, etc. 2-, 3- and 4-dimensional vec

Carlos Correia 1 Oct 25, 2021
2D Graphics Framework for C99

roita 2D Graphics Framework for C99. Install clone the repo cd into roita run make install Dependencies -lX11 -lpthread -lxcb -lXau -lXdmcp -lGLX -lGL

r0tthin 1 Dec 4, 2021
Remake of Fireboy and Watergirl in a C++ OpenGL&SDL framework

Fireboy and Watergirl After receiving an assignment to make a 2D grid-based game we decided to make a rmake of the popular game 'Fireboy and Watergirl

Sander De Keukelaere 2 Dec 2, 2021
Basic framework for D3D11 init, model/texture loading, shader compilation and camera movement.

reed-framework Basic framework for D3D11 init, model/texture loading, camera movement, etc. Instructions: #include <framework.h> Link with framework.l

Nathan Reed 34 May 18, 2022
🎮 C Bindings/Wrappers for Apple's METAL framework

Apple's Metal for C C Wrapper for Apple's METAL framework. This library is C bindings of Metal API (MetalGL). Since OpenGL is deprecated, this library

Recep Aslantas 103 Jun 22, 2022
Metal-cpp is a low-overhead C++ interface for Metal that helps developers add Metal functionality to graphics apps, games, and game engines that are written in C++.

About metal-cpp is a low overhead and header only C++ interface for Metal that helps developers add Metal functionality to graphics applications that

Бранимир Караџић 138 Jun 27, 2022
Dummy code for using an ESP32 as a lightbulb in Apples HomeKit.

ESP32 HomeKit Lightbulb A dummy implementation of a HomeKit lightbulb using the ESP HomeKit SDK by Espressif for the ESP32. Prerequisites PlatformIO U

Louis Meyer 2 Apr 27, 2022
autogen bindings to Raylib 4.0 and convenience wrappers on top. Requires use of `unsafe`

Raylib-CsLo Raylib-CsLo LowLevel autogen bindings to Raylib 4.0 and convenience wrappers on top. Requires use of unsafe A focus on performance. No run

NotNot 51 Jun 16, 2022
Distributed (Deep) Machine Learning Community 677 Apr 14, 2022
Thin C++-flavored wrappers for the CUDA Runtime API

cuda-api-wrappers: Thin C++-flavored wrappers for the CUDA runtime API Branch Build Status: Master | Development: nVIDIA's Runtime API for CUDA is int

Eyal Rozenberg 496 Jun 27, 2022
C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions (SSE, AVX, NEON, AVX512)

C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions (SSE, AVX, NEON, AVX512)

Xtensor Stack 1.4k Jun 24, 2022
VNOpenAI 22 Jun 15, 2022
Mini-async-log-c - Mini async log C port. Now with C++ wrappers.

Description A C11/C++11 low-latency wait-free producer (when using Thread Local Storage) asynchronous textual data logger with type-safe strings. Base

null 66 Dec 7, 2021
Capstone disassembly/disassembler framework: Core + bindings.

Capstone disassembly/disassembler framework: Core (Arm, Arm64, BPF, EVM, M68K, M680X, MOS65xx, Mips, PPC, RISCV, Sparc, SystemZ, TMS320C64x, Web Assembly, X86, X86_64, XCore) + bindings.

Capstone Engine 5.7k Jun 22, 2022
A C++ framework for MDPs and POMDPs with Python bindings

AI-Toolbox This C++ toolbox is aimed at representing and solving common AI problems, implementing an easy-to-use interface which should be hopefully e

Eugenio Bargiacchi 556 Jun 27, 2022
Minimalistic C++/Python GUI library for OpenGL, GLES2/3, Metal, and WebAssembly/WebGL

NanoGUI NanoGUI is a minimalistic cross-platform widget library for OpenGL 3+, GLES 2/3, and Metal. It supports automatic layout generation, stateful

Mitsuba Physically Based Renderer 1k Jun 27, 2022
Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal

Low Level Graphics Library (LLGL) Documentation NOTE: This repository receives bug fixes only, but no major updates. Pull requests may still be accept

Lukas Hermanns 1.4k Jun 19, 2022
the checkra1n set of tools targeting bare metal, Linux and Windows

Universal toolchain Low-effort cross-compiling for the masses. What's Universal toolchain? It's a collection of sysroots and shell scripts in such a w

null 62 May 27, 2022
Because why not? Pi Zero bare metal project that ends in an RTOS implementation

PiZeroRTOS Because why not? This repo starts out as a Pi Zero bare metal project and it could very well end up as a viable RTOS implementation with a

null 7 Feb 13, 2022
A C++ bare metal environment for Raspberry Pi with USB (32 and 64 bit)

A C++ bare metal environment for Raspberry Pi with USB (32 and 64 bit)

Rene Stange 1.3k Jun 20, 2022