Pntr
Header-only CPU graphics library for C, with a focus on ease of use.
Install / Use
/learn @RobLoach/PntrREADME
pntr <a href="https://github.com/robloach/pntr"><img src="examples/resources/logo-55x55.png" align=left width=55 height=55 /></a>
Header-only CPU graphics library for C99 or C++, with a focus on ease-of-use.
Usage
#define PNTR_PIXELFORMAT_RGBA
#define PNTR_IMPLEMENTATION
#include "pntr.h"
int main() {
pntr_image* image = pntr_new_image(200, 200);
pntr_draw_circle_fill(image, 100, 100, 80, PNTR_RED);
pntr_save_image(image, "output.png");
pntr_unload_image(image);
return 0;
}
Examples
Features
- Draw rectangles, circles, ellipses, triangles, lines, arcs, etc
- RGBA or ARGB pixel bit order
- Clipping
- Load and save images (PNG)
- Draw sprites with scaling and rotation
- Alpha-blending, alpha masks, invert, brightness, etc
- Font rendering (TTF, BMF, TTY)
- UTF-8
- Documentation
Integrations
| Name | Description | | ---- | ----------- | | pntr_app | Application wrapper for running the same pntr code in raylib, SDL, Web, libretro, or in a CLI | | pntr_assetsys | Load pntr assets from .zip files with assetsys.h | | pntr_physfs | Load pntr assets from .zip files with PhysicsFS | | pntr_nuklear | Nuklear immediate-mode graphical user interface for pntr | | pntr_aseprite | Use Aseprite animated sprites in pntr | | pntr_tiled | Display Tiled 2D level editor maps in pntr | | pntr_portablegl | Use the OpenGL-esque software rendering library, PortableGL, in pntr | | pntr_doom | Play DOOM via PureDOOM rendered through pntr | | pntr_pixelfont | Additional pixel fonts outside of the default | | zig_pntr | Zig wrapper for pntr |
API
In order to use pntr, you must define PNTR_IMPLEMENTATION prior in one of your .c files prior to including pntr.h.
#define PNTR_IMPLEMENTATION
#include "pntr.h"
Configuration
You can modify how pntr functions based on the following defines:
| Define | Description |
| --- | --- |
| PNTR_IMPLEMENTATION | Define this in one of your .c or .cpp files before including pntr.h |
| PNTR_PIXELFORMAT_RGBA | Use the RGBA format |
| PNTR_PIXELFORMAT_ARGB | Use the ARGB pixel format |
| PNTR_ENABLE_DEFAULT_FONT | Enables the default 8x8 pixel font |
| PNTR_ENABLE_MATH | Enables use of C's standard math.h linked library, rather than using the built in math functions |
| PNTR_ENABLE_TTF | Enables support for loading TrueType fonts |
| PNTR_ENABLE_UTF8 | Enables UTF-8 support for font loading and text rendering |
| PNTR_LOAD_FILE | Callback to use when asked to load a file in pntr_load_file(). By default, will use stdio.h. |
| PNTR_LOAD_IMAGE_FROM_MEMORY | Callback to use when loading an image from memory via pntr_load_image_from_memory(). By default, will use stb_image |
| PNTR_SAVE_FILE | Callback to use when saving a file via pntr_save_file(). By default, uses stdio.h |
| PNTR_SAVE_IMAGE_TO_MEMORY | Callback to use when saving an image to memory via pntr_save_image_to_memory(). By default, will use stb_image_write |
| PNTR_NO_ALPHABLEND | Skips alpha blending when drawing pixels |
| PNTR_NO_STDIO | Will disable the standard file loading/saving calls for PNTR_LOAD_FILE and PNTR_SAVE_FILE |
| PNTR_NO_SAVE_IMAGE | Disables the default behavior of image saving |
| PNTR_NO_LOAD_IMAGE | Disables the default behavior of image loading |
| PNTR_NO_CUTE_PNG_IMPLEMENTATION | Skips defining CUTE_PNG_IMPLEMENTATION. Useful if you're using cute_png elsewhere |
| PNTR_NO_STB_TRUETYPE_IMPLEMENTATION | Skips defining STB_TRUETYPE_IMPLEMENTATION. Useful if you're using stb_truetype elsewhere |
| PNTR_NO_STB_IMAGE_WRITE_IMPLEMENTATION | Skips defining STB_IMAGE_WRITE_IMPLEMENTATION. useful if you're using stb_image_write elsewhere |
| PNTR_NO_STB_IMAGE_IMPLEMENTATION | Skips defining STB_IMAGE_IMPLEMENTATION. useful if you're using stb_image_write elsewhere |
Functions
pntr_image* pntr_new_image(int width, int height);
pntr_image* pntr_gen_image_color(int width, int height, pntr_color color);
pntr_image* pntr_image_copy(pntr_image* image);
pntr_image* pntr_image_from_image(pntr_image* image, int x, int y, int width, int height);
pntr_image* pntr_image_subimage(pntr_image* image, int x, int y, int width, int height);
pntr_rectangle pntr_image_get_clip(pntr_image* image);
void pntr_image_set_clip(pntr_image* image, int x, int y, int width, int height);
void pntr_image_reset_clip(pntr_image* image);
void pntr_unload_image(pntr_image* image);
void pntr_clear_background(pntr_image* image, pntr_color color);
void pntr_draw_point(pntr_image* dst, int x, int y, pntr_color color);
void pntr_draw_point_vec(pntr_image* dst, pntr_vector* point, pntr_color color);
void pntr_draw_points(pntr_image* dst, pntr_vector* points, int pointsCount, pntr_color color);
void pntr_draw_line(pntr_image* dst, int startPosX, int startPosY, int endPosX, int endPosY, pntr_color color);
void pntr_draw_line_horizontal(pntr_image* dst, int posX, int posY, int width, pntr_color color);
void pntr_draw_line_horizontal_thick(pntr_image* dst, int posX, int posY, int width, int thickness, pntr_color color);
void pntr_draw_line_thick(pntr_image* dst, int startPosX, int startPosY, int endPosX, int endPosY, int thickness, pntr_color color);
void pntr_draw_line_thick_vec(pntr_image* dst, pntr_vector start, pntr_vector end, int thickness, pntr_color color);
void pntr_draw_line_vec(pntr_image* dst, pntr_vector start, pntr_vector end, pntr_color color);
void pntr_draw_line_vertical(pntr_image* dst, int posX, int posY, int height, pntr_color color);
void pntr_draw_line_vertical_thick(pntr_image* dst, int posX, int posY, int height, int thickness, pntr_color color);
void pntr_draw_rectangle(pntr_image* dst, int posX, int posY, int width, int height, pntr_color color);
void pntr_draw_rectangle_fill(pntr_image* dst, int posX, int posY, int width, int height, pntr_color color);
void pntr_draw_rectangle_fill_rec(pntr_image* dst, pntr_rectangle rect, pntr_color color);
void pntr_draw_rectangle_gradient(pntr_image* dst, int x, int y, int width, int height, pntr_color topLeft, pntr_color topRight, pntr_color bottomLeft, pntr_color bottomRight);
void pntr_draw_rectangle_gradient_rec(pntr_image* dst, pntr_rectangle rect, pntr_color topLeft, pntr_color topRight, pntr_color bottomLeft, pntr_color bottomRight);
void pntr_draw_rectangle_rec(pntr_image* dst, pntr_rectangle rec, pntr_color color);
void pntr_draw_rectangle_thick(pntr_image* dst, int posX, int posY, int width, int height, int thickness, pntr_color color);
void pntr_draw_rectangle_thick_rec(pntr_image* dst, pntr_rectangle rect, int thickness, pntr_color color);
void pntr_draw_triangle(pntr_image* dst, int x1, int y1, int x2, int y2, int x3, int y3, pntr_color color);
void pntr_draw_triangle_fill(pntr_image* dst, int x1, int y1, int x2, int y2, int x3, int y3, pntr_color color);
void pntr_draw_triangle_fill_vec(pntr_image* dst, pntr_vector point1, pntr_vector point2, pntr_vector point3, pntr_color color);
void pntr_draw_triangle_thick(pntr_image* dst, int x1, int y1, int x2, int y2, int x3, int y3, int thickness, pntr_color color);
void pntr_draw_triangle_thick_vec(pntr_image* dst, pntr_vector point1, pntr_vector point2, pntr_vector point3, int thickness, pntr_color color);
void pntr_draw_triangle_vec(pntr_image* dst, pntr_vector point1, pntr_vector point2, pntr_vector point3, pntr_color color);
void pntr_draw_ellipse(pntr_image* dst, int centerX, int centerY, int radiusX, int radiusY, pntr_color color);
void pntr_draw_ellipse_fill(pntr_image* dst, int centerX, int centerY, int radiusX, int radiusY, pntr_color color);
void pntr_draw_ellipse_thick(pntr_image* dst, int centerX, int centerY, int radiusX, int radiusY, int thickness, pntr_color color);
void pntr_draw_circle(pntr_image* dst, int centerX, int centerY, int radius, pntr_color color);
void pntr_draw_circle_fill(pntr_image* dst, int centerX, int centerY, int radius, pntr_color color);
void pntr_draw_circle_thick(pntr_image* dst, int centerX, int centerY, int radius, int thickness, pntr_color color);
void pntr_draw_polygon(pntr_image* dst, pntr_vector* points, int numPoints, pntr_color color);
void pntr_draw_polygon_fill(pntr_image* dst, pntr_vector* points, int numPoints, pntr_color color);
void pntr_draw_polygon_thick(pntr_image* dst, pntr_vector* points, int numPoints, int thickness, pntr_color color);
void pntr_draw_polyline(pntr_image* dst, pntr_vector* points, int numPoints, pntr_color color);
void pntr_draw_polyline_thick(pntr_image* dst, pntr_vector* points, int numPoints,
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。



