memononen / nanovg

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

`'nvgCreateGL3’ was not declared in this scope` #634

Closed frutas-fruit closed 2 years ago

frutas-fruit commented 2 years ago

I am defining this in one of my cpp files:

#include <nanovg.h>
#define NANOVG_GL3_IMPLEMENTATION
#include <nanovg_gl.h>

But when I come to init my nanovg context (in the same cpp file), like this:

nanovg_context = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);

It throws an error upon compiling:

error: ‘nvgCreateGL3’ was not declared in this scope; did you mean ‘nvgCreateFont’?
  137 |   nanovg_context = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
      |             ^~~~~~~~~~~~
      |             nvgCreateFont

Any ideas why this is happening? I.e. I have clearly defined both NANOVG_GL3_IMPLEMENTATION and included nanovg_gl.h, so why does it still fail to find nvgCreateGL3?

mulle-nat commented 2 years ago

Looks like you are including <nanovg_gl.h> in some other place before it hits your code, or there is a typo in your code. If you can't see it easily, run the C preprocessor over your source file and see what's happening.

frutas-fruit commented 2 years ago

Looks like you are including <nanovg_gl.h> in some other place before it hits your code

Ah yeah, that's why. Didn't think including it in my hpp header would cause it to throw that error. Thanks for spotting it!