百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

micro-gl

> 编程语言
开源

仅包含头文件的 C++11 CPU 矢量图形。不需要标准库、FPU 也不用 GPU!

393 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

仅包含头文件的 C++11 CPU 矢量图形。不需要标准库、FPU 也不用 GPU!

micro{gl}

Fast, Super Slim, Embeddable, Headers only C++11 vector graphics library, that can run on any 32/64 bits computer without FPU or GPU. No standard library required.

Why micro-gl?

  • ZERO Dependencies: No std::, no external libraries.
  • Memory Freak Approved: Fixed compile-time allocations, zero heap fragmentation.
  • Arbitrary Precision: Native support for Q fixed-point math or any custom number type.
  • True Vector Tessellation: Unique trapezoid-decomposition pipeline.

check out our website at micro-gl.github.io/docs/microgl

Examples

A circle with Texture fill and Gradient stroke

…

A Rectangle, that samples a circle

cpp
using Canvas24= canvas>;
using number = float;
// using number = Q;

circle_sampler sampler{};

sampler.updatePoints({0.50,0.5}, 0.5, 0.10);
sampler.color_fill= {0, 0, 0, 255};
sampler.color_background= {255, 255, 255, 0};
sampler.color_stroke= {255, 255, 255, 255};

Canvas24 canvas(512, 512);

canvas.clear({255,0,255,255});
canvas.drawRect(
        sampler,
        0, 0, 300, 300);

A path tessellation with red color

…

Features

Language       

  • C++11, does not use any STL library and standard library.
  • headers only library
  • most functions are templates, which means you compile only what is used
  • compile-time polymorphism (no runtime virtual methods)
  • support for 32 bits and 64 bits
  • self contained and modular.

Graphics       

  • very modular design. if something does not exist, you can implement your own
  • over 10 blending modes implemented, you can wrote your own and supply as well
  • porter-duff alpha compositing
  • support for 2d sampler
  • can support any pixel coding you need, we implemented a lot out of the box
  • can render 3d geometries
  • we support 3d shaders
  • no need for GPU, it is all CPU
  • no need for FPU
  • support for any number system including Q numbers (fixed point), no need to use float points

Geometry       

  • fast implementation for common shapes (rect, rounded rectangles, circles, triangles)
  • batch triangles like GPU would
  • support polygons of any type convex, simple, and complex polygons
  • path fills (with even-odd or zero-one fill rule) in any precision
  • stroke fills
  • quadrilaterals
  • bezier patches
  • we providea dynamic array, but you can plug your own.

Installing micro{gl}

microgl is a headers only library, which gives the following install possibilities:

  1. Using cmake to invoke the install target, that will copy everything in your system via
bash
$ mkdir cmake-build-release
$ cd cmake-build-release
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ cmake --install .
  1. Copying the include/microgl to anywhere you want.
  2. Install via vcpkg.

Consuming micro{gl}

Following options are available:

  1. copy the project to a sub folder of your project. Inside your CMakeLists.txt add
cmake
add_subdirectory(/path/to/microgl)
target_link_libraries(your_app microgl)
  1. If you installed micro{gl} with option 1 (see above) at your system, you can instead
cmake
find_package(microgl CONFIG REQUIRED)
target_link_libraries(your_app microgl::microgl)
  1. If you have not installed, you can add in your app's CMakeLists.txt
cmake
target_include_directories(app path/to/microgl/folder/include/)
  1. If you manually copied the include/microgl to the default system include path,
    you can use cmake/Findmicrogl.cmake to automatically create the cmake targets
cmake
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/path/to/Findmicrogl/folder)
find_package(microgl REQUIRED)
target_link_libraries(your_app microgl::microgl)
  1. Just copy the include/microgl into a sub folder of your project and include the header
    files you need with relative path in your source files.
  2. If you have vcpkg installed, install the micro{gl} using the vcpkg install microgl command, and then you can use option 2 (see above) to find it. See issue micro-gl/micro-gl#33 for more details.

Running Examples

First make sure you have

  • SDL2 installed at your system.
  • cmake installed at your system.

There are two ways:

  1. Use your favourite IDE to load the root CMakeLists.txt file, and then it
    will pick up all of the targets, including the examples
  2. Using the command line:
bash
$ mkdir cmake-build-release
$ cd cmake-build-release
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ cmake --build . --target 
$ ../examples/bin/example_name
Author: Tomer Shalev, [email protected], all rights reserved (2021)

Thanks to JetBrains cLion Support Team for granting this project an OSS license of cLion

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++cppcpp11embeddedgraphics

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言