03 Configuration - inanevin/LinaVG GitHub Wiki

LinaVG provides a variety of configuration variables to tweak the rendering logic. All these can be found under the Configuration struct in Core/Common.hpp file. Some of them are crucially important such as Display Config or Framebuffer Scale and this document goes over a few of those.

Current frame buffer scale is used to multiply the size of internal shapes, such as AA thickness, extruded lines etc. This scale factor corresponds to operating system's scaling factor on e.g. high-dpi screens.

/// <summary>
/// Set this to your application's framebuffer scale, e.g. OS scaling factor for high-dpi screens.
/// </summary>
float globalFramebufferScale = 1.0f;

You should update this variable whenever your frame buffer scale changes, most window management APIs, like GLFW, provide callbacks to receive this info. Also, all styling options have their own local version of framebufferScale, in case you are drawing multiple windows on multiple monitors.

AA

You can set AA width by using:

/// <summary>
/// Size multiplier for AA vertices.
/// </summary>
float globalAAMultiplier = 1.0f;

Also, all styling options have their own local version of aaMultiplier, in case you are drawing multiple windows on multiple monitors and want to do local changes.

Unicode Fonts

Normally unicode encoding for iterating chars in a given text is disabled. If your loaded font has non-ASCII characters, enable unicode encoding to support them. More information regarding this is given in LoadFont method.

/// <summary>
/// If true, texts will be drawn by interpreting each character w/ 32 bit encoding.
/// Set this to true if you want to draw unicode characters.
/// Also you need to load the glyph ranges using customRanges in LoadFont.
/// Do not forget to send your text with in utf8-format, e.g. c++11 > u8"my string"
/// </summary>
bool useUnicodeEncoding = false;

Logging

LinaVG uses two callback functions (std::function) to pass information about internal errors and info logs. Set these to your custom functions or lambdas to receive them.

/// <summary>
/// Set this to your own function to receive error callbacks from LinaVG.
/// </summary>
std::function<void(const LINAVG_STRING&)> errorCallback;

/// <summary>
/// Set this to your own function to receive log callbacks from LinaVG.
/// </summary>
std::function<void(const LINAVG_STRING&)> logCallback;

Standard Library Functionality

LinaVG uses some standard library functions for internal logic. All these functions are exposed to custom macros which you can define in order to use your own structures instead of std namespace. Defining them will only work if you are building LinaVG along with your application. Use these macros before including "LinaVG.hpp" to override them.

Some small functionality, such as error/log callbacks use std::function and are not exposed. Also, utf8-encoding for non-ASCII unicode strings use std::wstring_convert and std::u32string.

#define LINAVG_STRING MyOwnStringClass

Your own string class needs to support:

  • assignment and append (+) operators
  • c_str() function to return const char*
  • compare() function that returns 0 if comparison checks, 1 if not.
#define LINAVG_MAP MyUnorderedMap

Your own map class needs to support:

  • [] access by key
  • const & non-const iterators
#define LINAVG_MEMCPY MyOwnMemCpyFunction

Needs to be same signature as std::memcpy

#define LINAVG_MEMMOVE MyOwnMemMoveFunction

Needs to be same signature as std::memmove

#define LINAVG_MALLOC MyOwnMallocFunction

Needs to be same signature as std::malloc

#define LINAVG_FREE MyOwnFreeFunction

Needs to be same signature as std::free

⚠️ **GitHub.com Fallback** ⚠️