diff --git a/examples/demo.nim b/examples/demo.nim index 03dd27d..775994c 100644 --- a/examples/demo.nim +++ b/examples/demo.nim @@ -204,7 +204,6 @@ proc main = var w = newWindow(c) - echo currentSourcePath nanovg.init() nanovg.loadFont(currentSourceDir()/"resources/Roboto-Regular.ttf", "sans") nanovg.loadFont(currentSourceDir()/"resources/Roboto-Bold.ttf", "sans-bold") diff --git a/examples/glew32.dll b/examples/glew32.dll new file mode 100644 index 0000000..928f564 Binary files /dev/null and b/examples/glew32.dll differ diff --git a/examples/glfw3.dll b/examples/glfw3.dll new file mode 100644 index 0000000..1ed6f46 Binary files /dev/null and b/examples/glfw3.dll differ diff --git a/src/nanovg/wrapper.nim b/src/nanovg/wrapper.nim index 8cc134b..4079085 100644 --- a/src/nanovg/wrapper.nim +++ b/src/nanovg/wrapper.nim @@ -1,6 +1,7 @@ import os import opengl import strutils +import regex import nimterop/[cimport, build] @@ -31,34 +32,37 @@ src/*.c """, checkout = "1f9c8864fc556a1be4d4bf1d6bfe20cde25734b4") let contents = readFile(srcDir/"src/nanovg_gl.h") - let newContents = contents.replace("#define NANOVG_GL_H\n", """ + let newContents = contents.replace(re"#define NANOVG_GL_H", """ +#define NANOVG_GL_H #define NANOVG_GL_USE_UNIFORMBUFFER #define NANOVG_GL3 #define GLFW_INCLUDE_GLEXT #ifdef __APPLE__ # define GLFW_INCLUDE_GLCOREARB #endif +#include #include #include "nanovg.h" -""") +""", limit=1) writeFile(srcDir/"src/nanovg_gl.h", newContents) +cDefine("NANOVG_GL3_IMPLEMENTATION", "") + # Manually wrap any symbols since nimterop cannot or incorrectly wraps them cOverride: # Standard Nim code to wrap types, consts, procs, etc. type + NVGcontext* {.importc: "struct NVGcontext", bycopy.} = object NVGcolor* {.importc: "struct NVGcolor", bycopy.} = object r* {.importc: "r".}: cfloat g* {.importc: "g".}: cfloat b* {.importc: "b".}: cfloat a* {.importc: "a".}: cfloat + proc CreateGL*(flags: cint): ptr NVGContext {.importc: "nvgCreateGL3", header: srcDir/"src/nanovg_gl.h", cdecl.} # Specify include directories for gcc and Nim cIncludeDir(srcDir/"src") -# Define global symbols -cDefine("NANOVG_GL3_IMPLEMENTATION", "1") - # Any global compiler options when defined(macosx): # cDefine("GLFW_INCLUDE_GLCOREARB", "1") @@ -69,8 +73,8 @@ elif defined(unix): {.passC: "-DNANOVG_GL3_IMPLEMENTATION -DNANOVG_GLEW".} {.passL: "-lGL -lGLU -lGLEW -lm -lglfw".} elif defined(windows): - {.passC: "-DNANOVG_GL3_IMPLEMENTATION -DNANOVG_GLEW -D_CRT_SECURE_NO_WARNINGS".} - {.passL: "-lglew32 -lm -lglfw3 -lgdi32 -lwinmm -luser32 -lglu32 -lopengl32 -lkernel32".} + {.passC: "-DNANOVG_GL3_IMPLEMENTATION -DNANOVG_GLEW -D_CRT_SECURE_NO_WARNINGS -w -fmax-errors=10".} + {.passL: "-lfreeglut -lglew32 -lm -lglfw3 -lgdi32 -lwinmm -luser32 -lglu32 -lopengl32 -lkernel32".} # Compile in any common source code