C++11 cross-platform GPU-accelerated pixel-space 2D drawing library.
API documentation | Contributing | FAQ
- cross-platform: Linux, MaxOS, Windows, MinGW
- very fast (using OpenGL instancing under the hood)
- integer pixel space (resize agnostic)
- indexed primitives, images, atlases, transparency, z-order
- text rendering (real-time font atlas generation from FreeType file)
The project is using CMake as build solution.
You can build the library using one of the modern compiler: Clang, GCC, MSVC.
Some dependencies (GLEW, AGG, FreeType) are required. You can find it in deps
folder and build by yourself.
See draw-wxWidgets repo as example of using the library with wxWidgets.
The library is licensed under the Simplified BSD License.
using namespace draw;
class MyContext final : public Context {
public:
/*...*/
virtual void setCurrent() final { mySetCurrent(); }
};
auto renderer = makeRenderer(std::move(make_unique<MyContext>(/*...*/)));
auto image = renderer->makeImage({32, 32}, Image::Format::RGBA, true);
image->upload(dataSpan);
auto rect = renderer->makeRect();
rect->position({10, 20});
rect->size({30, 30});
rect->color(0xCC0000FF);
rect->image(image);
rect->visibility(true);
auto text = renderer->makeText();
text->position({10, 60});
text->font(renderer->makeFont("cour.ttf", 10));
text->text(L"ABCDEFG");
text->visibility(true);
renderer->resize(myScreenSize);
renderer->draw(0xEEEEEEFF);
mySwapBuffers();