02 Quick Start - inanevin/LinaVG GitHub Wiki

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.


// Include LinaVG
#include "LinaVG.hpp"

// Configure display properties based on your application window
LinaVG::Config.displayPosX   = 0;
LinaVG::Config.displayPosY   = 0;
LinaVG::Config.displayWidth  = myDisplayWidth;
LinaVG::Config.displayHeight = myDisplayHeight;

// Initialize LinaVG
LinaVG::Initialize();

// Your application loop
while (m_applicationRunning)
{

    // Let LinaVG know that we are starting to render.
    LinaVG::StartFrame();

    // 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);
    LinaVG::DrawRect(min, max, style);

    // Finally, flush all the buffers and render to screen.
    LinaVG::Render();

    // Let LinaVG know that we are finishing this frame
    LinaVG::EndFrame();
}

// Terminate LinaVG before exiting your application.
LinaVG::Terminate();

And that's basically it! Now you should have this on your screen, easy peasy.

1

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.