nanovg icon indicating copy to clipboard operation
nanovg copied to clipboard

VC2013 C++ Compile

Open TronicLabs opened this issue 10 years ago • 3 comments

nanovg_gl.h#L1444-#L1525

EX. #L1447

static NVGcontext* nvgCreateGL3(int flags);

#L1492

static void nvgDeleteGL3(NVGcontext* ctx);

#L1502

static int nvglCreateImageFromHandle(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) {...}

#L1518

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.

TronicLabs avatar Feb 14 '15 08:02 TronicLabs

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 avatar Feb 14 '15 10:02 memononen

@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

xarthurx avatar May 25 '19 17:05 xarthurx

#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 .

memononen avatar May 25 '19 18:05 memononen