nanovg
nanovg copied to clipboard
VC2013 C++ Compile
EX. #L1447
static NVGcontext* nvgCreateGL3(int flags);
static void nvgDeleteGL3(NVGcontext* ctx);
static int nvglCreateImageFromHandle(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) {...}
static GLuint nvglImageHandle(NVGcontext* ctx, int image) {...}
to compile without problems I had to make static struct and the void of this section, otherwise the compiler returned an error saying that they were already defined.
The GL backend is a bit special, as it follows the one-header-file library model (idea stolen from the stb_* libraries).
The idea is that in one file you define NANOVG_GL_IMPLEMENTATION
before including the header, and it will also include the implementation, not just the prototypes. Then on each other case you include just the header.
The backend contains implementations for multiple GL versions. For example if you're using GL2 backend, you can define NANOVG_GL2
once in your build settings.
I hope that makes sense.
@memononen Could you explain it a bit more in depth?
I have a viewer that have some basic implementation of drawing funcs using nanovg, with a header app.h
(where #define NANOVG_GL3_IMPLEMENTATION
happens)
And for a derived class that defined in another header derivedApp.h
, if there is a derivedApp.cpp
exist and include derivedApp.h
, the compiler will report sth like:
nvgDeleteGL3 already defined in xxx.obj
nvgCreateGL3 already defined in xxx.obj
#define NANOVG_GL3_IMPLEMENTATION
should be in the implementation file
not in header.
On Sat, May 25, 2019 at 8:06 PM X.ZhaoMa [email protected] wrote:
@memononen https://github.com/memononen Could you explain it a bit more in depth?
I have a viewer that have some basic implementation of drawing funcs using nanovg, with a header app.h (where #define NANOVG_GL3_IMPLEMENTATION happens)
And for a derived class that defined in another header derivedApp.h, if there is a derivedApp.cpp exist and include derivedApp.h, the compiler will report sth like:
nvgDeleteGL3 already defined in xxx.obj nvgCreateGL3 already defined in xxx.obj
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/memononen/nanovg/issues/199?email_source=notifications&email_token=ABIBXSGIXD2OCKBWAFZGUDLPXFWZ5A5CNFSM4A4B5AG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWHVRUA#issuecomment-495933648, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIBXSHFKR5QAH3TZGOEKRDPXFWZ5ANCNFSM4A4B5AGQ .