• Stars
    star
    346
  • Rank 118,882 (Top 3 %)
  • Language
    C
  • Created almost 8 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

Header only tiny wavefront .obj loader in pure C99

tinyobjloader in C

Tiny but powerful header only wavefront obj loader written in C99.

If you are looking for C++ version, please see https://github.com/syoyo/tinyobjloader

Current status

Experimental. Loading geometry data would be OK, More testing required for materials and shapes.

Features

  • Single file, header only
  • Dependency-free pure C99 implementation(except for libc)
  • Provides mostly similar functionality as in C++ version. https://github.com/syoyo/tinyobjloader
  • Moderate speed and moderate memory consumption
    • Rungholt 7M triangle scene(260 MB) can be loaded in 4.7 secs and consumes 3.6 GB memory at the maximum on MacBook12 Core m5 1.2 GHz(single core use)
  • Unit tests using acutest thanks to @andystanton

Usage

Copy tinyobj_loader_c.h to your project.

/* define TINYOBJ_LOADER_C_IMPLEMENTATION for only *one* .c */
#define TINYOBJ_LOADER_C_IMPLEMENTATION
#include "tinyobj_loader_c.h"

...

See examples/viewer/ for more details.

tinyobjloader allocates memory. To replace the functions used for allocation, define TINYOBJ_MALLOC, TINYOBJ_REALLOC, TINYOBJ_CALLOC and TINYOBJ_FREE in the .c file you defined TINYOBJ_LOADER_C_IMPLEMENTATION in, before including tinyobj_loader_c.h. Define either all or none of them. They replace malloc, realloc, calloc and free respectively.

Example:

#define TINYOBJ_LOADER_C_IMPLEMENTATION
#define TINYOBJ_MALLOC my_malloc
#define TINYOBJ_REALLOC my_realloc
#define TINYOBJ_CALLOC my_calloc
#define TINYOBJ_FREE my_free
#include "tinyobj_loader_c.h"

Tests

The single header test library acutest is used to provide a test runner and assertion macros. There are two test suites: one for the API and one for the internal functions. Ultimately the internal tests should be removed, but are useful while the project is volatile.

The tests can be run from the project root using:

$ make test

This builds and executes a binary called tinyobj_tests in the test folder. There are some options to run specific tests that can be passed to the executable directly that are described on the acutest readme.

By default acutest forks for each test. To disable this for debugging purposes, you can pass the switch --no-exec to tinyobj_tests.

License

MIT license.

Third party licenses

TODO

  • Windows build?

More Repositories

1

tinygltf

Header only C++11 tiny glTF 2.0 library
C++
1,582
star
2

tinyexr

Tiny OpenEXR image loader/saver library
C++
620
star
3

tinyusdz

Tiny, dependency-free USDZ/USDA/USDC library written in C++14
C++
283
star
4

tinygltfloader

Header only C++ Tiny glTF loader.
C
247
star
5

tinydng

Header-only Tiny DNG/TIFF loader and writer in C++
C
126
star
6

MMDLoader

Simple MMD(PMD/VMD) loader in C++
C++
103
star
7

lucille

lucille global illumination renderer
C
89
star
8

tacotron-tts-cpp

Tacotron text to speech in C++(synthesize only)
C++
71
star
9

nanovg-nanort

NanoRT(SW ray tracer) backend for NanoVG
C
49
star
10

nanocanvas

NanoCanvas, portable JavaScript vector graphics engine.
C
43
star
11

tinymeshutils

Tiny Mesh utilities(e.g. compute half-edge data structure) in C++11
C++
35
star
12

docker-utils

Docker utilities
Shell
33
star
13

tinyvdbio

TinyVDBIO header-only C++ OpenVDB IO library
C++
32
star
14

eson

ESON, Exa-scale Storage Object Notation
Python
31
star
15

window-bootstrap

Cross-platform C++ Window/UI bootstrap
C
29
star
16

python-rdma-examples

Python RDMA sample scripts
Python
18
star
17

tinyshrot

TinySHRot, header-only C89 spherical harmonics rotation codes.
C
17
star
18

aobench

Automatically exported from code.google.com/p/aobench
HTML
16
star
19

aobench_cs

aobench in OpenGL compute shader!
C++
12
star
20

standalone-pocketfft

pocketfft in standalone C
C
12
star
21

tinyxpd

Dependency-free and header-only C++11 XGen XPD cache I/O library.
C++
11
star
22

USD-build-aarch64

USD build script for aarch64 target
C++
10
star
23

dynamic_bitset

Simple dynamic bitset template class
C++
10
star
24

oi-build

OpenIndiana Unified Build System
C
9
star
25

minioptix

Mini OptiX sample
C
8
star
26

libphm

PHM: Simple Portable Half float(fp16) Map fileformat in C/C++
C
7
star
27

tinylinalg

Tiny linear algebra and matrix math library
7
star
28

xgen-spline-to-cyhair

XGen Interactive Grooming spline to CyHair exporter
C++
7
star
29

node.rdma

RDMA transport layer for node.js
C++
6
star
30

tinylosslessjpeg

Tiny LosslessJPEG decoder in C++11
6
star
31

flutter_native_vulkan_experiment

Experiment to call Vulkan function from Flutter(dart ffi)
Dart
6
star
32

espnet-tts-streamlit

ESPNet TTS with Streamlit GUI
Python
6
star
33

tinycolorio

Header-only C++11 color IO library
Jupyter Notebook
6
star
34

OpenVDB-Android

Android port of OpenVDB
C++
5
star
35

staticstruct

Simple statically typed struct serialization/deserialization library in C++11
C++
5
star
36

raw-images

RAW photo images
5
star
37

espnet-tts

ESPNet TTS standalone execution
Python
4
star
38

mudalang

MUDA(MUltiple Data Accelerator) language
Haskell
4
star
39

solaris-infiniband-tools

Tcl
4
star
40

minijit

Minimal clang/LLVM JIT experiment
CMake
4
star
41

usda-to-usdc-experiment

USDA to USDC conversion experiment in C++
C++
4
star
42

cycles

cycles experimental
C++
3
star
43

tinyarchive

Tiny binary archive library.
C++
3
star
44

parallella-playground

Parallella Epiphany playground
C
3
star
45

aobench_oculus

aobench for Oculus Rift
C++
3
star
46

libjsonnet-cpp

Embed jsonnet to your C++11 application
C++
2
star
47

francine

Render backend
2
star
48

MUDA

MUDA is a MUltiple Data Accleleration language
Haskell
2
star
49

cmake-rpath-experiment

CMake + RPATH experiment
CMake
2
star
50

alembic-converters

Alembic file formart converters in C++11
C++
2
star
51

jsmuda

optimized code generator written in node.js
JavaScript
2
star
52

cyhair-combiner

Simple CyHair combiner tool
C++
2
star
53

LLL

Lucille Light transport Language
Haskell
2
star
54

llvm-project-mingw-build

llvm-project MinGW build script using llvm-mingw
Shell
2
star
55

libtorch_mobile_build

libtorch mobile build script
CMake
2
star
56

visemenet-docker

Run VisnemeNet inference in nvidia-docker container
Dockerfile
1
star
57

jch-vis

Visualize Jump Consistent Hash
1
star
58

klee-avx

avx support branch for klee
1
star
59

OSOgraph

Simple script visualizing OSO instructions using graphviz
Python
1
star
60

orelatex

δΏΊεΎ— latex η’°ε’ƒγƒ†γƒ³γƒ—γƒ¬γƒΌγƒˆ
1
star
61

aobench-ios

aobench-ios
C
1
star
62

oremake

oremake
JavaScript
1
star
63

nanostl

NanoSTL, small subset of C++ STL
1
star
64

aobench-fortran

Fortran 90 port of aobench
Fortran
1
star
65

aobench-osv

OSv port of aobench
C++
1
star
66

llvm-win-build

llvm-win-build
1
star
67

clapack-cmake-android-arm64

clapack cmake build for Android ARM64(NDK r20 or later)
C
1
star
68

orevfx

ore vfx tool build
1
star
69

orebuildenv

俺得ビルド環咃
Shell
1
star
70

naiad-tools

Naiad emp processing tools
C
1
star
71

lesh

continuos building tool
JavaScript
1
star