memononen / nanovg

Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.
zlib License
5.15k stars 771 forks source link

add include guard so that the gl_header can be included in multiple source files #605

Closed ITotalJustice closed 3 years ago

ITotalJustice commented 3 years ago

Hi, firstly thank you so much for the great library.

I need to include the gl header in multiple source files to use some of the gl functions such as nvglCreateImageFromHandleGL3, however i was getting errors because of functions being defined in multiple source files. I added an include guard for this, so it would like this in another source file that wants to use gl stuff:

#define NANOVG_GL_HEADER_ONLY
#define NANOVG_GL3_IMPLEMENTATION
#include "nanovg/gl/nanovg_gl.h"

this way only the definitions of the functions are pulled in.

memononen commented 3 years ago

You should define the implementation in just fine one file. If you want to include the GL3 header only you can do it like this:

#define NANOVG_GL3
#include "nanovg/gl/nanovg_gl.h"
ITotalJustice commented 3 years ago

Thank you, i totally missed NANOVG_GL3