{"id":31758509,"url":"https://github.com/nickscha/cdlod","last_synced_at":"2025-10-09T20:32:45.424Z","repository":{"id":315252090,"uuid":"1058737861","full_name":"nickscha/cdlod","owner":"nickscha","description":"C89, single header, nostdlib continuous distance-dependent level of detail","archived":false,"fork":false,"pushed_at":"2025-09-17T13:43:52.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-17T15:32:13.533Z","etag":null,"topics":["c89","cdlod","continuous-distance-dependent","level-of-detail","nostdlib","single-header"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nickscha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-17T13:37:35.000Z","updated_at":"2025-09-17T13:43:56.000Z","dependencies_parsed_at":"2025-09-17T15:32:16.671Z","dependency_job_id":"60545640-577a-4738-95f9-22712b0a34d1","html_url":"https://github.com/nickscha/cdlod","commit_stats":null,"previous_names":["nickscha/cdlod"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nickscha/cdlod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickscha%2Fcdlod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickscha%2Fcdlod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickscha%2Fcdlod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickscha%2Fcdlod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickscha","download_url":"https://codeload.github.com/nickscha/cdlod/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickscha%2Fcdlod/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002000,"owners_count":26083258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c89","cdlod","continuous-distance-dependent","level-of-detail","nostdlib","single-header"],"created_at":"2025-10-09T20:30:24.737Z","updated_at":"2025-10-09T20:32:45.414Z","avatar_url":"https://github.com/nickscha.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cdlod\nA C89 standard compliant, single header, nostdlib (no C Standard Library) Continuous Distance-Dependent Level of Detail (CDLOD).\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/nickscha/cdlod\"\u003e\u003cimg src=\"assets/cdlod.png\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nFor more information please look at the \"cdlod.h\" file or take a look at the \"examples\" or \"tests\" folder.\n\n\u003e [!WARNING]\n\u003e THIS PROJECT IS A WORK IN PROGRESS! ANYTHING CAN CHANGE AT ANY MOMENT WITHOUT ANY NOTICE! USE THIS PROJECT AT YOUR OWN RISK!\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/nickscha/cdlod/releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/nickscha/cdlod?style=flat-square\u0026color=blue\" alt=\"Latest Release\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/nickscha/cdlod/releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/downloads/nickscha/cdlod/total?style=flat-square\u0026color=brightgreen\" alt=\"Downloads\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square\" alt=\"License\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Standard-C89-orange?style=flat-square\" alt=\"C Standard\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/nolib-nostdlib-lightgrey?style=flat-square\" alt=\"nostdlib\"\u003e\n\u003c/p\u003e\n\n## **Features**\n- **C89 compliant** — portable and legacy-friendly  \n- **Single-header API** — just include `cdlod.h`  \n- **nostdlib** — no dependency on the C Standard Library  \n- **Minimal binary size** — optimized for small executables  \n- **Cross-platform** — Windows, Linux, MacOs \n- **Strict compilation** — built with aggressive warnings \u0026 safety checks  \n\n## Quick Start\n\nDownload or clone cdlod.h and include it in your project.\n\n```C\n#include \"cdlod.h\" /* Continuous Distance-Dependent Level of Detail */\n\n/* (1) Define a height function for a given x and z coordinate */\nfloat custom_height_function(float x, float z)\n{\n  (void) x;\n  (void) y;\n\n  /* Flat Plane (replace with perlin/simplex noise or other height algorithms) */\n  return 0.0f;\n}\n\nint main() {\n    /* (2) Define a memory buffer for the gneerated cdlod vertice and indices */\n    #define VERTICES_CAPACITY 200000\n    #define INDICES_CAPACITY 200000\n    float vertices[VERTICES_CAPACITY];\n    int indices[INDICES_CAPACITY];\n    int vertices_count = 0;\n    int indices_count  = 0;\n\n    /* (3) Define when different lod ranges should be applied (distance to camera) */\n    /*     This has to be sorted in an ascending order                             */\n    /*     First = Highest Level of Detail                                         */\n    float lod_ranges[] = {0.0f, 50.0f, 100.0f, 200.0f, 400.0f};\n    float patch_size   = 64.0f;\n    int grid_radius    = 1;\n    float skirt_depth  = 5.0f;\n\n    /* (4) Define an eye/camera position from which the CDLOD grid should be generated */\n    float camera_position_x =  0.0f;\n    float camera_position_y = 10.0f;\n    float camera_position_z =  0.0f;\n\n    float camera_front_x    =  0.0f;\n    float camera_front_z    = -1.0f; /* For example -1.0f in right-hand-layout (e.g. OpenGL) is front facing */\n\n    /* (5) Generate the CDLOD vertices and indices */\n    cdlod(\n        vertices, VERTICES_CAPACITY, \u0026vertices_count,            /* Vertices data                                   */\n        indices, INDICES_CAPACITY, \u0026indices_count,               /* Indices data                                    */\n        camera_position_x, camera_position_y, camera_position_z, /* Camera position                                 */\n        camera_front_x, camera_front_z,                          /* Camera front facing vector                      */\n        custom_height_function,                                  /* Y-Heightmap function                            */\n        patch_size,                                              /* How large is each patch                         */\n        5, lod_ranges,                                           /* Number of lod levels and the ranges             */\n        grid_radius,                                             /* How big is the grid (1=3x3, 3=5x5 patches, ...) */\n        skirt_depth\n    );\n \n    return 0;\n}\n```\n### Define max. lod levels\n\nBy default maximum 8 lod levels are supported.\nIf you want to increase/decrease that amount you can either use the compile flag `-DCDLOD_MAX_LODS=16` or define it before including the header.\n\n```C\n#define CDLOD_MAX_LODS 16\n#include \"cdlod.h\"\n```\n\n## Benchmark Results\n\nThe `cdlod_test.c` measures cpu cycle counts and time in milliseconds for the cdlod function.\n\nThe following settings were used:\n- 5 LOD ranges\n- 64.0f per patch size\n- 9 grid radius (equals 19x19 patches)\n\nThis is captured on a `Intel Core i7-7700HQ CPU @ 2.14 GHz` with a single core.\n\nIt averages around **0.03 milliseconds** which makes this algorithm suitable and render buget friendly for software rasterizers.\n\n```txt\ncdlod_test.c:119 [perf]\ncdlod_test.c:119 [perf] +-------------------------------------------------------+-------------------------------------------------------+\ncdlod_test.c:119 [perf] | cylces                                                | time_ms                                               |\ncdlod_test.c:119 [perf] +-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+\ncdlod_test.c:119 [perf] |         min |         max |         avg |         sum |         min |         max |         avg |         sum |\ncdlod_test.c:119 [perf] +-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+\ncdlod_test.c:119 [perf] |       91712 |      508728 |      106040 |  1060407695 |      0.0326 |      0.1812 |      0.0378 |    378.2178 |  10000 x cdlod\ncdlod_test.c:119 [perf] +-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+\n```\n\nThe build script used for this can be found in `tests/build.bat`\n\n```sh\ncc -s -O2 -std=c89 -pedantic -Wall -Wextra -Werror -Wvla -Wconversion -Wdouble-promotion -Wsign-conversion -Wmissing-field-initializers -Wuninitialized -Winit-self -Wunused -Wunused-macros -Wunused-local-typedefs -o cdlod_test.exe cdlod_test.c\n```\n\n## Run Example: nostdlib, freestsanding\n\nIn this repo you will find the \"examples/cdlod_win32_nostdlib.c\" with the corresponding \"build.bat\" file which\ncreates an executable only linked to \"kernel32\" and is not using the C standard library and executes the program afterwards.\n\n## \"nostdlib\" Motivation \u0026 Purpose\n\nnostdlib is a lightweight, minimalistic approach to C development that removes dependencies on the standard library. The motivation behind this project is to provide developers with greater control over their code by eliminating unnecessary overhead, reducing binary size, and enabling deployment in resource-constrained environments.\n\nMany modern development environments rely heavily on the standard library, which, while convenient, introduces unnecessary bloat, security risks, and unpredictable dependencies. nostdlib aims to give developers fine-grained control over memory management, execution flow, and system calls by working directly with the underlying platform.\n\n### Benefits\n\n#### Minimal overhead\nBy removing the standard library, nostdlib significantly reduces runtime overhead, allowing for faster execution and smaller binary sizes.\n\n#### Increased security\nStandard libraries often include unnecessary functions that increase the attack surface of an application. nostdlib mitigates security risks by removing unused and potentially vulnerable components.\n\n#### Reduced binary size\nWithout linking to the standard library, binaries are smaller, making them ideal for embedded systems, bootloaders, and operating systems where storage is limited.\n\n#### Enhanced performance\nDirect control over system calls and memory management leads to performance gains by eliminating abstraction layers imposed by standard libraries.\n\n#### Better portability\nBy relying only on fundamental system interfaces, nostdlib allows for easier porting across different platforms without worrying about standard library availability.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickscha%2Fcdlod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickscha%2Fcdlod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickscha%2Fcdlod/lists"}