• Stars
    star
    156
  • Rank 231,568 (Top 5 %)
  • Language
    C
  • License
    MIT License
  • Created almost 6 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

More Repositories

1

cglm

📽 Highly Optimized 2D / 3D Graphics Math (glm) for C
C
2,039
star
2

AssetKit

🎨 Modern 2D/3D - Importer • Exporter • Util - Library, also known as (AssetIO)
C
178
star
3

gkern

🎥 Graphics Kernel: flexible, highly configurable, extensible render engine (realtime + offline)
C
96
star
4

ds

🔗 Common Data Structures and Algorithms
C
47
star
5

tm

timers and timeline
C
39
star
6

gpu

🔭 cross platform general purpose GPU library - optimized for rendering
C
23
star
7

json

🔋 In-place lightweight JSON parser
C
23
star
8

xml

🔋 In-place lightweight XML parser
C
9
star
9

phy

physics engine written in C
C
9
star
10

im

📷 image loader library for fast load images especially for rendering and image analysis (In Progress)
C
8
star
11

simple-collada-viewer

A simple viewer to show how to use AssetKit, libgk, assetkit-gl and cglm libraries (with screenshot)
C
6
star
12

mathkit

C vector, matrix library (including 3d, opengl math)
C
5
star
13

libsig

Signal/Event handling lib for C/C++
C++
4
star
14

rays

Physically-based path tracer for production rendering (may include fast ray tracer as altnative render path)
C
4
star
15

asset-xchange

new file format to store 2d/3d assets for game and films
3
star
16

assetkit-gl

Bridge library for loading AssetKit to libgk
C
3
star
17

filt

Image Filter
C
2
star
18

ui

🖱 user interface library top of GPU (OpenGL/Metal/Vulkan...)
Objective-C
2
star
19

libui

Cross platform user interface (including graphics) library for C++
C++
1
star
20

netutils

Network Utils for C/C++
C
1
star
21

http

http parser and utility
C
1
star
22

sample-models

3D sample models for loaders (AssetKit) for testing purpose
1
star
23

Qt-Dispatch

C++
1
star