Skip to content

Instantly share code, notes, and snippets.

@paniq
Created April 22, 2019 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paniq/379dbaa266c36e9847719b9756e47572 to your computer and use it in GitHub Desktop.
Save paniq/379dbaa266c36e9847719b9756e47572 to your computer and use it in GitHub Desktop.
define sdl
import ..tukan.sdl
define glmain
import ..tukan.glmain
using import glm
using import glsl
using import ..tukan.gl
using import ..tukan.nanovg
glmain.init
title = "NanoVG test"
width = 960
height = 540
resizable = true
global vg = (nvgCreateGL3 1)
global monofont =
nvgCreateFont vg "fixed"
.. module-dir "/../assets/core/fonts/UbuntuMono-R.ttf"
global cursor = (ivec2 100 100)
fn render-view (size)
glBindFramebuffer GL_FRAMEBUFFER 0
nvgBeginGLFrame vg size
nvgBeginPath vg
nvgRect vg 0 0 (unpack (vec2 size))
nvgFillColor vg
nvgRGBf 0.5 0.5 0.5
nvgFill vg
nvgFillColor vg
nvgRGBf 0 0 0
nvgText vg 200 200 "The Quick Brown Fox Yadda Yadda" null
nvgBeginPath vg
nvgCircle vg (f32 cursor.x) (f32 cursor.y) 8
nvgStrokeColor vg
nvgRGBf 1 1 1
nvgStrokeWidth vg 4
nvgStroke vg
nvgStrokeColor vg
nvgRGBf 0 0 0
nvgStrokeWidth vg 2
nvgStroke vg
nvgEndFrame vg
@@ 'on glmain.on-event
fn (event)
if event.type == sdl.SDL_MOUSEMOTION
cursor =
ivec2
event.motion.x
event.motion.y
@@ 'on glmain.on-draw
fn (s size)
render-view size
glmain.loop;
nvgDeleteGL3 vg
glmain.shutdown;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment