Skip to content
/ draw Public

C++11 cross-platform GPU-accelerated pixel-space 2D drawing library

License

Notifications You must be signed in to change notification settings

vsergey3d/draw

Repository files navigation

draw  Build Status Build status codecov.io

C++11 cross-platform GPU-accelerated pixel-space 2D drawing library.

API documentation | Contributing | FAQ

Features

  • 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)

How to use

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.

Licensing

The library is licensed under the Simplified BSD License.

Example

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();

About

C++11 cross-platform GPU-accelerated pixel-space 2D drawing library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published