Code Monkey home page Code Monkey logo

cgltf's Introduction

cgltf

Single-file/stb-style C glTF loader

Usage

#include "cgltf.h"

void* buf; /* Pointer to glb or gltf file data */
size_t size; /* Size of the file data */

cgltf_options options = {0};
cgltf_data data;
cgltf_result result = cgltf_parse(&options, buf, size, &data);
if (result == cgltf_result_success)
{
	/* TODO make awesome stuff */
	cgltf_free(&data);
}

Support

cgltf supports this:

  • glTF 2.0
  • glb (binary files) and gltf (JSON files)
  • meshes (including accessors, buffer views, buffers)

cgltf does not yet support this:

  • animations
  • scenes and nodes
  • materials
  • any extensions (like Draco, for example)

Building

The easiest approach is to integrate the cgltf.h header file into your project. If you are unfamiliar with single-file C libraries (also known as stb-style libraries), this is how it goes:

  1. Include cgltf.h where you need the functionality.
  2. Have exactly one source file that defines CGLTF_IMPLEMENTATIONbefore including cgltf.h.
  3. Use the cgltf functions as described above.

For testing, there is a CMake file in test test/ folder.

Contributing

Everyone is welcome to contribute to the library. If you find any problems, you can submit them using GitHub's issue system. If you want to contribute code, you should fork the project and then send a pull request.

Dependencies

Basically none.

C headers being used:

#include <stdint.h>
#include <string.h>
#include <stdlib.h>

Note, this library integrates the JSMN JSON parser into its source.

Testing

There is a Python script in the test/ folder that retrieves the glTF sample files from the glTF-Sample-Models repository and runs the library against all gltf and glb files in there.

cgltf's People

Contributors

jkuhlmann avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.