You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you use different threads for layouting and drawing, you will notice that one aspect of nanovg becomes very limiting: you always need a full blown graphics context for everything. This usually means also an OS window. But for layouting you usually only need some font metrics, which can be provided by FreeType (or STB). Neither of them need OpenGL to work.
Because the font implementation of nanovg is somewhat abstracted (over STB and FreeType) and hidden, you run the risk of recreating a lot of code that is very similiar but still slightly different to nanovg, when you need to use FreeType or STB directly.
The solution IMO is to create nvgContext with different types (I added another NVG_PATH_CONTEXT type for experimental purposes):
During creation of a NVG_FONT_CONTEXT context nanovg will not attempt to access any OpenGL functionality. At runtime each function in nanovg is asserted for compliance.
When you use different threads for layouting and drawing, you will notice that one aspect of nanovg becomes very limiting: you always need a full blown graphics context for everything. This usually means also an OS window. But for layouting you usually only need some font metrics, which can be provided by FreeType (or STB). Neither of them need OpenGL to work.
Because the font implementation of nanovg is somewhat abstracted (over STB and FreeType) and hidden, you run the risk of recreating a lot of code that is very similiar but still slightly different to nanovg, when you need to use FreeType or STB directly.
The solution IMO is to create
nvgContext
with different types (I added anotherNVG_PATH_CONTEXT
type for experimental purposes):During creation of a
NVG_FONT_CONTEXT
context nanovg will not attempt to access any OpenGL functionality. At runtime each function in nanovg isassert
ed for compliance.e.g.
Now you can write layout code, that uses nanovg functions to determine font metrics.
You can view the actual working code in my nanovg fork.
The text was updated successfully, but these errors were encountered: