SDL_gpu: batched 2D graphics on top of SDL
A library for high-performance, modern 2D graphics with SDL written in C.
At a glance
- What is it?
- SDL_gpu is a C library that draws hardware accelerated 2D scenes through OpenGL while staying close to the SDL 1.2 API shape. It wins on batching, shaders and free blend state control, and it asks you to give up the SDL_Renderer object model.
- Who is it for?
- SDL_gpu fits C projects that already use SDL and want batched 2D drawing, shader control and a switch to explicit OpenGL calls without a full engine rewrite. It does not fit teams that want to stay inside the SDL_Renderer API, or projects that need an actively versioned library, since the last push was on 2026-05-26 and the newest tagged release is v0.12.0 from 2022.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 150 days ago.
- What is it written in?
- Mainly C, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.
Editorial analysis
SDL_gpu collects draw commands into batches instead of issuing one per sprite
The central claim of the library is throughput per frame rather than API novelty. According to the project description, SDL_gpu automatically collects and submits batches, so a scene with many sprites does not turn into a separate draw command for every one of them, and redundant state changes are folded together rather than resent. That is the specific problem it addresses: games and tools with large numbers of small textured quads spend their time in driver overhead, and a batching layer is the usual answer.
Around that core, the library offers a shader API, full blend state control, and arbitrary geometry rendering as triangles. Blend state in particular is exposed as a first class concept rather than a texture property, which is the part that distinguishes it from a thin wrapper over SDL_Render. The library also keeps a style familiar to SDL 1.2 users, and it works against either SDL 1.2 or SDL 2.0, so a codebase that predates the SDL_Renderer rework can adopt it without first migrating to the newer object model.
The trade-off is that you are choosing a rendering abstraction over SDL's own. The API surface is a different set of types, and the call names differ, so the transition is a port rather than a configuration change.
GPU_Target and GPU_Image stand in for SDL_Renderer and SDL_Texture
The project describes itself as able to replace the SDL_Render subsystem of SDL2, and the mapping it publishes is a good summary of the design. A render destination, which the documentation calls a render destination such as the screen, becomes a GPU_Target rather than an SDL_Renderer. A render source, a texture container in the project's wording, becomes a GPU_Image rather than an SDL_Texture.
The conversion list in the project documentation pairs the two APIs function by function. Creation and lifetime calls map cleanly: SDL_CreateWindow() becomes either GPU_SetInitWindow() or GPU_Init(), and SDL_DestroyRenderer() becomes GPU_FreeTarget(), with the explicit warning not to free the screen target yourself. Drawing maps to GPU_Blit() or GPU_BlitRect() where SDL_RenderCopy() was used, and the present call becomes GPU_Flip(). Colour and alpha handling that was split across SDL_SetTextureColorMod() and SDL_SetTextureAlphaMod() collapses into GPU_SetRGBA() or GPU_SetColor().
One difference will bite during a port. SDL functions take a rectangular region expressed as an SDL_Rect, while SDL_gpu uses floating point coordinates for subpixel precision, so some calls need a GPU_Rect instead. Code that assumed integer pixel boundaries has to be revisited rather than mechanically translated.
Building on Linux with CMake and linking against SDL2_gpu
The project points at GitHub as the home of the source, and the checkout step is a plain clone. SDL_gpu uses CMake to coordinate the library build, and CMake is described as available both as a GUI program and on the command line. On Linux and UNIX systems the documented sequence runs in the base directory of the checkout.
git clone https://github.com/grimfang4/sdl-gpu.git sdl-gpuThe build itself is three commands, and the third installs system wide.
cmake -G "Unix Makefiles"
make
sudo make installIf the default installation directory is wrong for your layout, the same generator is reused with an explicit prefix, which is the one knob the project documents for install location.
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usrWindows builders are pointed at cmake-gui, and the project itself comments that cmake-gui is messy, so expect to configure options through a GUI. After the build, the include for SDL_gpu.h is added to your sources and you link to SDL2_gpu, distributed as libSDL2_gpu.a, or to SDL_gpu if you are still on the old SDL 1.2. The runtime dependencies are SDL 1.2 or SDL 2.0 from www.libsdl.org plus a rendering backend, and the backends currently implemented are OpenGL 1.1, 2.0, 3.0 and 4.0, along with OpenGL ES 1.1, 2.0 and 3.0.
Explicit OpenGL calls and triangle geometry sit next to the 2D layer
SDL_gpu does not lock you into a closed 2D world. The feature list states that the library can be integrated with explicit OpenGL calls, so a scene can mix 2D and 3D in one frame without switching backends. Arbitrary geometry rendering as triangles covers the cases where a sprite quad is the wrong primitive, and that matters for tools that draw vector-ish shapes rather than tiles.
There is also a set of built-in primitive shapes: points, lines, triangles, rectangles, ellipses and polygons, and arcs. Arcs are worth noting because they are not a primitive in most immediate mode 2D libraries, and they map to specific calls: SDL_RenderDrawPoint() becomes GPU_Pixel(), SDL_RenderDrawLine() becomes GPU_Line(), SDL_RenderDrawRect() becomes GPU_Rectangle() and SDL_RenderFillRect() becomes GPU_RectangleFilled(). Blend modes are separated into a shape blend mode set through GPU_SetShapeBlendMode() and an image blend mode set through GPU_SetBlendMode().
The library reads BMP, TGA and PNG files through stb-image, so image loading does not require pulling in SDL_image. Reading pixels back from the GPU is possible too, with SDL_RenderReadPixels() replaced by GPU_CopySurfaceFromTarget() or GPU_CopySurfaceFromImage().
Anchored rotation and scaling make corner coordinates predictable
A small design decision in the library is worth its own note because it changes how you reason about drawing code. The project states that rotation and scaling happen about the center of images, which makes the resulting corner coordinates more obvious to reason about, and that this is adjustable through anchor settings.
That sounds minor, and it is, but the alternative is a class of bug that only shows up visually. A renderer that scales around the top left corner produces offsets that depend on the sprite size, so a UI element that is correct at one resolution is wrong at another. With a center anchor the offset is symmetric, and with anchor settings you can still move the pivot when a layout needs it.
The SDL conversion list reflects the same intent. Where SDL offers SDL_RenderCopyEx() for rotated and scaled copies, SDL_gpu splits the operation into distinct calls: GPU_BlitRotate(), GPU_BlitScale() and GPU_BlitTransform(). Picking the narrowest call for the effect you want keeps the state changes the batcher sees to a minimum, which is the point of the automatic batching in the first place.
The repository layout shows a library with demos, tests and Android support
The top level of the repository is larger than a single header library would be. Directories for demos, tests, common code, headers, sources, tools and scripts sit alongside a CMakeLists.txt, an Android.mk file and an AndroidCMake directory, plus configuration files for Appveyor and Travis CI, a Doxyfile pair, and a version.txt. Continuous integration is set up for Windows through Appveyor and for Linux and MacOS through Travis CI, and the project points to an Appveyor page for prebuilt Windows library files.
Documentation is generated with Doxygen, and a pre-generated version is published on a Github.io page for the project. A separate README-ios.txt suggests some attention to mobile targets, and the Android build files point in the same direction, though the main README does not describe an iOS or Android setup procedure in detail.
What the layout does not include is a dedicated changelog, a versioning policy, or a compatibility table for SDL releases beyond the statement that both SDL 1.2 and SDL 2.0 are supported. If you are pinning versions across a team, that gap is worth planning for.
Recent commits continue, but the published releases have gone quiet
The repository is not archived, and the last push was on 2026-05-26, so source changes are still landing. The release history tells a different story. The newest tagged release is v0.12.0 from 2022-06-24, and the two other published artifacts are far older: latest-linux-gcc, an automated Linux GCC build, dated 2017-07-18, and latest, described as a latest unstable debug build, dated 2015-10-04.
Those artifact names are the kind that leak into build scripts, and a file called latest that has not moved since 2015 is a hazard. Anyone pulling a prebuilt binary by that name should check what they actually get. The current source tree is a different matter: with pushes recorded in May 2026, a checkout of master is more current than anything published as a release, which shifts the burden of stability onto your own build.
The project also does not document a rollback procedure, a supported release matrix, or a policy for how long old branches keep working. The bug reporting route is a repository issue, and the maintenance route is a pull request, so upstream is reachable, but nothing in the documentation tells you what a safe upgrade looks like.
Editorial conclusion
SDL_gpu fits C projects that already use SDL and want batched 2D drawing, shader control and a switch to explicit OpenGL calls without a full engine rewrite. It does not fit teams that want to stay inside the SDL_Renderer API, or projects that need an actively versioned library, since the last push was on 2026-05-26 and the newest tagged release is v0.12.0 from 2022. Before adopting it, confirm that your build system can consume the CMake target, that the OpenGL version on your target machines is one of the listed backends, and that your own code can live with float coordinates and the GPU_Target ownership rules, since the project does not document a rollback path or a compatibility matrix for SDL versions beyond 1.2 and 2.0.
Frequently asked questions
How do I build and install SDL_gpu on Linux?
Clone the repository, then run CMake with the Unix Makefiles generator, run make, and run sudo make install. The project also documents an explicit install location through CMAKE_INSTALL_PREFIX, for example cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr.
Can SDL_gpu replace the SDL_Render subsystem of SDL2?
Yes. The project documents the swap: a GPU_Target stands in for an SDL_Renderer and a GPU_Image for an SDL_Texture, with GPU_Blit() replacing SDL_RenderCopy() and GPU_Flip() replacing SDL_RenderPresent(). One warning applies, do not free the screen target yourself.
Which SDL versions and rendering backends does SDL_gpu support?
The project states that SDL_gpu is compatible with either SDL 1.2 or SDL 2.0, and you link to SDL2_gpu (libSDL2_gpu.a) or to SDL_gpu when using the old SDL 1.2. The implemented rendering backends are OpenGL 1.1, 2.0, 3.0 and 4.0, and OpenGL ES 1.1, 2.0 and 3.0.
Does SDL_gpu support shaders and custom blend modes?
The feature list includes a shader API and full blend state control. Shape and image blend modes are set separately through GPU_SetShapeBlendMode() and GPU_SetBlendMode(), and colour and alpha adjustments go through GPU_SetRGBA() or GPU_SetColor().
How do I load PNG files and read pixels back from SDL_gpu?
The library loads BMP, TGA and PNG files via stb-image, so no separate image loader is required. Reading pixels back uses GPU_CopySurfaceFromTarget() or GPU_CopySurfaceFromImage() in place of SDL_RenderReadPixels().
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/grimfang4-sdl-gpu)Was this useful?