From f65fb205c4336559da9b1a56e2738622683b639a Mon Sep 17 00:00:00 2001 From: Hanspeter Portner Date: Fri, 10 Aug 2018 18:54:13 +0200 Subject: [PATCH] improve prototype of nanovg backend. --- canvas.lv2/render_nanovg.h | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/canvas.lv2/render_nanovg.h b/canvas.lv2/render_nanovg.h index 030056f..308e306 100644 --- a/canvas.lv2/render_nanovg.h +++ b/canvas.lv2/render_nanovg.h @@ -21,10 +21,25 @@ #include #include -#define NANOVG_GL3_IMPLEMENTATION +#include +#define NANOVG_GL2_IMPLEMENTATION #include #include +#if defined(NANOVG_GL2_IMPLEMENTATION) +# define nvgCreate nvgCreateGL2 +# define nvgDelete nvgDeleteGL2 +#elif defined(NANOVG_GL3_IMPLEMENTATION) +# define nvgCreate nvgCreateGL3 +# define nvgDelete nvgDeleteGL3 +#elif defined(NANOVG_GLES2_IMPLEMENTATION) +# define nvgCreate nvgCreateGLES2 +# define nvgDelete nvgDeleteGLES2 +#elif defined(NANOVG_GLES3_IMPLEMENTATION) +# define nvgCreate nvgCreateGLES3 +# define nvgDelete nvgDeleteGLES3 +#endif + #ifdef __cplusplus extern "C" { #endif @@ -523,15 +538,11 @@ lv2_canvas_render(LV2_Canvas *canvas, NVGcontext *ctx, const LV2_Atom_Tuple *tup nvgSave(ctx); // clear surface - /* FIXME - cairo_set_operator(ctx, CAIRO_OPERATOR_CLEAR); - cairo_paint(ctx); - */ - - // default attributes - /* FIXME - cairo_set_operator(ctx, CAIRO_OPERATOR_SOURCE); - */ + nvgBeginPath(ctx); + nvgRect(ctx, 0, 0, 1.f, 1.f); + nvgFillColor(ctx, nvgRGBA(0x1e, 0x1e, 0x1e, 0xff)); + nvgFill(ctx); + nvgFontSize(ctx, 0.1); nvgStrokeWidth(ctx, 0.01); nvgStrokeColor(ctx, nvgRGBA(0xff, 0xff, 0xff, 0xff)); @@ -559,12 +570,6 @@ lv2_canvas_render(LV2_Canvas *canvas, NVGcontext *ctx, const LV2_Atom_Tuple *tup // save state nvgRestore(ctx); - // flush - /* FIXME - cairo_surface_t *surface = cairo_get_target(ctx); - cairo_surface_flush(surface); - */ - return true; } -- 2.38.5