-
-
Notifications
You must be signed in to change notification settings - Fork 27
02 Quick Start
Inan Evin edited this page Oct 12, 2024
·
11 revisions
Below is a bare-minimum implementation steps for drawing with LinaVG. As said in the home page, it's assumed that your application already has a graphics rendering backend setup and running, of course along with a window with a valid context. Check Custom Backends for more information.
// Include LinaVG
#include "LinaVG.hpp"
LinaVG::Drawer lvgDrawer;
// Bind draw callback.
lvgDrawer.GetCallbacks().draw = std::bind(&GLBackend::DrawDefault, m_renderingBackend, std::placeholders::_1);
// Your application loop
while (m_applicationRunning)
{
// Setup style, give a gradient color from red to blue.
StyleOptions style;
style.isFilled = true;
style.color.start = Vec4(1, 0, 0, 1);
style.color.end = Vec4(0, 0, 1, 1);
// Draw a 200x200 rectangle starting from 300, 300.
const Vec2 min = Vec2(300, 300);
const Vec2 max = Vec2(500, 500);
lvgDrawer.DrawRect(min, max, style);
// Flush buffers, this will call your callback functions.
lvgDrawer.FlushBuffers();
// Shrink buffers.
lvgDrawer.ResetFrame();
}
And that's basically it! Now you should have this on your screen, easy peasy.
There are a lot more to LinaVG in regards to usage, configuration, other shapes/lines/texts and styling, as well as basic threading support. Check out the rest of the Wiki or the example application to learn about them all.