🎮 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.

You might also like...
A simple game framework written in C++ using SDL

SGF SGF (Simple Game Framework) is, as the name implies; a very simple and easy to use game framework written in C++ using SDL. Currently the project

One framework for creating powerful cross-platform games.

MonoGame One framework for creating powerful cross-platform games. The spiritual successor to XNA with thousands of titles shipped across desktop, mob

🎮 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

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

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

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

Minerva: a fast and flexible tool for deep learning on multi-GPU. It provides ndarray programming interface, just like Numpy. Python bindings and C++ bindings are both available. The resulting code can be run on CPU or GPU. Multi-GPU support is very easy.
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

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, WinPcap, DPDK and PF_RING.
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)

Toolkit for software engineers to Deploy AI Systems Yourself (DAISY). DaisyKit SDK is the core of models and algorithms, which can be used to develop wrappers and applications for different platforms: mobile, embedded or web browsers.
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

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.

A C++ framework for MDPs and POMDPs with Python bindings
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

Minimalistic C++/Python GUI library for OpenGL, GLES2/3, Metal, and WebAssembly/WebGL
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

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) 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

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

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

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)

Comments
  • 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
Godot bindings for the Rapier3D physics engine

Godot bindings for the Rapier3D physics library How to use There are two parts: A Godot module which must be compiled with the engine.

David Hoppenbrouwers 27 Nov 23, 2022
LibRaylib Bindings for Crystal.

raylib-cr Crystal Bindings for raylib, a small and easy to use game development library. As for now the bindings only support the raw function calls f

Ian Rash 31 Nov 22, 2022
Cute Framework (CF for short) is the cutest framework available for making 2D games in C/C++

Cute Framework (CF for short) is the cutest framework available for making 2D games in C/C++. CF comprises of different features, where the various features avoid inter-dependencies. In this way using CF is about picking and choosing which pieces are needed for your game

null 307 Nov 25, 2022
Polycode is a cross-platform framework for creative code.

Polycode is a cross-platform framework for creative code. You can use it as a C++ API or as a standalone scripting language to get easy and simple acc

Ivan Safrin 2.4k Nov 28, 2022
Skynet is a lightweight online game framework

Skynet is a lightweight online game framework which can be used in many other fields.

云风 11.6k Nov 29, 2022
A simple localization framework that can re-localize in built maps based on FAST-LIO.

Realtime 3D global localization in a pre-built point cloud map. By fusing low-frequency global localization (about 0.5~0.2Hz), and high-frequency odometry from FAST-LIO, the entire system is computationally efficient.

KINO 238 Dec 3, 2022
A Framework for developing Unity games with Lua

UnityLua A Framework for developing Unity games with Lua Warning: This is not finished, I don't suggest using this until it is complete or you may run

Down 7 Jul 13, 2022
Advanced modding framework for multiplayer modifications

A suite of tools and libraries to accelerate multi-player modification development.

MafiaHub 29 Nov 28, 2022
dos-like is a programming library/framework, kind of like a tiny game engin

dos-like is a programming library/framework, kind of like a tiny game engine, for writing games and programs with a similar feel to MS-DOS productions from the early 90s. But rather than writing code that would run on a real DOS machine, dos-like is about making programs which runs on modern platforms like Windows, Mac and Linux, but which attempts to recreate the look, feel, and sound of old DOS programs.

Mattias Gustavsson 804 Nov 23, 2022
sdl based game framework

Hallow Engine an sdl-based game framework Install Procedure Install SDL2[https://libsdl.org] and take the .h(header) files from the include/ folder, t

Hallow - The Game Framework 6 Nov 24, 2021