• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    C
  • License
    MIT License
  • Created over 6 years ago
  • Updated 11 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,271
star
2

AssetKit

๐ŸŽจ Modern 2D/3D - Importer โ€ข Exporter โ€ข Util - Library, also known as (AssetIO)
C
186
star
3

gkern

๐ŸŽฅ Graphics Kernel: flexible, highly configurable, extensible render engine (realtime + offline)
C
98
star
4

ds

๐Ÿ”— Common Data Structures and Algorithms
C
50
star
5

tm

timers and timeline
C
40
star
6

gpu

๐Ÿ”ญ cross platform general purpose GPU library - optimized for rendering
C
31
star
7

json

๐Ÿ”‹ In-place lightweight JSON parser
C
25
star
8

im

๐Ÿ“ท image loader library for fast load images especially for rendering and image analysis (In Progress)
C
10
star
9

phy

physics engine written in C
C
10
star
10

simple-collada-viewer

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

libsig

Signal/Event handling lib for C/C++
C++
5
star
12

mathkit

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

rays

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

assetkit-gl

Bridge library for loading AssetKit to libgk
C
4
star
15

filt

Image Filter
C
3
star
16

asset-xchange

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

http

http parser and utility
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

sample-models

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

Qt-Dispatch

C++
1
star