Skip to content

03 Configuration

Inan Evin edited this page Oct 12, 2024 · 10 revisions

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. A few examples of those:

/// <summary>
/// Used as an additional scale on AA thickness.
/// All Style options also have their own/local framebuffer scale, which is multiplied by this value.
/// </summary>
float globalAAMultiplier = 1.0f;

/// <summary>
/// If the angle between two lines exceed this limit fall-back to bevel joints from miter joints.
/// This is because miter joins the line points on intersection, ang with a very small angle (closer to 180) intersections get close to infinity.
/// </summary>
float miterLimit = 150;

/// <summary>
/// Maximum size a font texture atlas can have, all atlasses are square, so this is used for both width and height.
/// Increase if you are loading a lot of characters or fonts with big sizes (e.g. 100)
/// You can use Internal::DrawDebugFontAtlas to visualize the atlas target font belongs to.
/// </summary>
unsigned int maxFontAtlasSize = 768;

/// <summary>
/// Every interval ticks system will garbage collect all vertex and index buffers, meaning that will clear all the arrays.
/// On other ticks, arrays are simply resized to 0, avoiding re-allocations on the next frame.
/// Set to 0 for instant flush on buffers at the end of every frame.
/// </summary>
int gcCollectInterval = 600;

/// <summary>
/// This amount of buffers are reserved upon Renderer initialization. Saves time from allocating/deallocating buffers in runtime.
/// </summary>
int defaultBufferReserve = 50;

/// <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;

/// <summary>
/// Enabling caching allows faster text rendering in exchange for more memory consumption.
/// Note: dynamic texts you render will not benefit from this.
/// </summary>
bool textCachingEnabled = false;

/// <summary>
/// Initial reserve for normal text cache, will grow if needed.
/// </summary>
int textCacheReserve = 300;

/// <summary>
/// Every this amount of ticks the text caches will be cleared up to prevent memory bloating.
/// </summary>
int textCacheExpireInterval = 3000;

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

Clone this wiki locally