Make nanovg work with mac

This commit is contained in:
Joey Yakimowich-Payne 2020-09-09 05:07:15 -06:00
commit 86630827e3
6 changed files with 86 additions and 45 deletions

View file

@ -22,15 +22,20 @@ proc main =
fps = newGraph(RenderStyle.FPS, "Frame Time")
cpuGraph = newGraph(RenderStyle.MS, "CPU Time")
discard glfw.init()
initHint(CONTEXT_VERSION_MAJOR, 3)
initHint(CONTEXT_VERSION_MINOR, 2)
when defined(macosx):
initHint(OPENGL_FORWARD_COMPAT, 1)
initHint(OPENGL_PROFILE, OPENGL_COMPAT_PROFILE)
else:
initHint(OPENGL_PROFILE, OPENGL_CORE_PROFILE)
initHint(OPENGL_PROFILE, OPENGL_CORE_PROFILE)
discard glfw.init()
windowHint(CONTEXT_VERSION_MAJOR, 3)
windowHint(CONTEXT_VERSION_MINOR, 2)
when defined(macosx):
windowHint(OPENGL_FORWARD_COMPAT, 1)
windowHint(OPENGL_PROFILE, OPENGL_CORE_PROFILE)
var w = createWindow(800, 600, "Minimal Nim-GLFW Example", nil, nil)
w.makeContextCurrent()

View file

@ -73,6 +73,7 @@ proc main() =
discard glew.init()
let vg = nanovg.newContext()
vg.loadFont(currentSourceDir()/"resources"/"Roboto-Regular.ttf", "sans")
vg.loadFont(currentSourceDir()/"resources"/"umeboshi.ttf", "umeboshi")
vg.loadFont(currentSourceDir()/"resources"/"Roboto-Bold.ttf", "sans-bold")
vg.loadFont(currentSourceDir()/"resources"/"fa.ttf", "fa")
vg.loadFont(currentSourceDir()/"resources"/"entypo.ttf", "icons")
@ -87,6 +88,7 @@ proc main() =
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT)
vg.withFrame(window):
vg.setFont("umeboshi")
vg.text("Some仮名thing is up", 100, 100, 100)
vg.drawWindow("Title", 50, 50, 300, 400)
vg.drawLabel("Hello!", 10, 10, 280, 20)
@ -116,4 +118,4 @@ proc main() =
img.quit()
sdl.quit()
main()
main()