Branimir Karadžić 7 anni fa
parent
commit
15485134f7

+ 59 - 30
examples/common/nanovg/fontstash.h

@@ -38,6 +38,11 @@ enum FONSalign {
 	FONS_ALIGN_BASELINE	= 1<<6, // Default
 	FONS_ALIGN_BASELINE	= 1<<6, // Default
 };
 };
 
 
+enum FONSglyphBitmap {
+	FONS_GLYPH_BITMAP_OPTIONAL = 1,
+	FONS_GLYPH_BITMAP_REQUIRED = 2,
+};
+
 enum FONSerrorCode {
 enum FONSerrorCode {
 	// Font atlas is full.
 	// Font atlas is full.
 	FONS_ATLAS_FULL = 1,
 	FONS_ATLAS_FULL = 1,
@@ -78,12 +83,13 @@ struct FONStextIter {
 	const char* next;
 	const char* next;
 	const char* end;
 	const char* end;
 	unsigned int utf8state;
 	unsigned int utf8state;
+	int bitmapOption;
 };
 };
 typedef struct FONStextIter FONStextIter;
 typedef struct FONStextIter FONStextIter;
 
 
 typedef struct FONScontext FONScontext;
 typedef struct FONScontext FONScontext;
 
 
-// Constructor and destructor.
+// Contructor and destructor.
 FONScontext* fonsCreateInternal(FONSparams* params);
 FONScontext* fonsCreateInternal(FONSparams* params);
 void fonsDeleteInternal(FONScontext* s);
 void fonsDeleteInternal(FONScontext* s);
 
 
@@ -92,7 +98,7 @@ void fonsSetErrorCallback(FONScontext* s, void (*callback)(void* uptr, int error
 void fonsGetAtlasSize(FONScontext* s, int* width, int* height);
 void fonsGetAtlasSize(FONScontext* s, int* width, int* height);
 // Expands the atlas size.
 // Expands the atlas size.
 int fonsExpandAtlas(FONScontext* s, int width, int height);
 int fonsExpandAtlas(FONScontext* s, int width, int height);
-// Resets the whole stash.
+// Reseta the whole stash.
 int fonsResetAtlas(FONScontext* stash, int width, int height);
 int fonsResetAtlas(FONScontext* stash, int width, int height);
 
 
 // Add fonts
 // Add fonts
@@ -122,7 +128,7 @@ void fonsLineBounds(FONScontext* s, float y, float* miny, float* maxy);
 void fonsVertMetrics(FONScontext* s, float* ascender, float* descender, float* lineh);
 void fonsVertMetrics(FONScontext* s, float* ascender, float* descender, float* lineh);
 
 
 // Text iterator
 // Text iterator
-int fonsTextIterInit(FONScontext* stash, FONStextIter* iter, float x, float y, const char* str, const char* end);
+int fonsTextIterInit(FONScontext* stash, FONStextIter* iter, float x, float y, const char* str, const char* end, int bitmapOption);
 int fonsTextIterNext(FONScontext* stash, FONStextIter* iter, struct FONSquad* quad);
 int fonsTextIterNext(FONScontext* stash, FONStextIter* iter, struct FONSquad* quad);
 
 
 // Pull texture changes
 // Pull texture changes
@@ -880,20 +886,22 @@ error:
 int fonsAddFont(FONScontext* stash, const char* name, const char* path)
 int fonsAddFont(FONScontext* stash, const char* name, const char* path)
 {
 {
 	FILE* fp = 0;
 	FILE* fp = 0;
-	int dataSize = 0;
+	size_t dataSize = 0;
+	size_t readed;
 	unsigned char* data = NULL;
 	unsigned char* data = NULL;
 
 
 	// Read in the font data.
 	// Read in the font data.
 	fp = fopen(path, "rb");
 	fp = fopen(path, "rb");
 	if (fp == NULL) goto error;
 	if (fp == NULL) goto error;
 	fseek(fp,0,SEEK_END);
 	fseek(fp,0,SEEK_END);
-	dataSize = (int)ftell(fp);
+	dataSize = ftell(fp);
 	fseek(fp,0,SEEK_SET);
 	fseek(fp,0,SEEK_SET);
 	data = (unsigned char*)malloc(dataSize);
 	data = (unsigned char*)malloc(dataSize);
 	if (data == NULL) goto error;
 	if (data == NULL) goto error;
-	fread(data, 1, dataSize, fp);
+	readed = fread(data, 1, dataSize, fp);
 	fclose(fp);
 	fclose(fp);
 	fp = 0;
 	fp = 0;
+	if (readed != dataSize) goto error;
 
 
 	return fonsAddFontMem(stash, name, data, dataSize, 1);
 	return fonsAddFontMem(stash, name, data, dataSize, 1);
 
 
@@ -1035,7 +1043,7 @@ static void fons__blur(FONScontext* stash, unsigned char* dst, int w, int h, int
 }
 }
 
 
 static FONSglyph* fons__getGlyph(FONScontext* stash, FONSfont* font, unsigned int codepoint,
 static FONSglyph* fons__getGlyph(FONScontext* stash, FONSfont* font, unsigned int codepoint,
-								 short isize, short iblur)
+								 short isize, short iblur, int bitmapOption)
 {
 {
 	int i, g, advance, lsb, x0, y0, x1, y1, gw, gh, gx, gy, x, y;
 	int i, g, advance, lsb, x0, y0, x1, y1, gw, gh, gx, gy, x, y;
 	float scale;
 	float scale;
@@ -1058,12 +1066,18 @@ static FONSglyph* fons__getGlyph(FONScontext* stash, FONSfont* font, unsigned in
 	h = fons__hashint(codepoint) & (FONS_HASH_LUT_SIZE-1);
 	h = fons__hashint(codepoint) & (FONS_HASH_LUT_SIZE-1);
 	i = font->lut[h];
 	i = font->lut[h];
 	while (i != -1) {
 	while (i != -1) {
-		if (font->glyphs[i].codepoint == codepoint && font->glyphs[i].size == isize && font->glyphs[i].blur == iblur)
-			return &font->glyphs[i];
+		if (font->glyphs[i].codepoint == codepoint && font->glyphs[i].size == isize && font->glyphs[i].blur == iblur) {
+			glyph = &font->glyphs[i];
+			if (bitmapOption == FONS_GLYPH_BITMAP_OPTIONAL || (glyph->x0 >= 0 && glyph->y0 >= 0)) {
+			  return glyph;
+			}
+			// At this point, glyph exists but the bitmap data is not yet created.
+			break;
+		}
 		i = font->glyphs[i].next;
 		i = font->glyphs[i].next;
 	}
 	}
 
 
-	// Could not find glyph, create it.
+	// Create a new glyph or rasterize bitmap data for a cached glyph.
 	g = fons__tt_getGlyphIndex(&font->font, codepoint);
 	g = fons__tt_getGlyphIndex(&font->font, codepoint);
 	// Try to find the glyph in fallback fonts.
 	// Try to find the glyph in fallback fonts.
 	if (g == 0) {
 	if (g == 0) {
@@ -1084,20 +1098,34 @@ static FONSglyph* fons__getGlyph(FONScontext* stash, FONSfont* font, unsigned in
 	gw = x1-x0 + pad*2;
 	gw = x1-x0 + pad*2;
 	gh = y1-y0 + pad*2;
 	gh = y1-y0 + pad*2;
 
 
-	// Find free spot for the rect in the atlas
-	added = fons__atlasAddRect(stash->atlas, gw, gh, &gx, &gy);
-	if (added == 0 && stash->handleError != NULL) {
-		// Atlas is full, let the user to resize the atlas (or not), and try again.
-		stash->handleError(stash->errorUptr, FONS_ATLAS_FULL, 0);
+	// Determines the spot to draw glyph in the atlas.
+	if (bitmapOption == FONS_GLYPH_BITMAP_REQUIRED) {
+		// Find free spot for the rect in the atlas
 		added = fons__atlasAddRect(stash->atlas, gw, gh, &gx, &gy);
 		added = fons__atlasAddRect(stash->atlas, gw, gh, &gx, &gy);
+		if (added == 0 && stash->handleError != NULL) {
+			// Atlas is full, let the user to resize the atlas (or not), and try again.
+			stash->handleError(stash->errorUptr, FONS_ATLAS_FULL, 0);
+			added = fons__atlasAddRect(stash->atlas, gw, gh, &gx, &gy);
+		}
+		if (added == 0) return NULL;
+	} else {
+		// Negative coordinate indicates there is no bitmap data created.
+		gx = -1;
+		gy = -1;
 	}
 	}
-	if (added == 0) return NULL;
 
 
 	// Init glyph.
 	// Init glyph.
-	glyph = fons__allocGlyph(font);
-	glyph->codepoint = codepoint;
-	glyph->size = isize;
-	glyph->blur = iblur;
+	if (glyph == NULL) {
+		glyph = fons__allocGlyph(font);
+		glyph->codepoint = codepoint;
+		glyph->size = isize;
+		glyph->blur = iblur;
+		glyph->next = 0;
+
+		// Insert char to hash lookup.
+		glyph->next = font->lut[h];
+		font->lut[h] = font->nglyphs-1;
+	}
 	glyph->index = g;
 	glyph->index = g;
 	glyph->x0 = (short)gx;
 	glyph->x0 = (short)gx;
 	glyph->y0 = (short)gy;
 	glyph->y0 = (short)gy;
@@ -1106,15 +1134,14 @@ static FONSglyph* fons__getGlyph(FONScontext* stash, FONSfont* font, unsigned in
 	glyph->xadv = (short)(scale * advance * 10.0f);
 	glyph->xadv = (short)(scale * advance * 10.0f);
 	glyph->xoff = (short)(x0 - pad);
 	glyph->xoff = (short)(x0 - pad);
 	glyph->yoff = (short)(y0 - pad);
 	glyph->yoff = (short)(y0 - pad);
-	glyph->next = 0;
 
 
-	// Insert char to hash lookup.
-	glyph->next = font->lut[h];
-	font->lut[h] = font->nglyphs-1;
+	if (bitmapOption == FONS_GLYPH_BITMAP_OPTIONAL) {
+		return glyph;
+	}
 
 
 	// Rasterize
 	// Rasterize
 	dst = &stash->texData[(glyph->x0+pad) + (glyph->y0+pad) * stash->params.width];
 	dst = &stash->texData[(glyph->x0+pad) + (glyph->y0+pad) * stash->params.width];
-	fons__tt_renderGlyphBitmap(&renderFont->font, dst, gw-pad*2,gh-pad*2, stash->params.width, scale,scale, g);
+	fons__tt_renderGlyphBitmap(&renderFont->font, dst, gw-pad*2,gh-pad*2, stash->params.width, scale, scale, g);
 
 
 	// Make sure there is one pixel empty border.
 	// Make sure there is one pixel empty border.
 	dst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width];
 	dst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width];
@@ -1141,7 +1168,7 @@ static FONSglyph* fons__getGlyph(FONScontext* stash, FONSfont* font, unsigned in
 	if (iblur > 0) {
 	if (iblur > 0) {
 		stash->nscratch = 0;
 		stash->nscratch = 0;
 		bdst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width];
 		bdst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width];
-		fons__blur(stash, bdst, gw,gh, stash->params.width, iblur);
+		fons__blur(stash, bdst, gw, gh, stash->params.width, iblur);
 	}
 	}
 
 
 	stash->dirtyRect[0] = fons__mini(stash->dirtyRect[0], glyph->x0);
 	stash->dirtyRect[0] = fons__mini(stash->dirtyRect[0], glyph->x0);
@@ -1303,7 +1330,7 @@ float fonsDrawText(FONScontext* stash,
 	for (; str != end; ++str) {
 	for (; str != end; ++str) {
 		if (fons__decutf8(&utf8state, &codepoint, *(const unsigned char*)str))
 		if (fons__decutf8(&utf8state, &codepoint, *(const unsigned char*)str))
 			continue;
 			continue;
-		glyph = fons__getGlyph(stash, font, codepoint, isize, iblur);
+		glyph = fons__getGlyph(stash, font, codepoint, isize, iblur, FONS_GLYPH_BITMAP_REQUIRED);
 		if (glyph != NULL) {
 		if (glyph != NULL) {
 			fons__getQuad(stash, font, prevGlyphIndex, glyph, scale, state->spacing, &x, &y, &q);
 			fons__getQuad(stash, font, prevGlyphIndex, glyph, scale, state->spacing, &x, &y, &q);
 
 
@@ -1326,7 +1353,7 @@ float fonsDrawText(FONScontext* stash,
 }
 }
 
 
 int fonsTextIterInit(FONScontext* stash, FONStextIter* iter,
 int fonsTextIterInit(FONScontext* stash, FONStextIter* iter,
-					 float x, float y, const char* str, const char* end)
+					 float x, float y, const char* str, const char* end, int bitmapOption)
 {
 {
 	FONSstate* state = fons__getState(stash);
 	FONSstate* state = fons__getState(stash);
 	float width;
 	float width;
@@ -1366,6 +1393,7 @@ int fonsTextIterInit(FONScontext* stash, FONStextIter* iter,
 	iter->end = end;
 	iter->end = end;
 	iter->codepoint = 0;
 	iter->codepoint = 0;
 	iter->prevGlyphIndex = -1;
 	iter->prevGlyphIndex = -1;
+	iter->bitmapOption = bitmapOption;
 
 
 	return 1;
 	return 1;
 }
 }
@@ -1386,7 +1414,8 @@ int fonsTextIterNext(FONScontext* stash, FONStextIter* iter, FONSquad* quad)
 		// Get glyph and quad
 		// Get glyph and quad
 		iter->x = iter->nextx;
 		iter->x = iter->nextx;
 		iter->y = iter->nexty;
 		iter->y = iter->nexty;
-		glyph = fons__getGlyph(stash, iter->font, iter->codepoint, iter->isize, iter->iblur);
+		glyph = fons__getGlyph(stash, iter->font, iter->codepoint, iter->isize, iter->iblur, iter->bitmapOption);
+		// If the iterator was initialized with FONS_GLYPH_BITMAP_OPTIONAL, then the UV coordinates of the quad will be invalid.
 		if (glyph != NULL)
 		if (glyph != NULL)
 			fons__getQuad(stash, iter->font, iter->prevGlyphIndex, glyph, iter->scale, iter->spacing, &iter->nextx, &iter->nexty, quad);
 			fons__getQuad(stash, iter->font, iter->prevGlyphIndex, glyph, iter->scale, iter->spacing, &iter->nextx, &iter->nexty, quad);
 		iter->prevGlyphIndex = glyph != NULL ? glyph->index : -1;
 		iter->prevGlyphIndex = glyph != NULL ? glyph->index : -1;
@@ -1483,7 +1512,7 @@ float fonsTextBounds(FONScontext* stash,
 	for (; str != end; ++str) {
 	for (; str != end; ++str) {
 		if (fons__decutf8(&utf8state, &codepoint, *(const unsigned char*)str))
 		if (fons__decutf8(&utf8state, &codepoint, *(const unsigned char*)str))
 			continue;
 			continue;
-		glyph = fons__getGlyph(stash, font, codepoint, isize, iblur);
+		glyph = fons__getGlyph(stash, font, codepoint, isize, iblur, FONS_GLYPH_BITMAP_OPTIONAL);
 		if (glyph != NULL) {
 		if (glyph != NULL) {
 			fons__getQuad(stash, font, prevGlyphIndex, glyph, scale, state->spacing, &x, &y, &q);
 			fons__getQuad(stash, font, prevGlyphIndex, glyph, scale, state->spacing, &x, &y, &q);
 			if (q.x0 < minx) minx = q.x0;
 			if (q.x0 < minx) minx = q.x0;

+ 14 - 6
examples/common/nanovg/nanovg.cpp

@@ -77,6 +77,7 @@ enum NVGpointFlags
 
 
 struct NVGstate {
 struct NVGstate {
 	NVGcompositeOperationState compositeOperation;
 	NVGcompositeOperationState compositeOperation;
+	int shapeAntiAlias;
 	NVGpaint fill;
 	NVGpaint fill;
 	NVGpaint stroke;
 	NVGpaint stroke;
 	float strokeWidth;
 	float strokeWidth;
@@ -655,6 +656,7 @@ void nvgReset(NVGcontext* ctx)
 	nvg__setPaintColor(&state->fill, nvgRGBA(255,255,255,255));
 	nvg__setPaintColor(&state->fill, nvgRGBA(255,255,255,255));
 	nvg__setPaintColor(&state->stroke, nvgRGBA(0,0,0,255));
 	nvg__setPaintColor(&state->stroke, nvgRGBA(0,0,0,255));
 	state->compositeOperation = nvg__compositeOperationState(NVG_SOURCE_OVER);
 	state->compositeOperation = nvg__compositeOperationState(NVG_SOURCE_OVER);
+	state->shapeAntiAlias = 1;
 	state->strokeWidth = 1.0f;
 	state->strokeWidth = 1.0f;
 	state->miterLimit = 10.0f;
 	state->miterLimit = 10.0f;
 	state->lineCap = NVG_BUTT;
 	state->lineCap = NVG_BUTT;
@@ -674,6 +676,12 @@ void nvgReset(NVGcontext* ctx)
 }
 }
 
 
 // State setting
 // State setting
+void nvgShapeAntiAlias(NVGcontext* ctx, int enabled)
+{
+	NVGstate* state = nvg__getState(ctx);
+	state->shapeAntiAlias = enabled;
+}
+
 void nvgStrokeWidth(NVGcontext* ctx, float width)
 void nvgStrokeWidth(NVGcontext* ctx, float width)
 {
 {
 	NVGstate* state = nvg__getState(ctx);
 	NVGstate* state = nvg__getState(ctx);
@@ -2183,7 +2191,7 @@ void nvgFill(NVGcontext* ctx)
 	int i;
 	int i;
 
 
 	nvg__flattenPaths(ctx);
 	nvg__flattenPaths(ctx);
-	if (ctx->params.edgeAntiAlias)
+	if (ctx->params.edgeAntiAlias && state->shapeAntiAlias)
 		nvg__expandFill(ctx, ctx->fringeWidth, NVG_MITER, 2.4f);
 		nvg__expandFill(ctx, ctx->fringeWidth, NVG_MITER, 2.4f);
 	else
 	else
 		nvg__expandFill(ctx, 0.0f, NVG_MITER, 2.4f);
 		nvg__expandFill(ctx, 0.0f, NVG_MITER, 2.4f);
@@ -2228,7 +2236,7 @@ void nvgStroke(NVGcontext* ctx)
 
 
 	nvg__flattenPaths(ctx);
 	nvg__flattenPaths(ctx);
 
 
-	if (ctx->params.edgeAntiAlias)
+	if (ctx->params.edgeAntiAlias && state->shapeAntiAlias)
 		nvg__expandStroke(ctx, strokeWidth*0.5f + ctx->fringeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit);
 		nvg__expandStroke(ctx, strokeWidth*0.5f + ctx->fringeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit);
 	else
 	else
 		nvg__expandStroke(ctx, strokeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit);
 		nvg__expandStroke(ctx, strokeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit);
@@ -2413,7 +2421,7 @@ float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char*
 	verts = nvg__allocTempVerts(ctx, cverts);
 	verts = nvg__allocTempVerts(ctx, cverts);
 	if (verts == NULL) return x;
 	if (verts == NULL) return x;
 
 
-	fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end);
+	fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end, FONS_GLYPH_BITMAP_REQUIRED);
 	prevIter = iter;
 	prevIter = iter;
 	while (fonsTextIterNext(ctx->fs, &iter, &q)) {
 	while (fonsTextIterNext(ctx->fs, &iter, &q)) {
 		float c[4*2];
 		float c[4*2];
@@ -2451,7 +2459,7 @@ float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char*
 
 
 	nvg__renderText(ctx, verts, nverts);
 	nvg__renderText(ctx, verts, nverts);
 
 
-	return iter.x;
+	return iter.nextx / scale;
 }
 }
 
 
 void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end)
 void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end)
@@ -2510,7 +2518,7 @@ int nvgTextGlyphPositions(NVGcontext* ctx, float x, float y, const char* string,
 	fonsSetAlign(ctx->fs, state->textAlign);
 	fonsSetAlign(ctx->fs, state->textAlign);
 	fonsSetFont(ctx->fs, state->fontId);
 	fonsSetFont(ctx->fs, state->fontId);
 
 
-	fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end);
+	fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end, FONS_GLYPH_BITMAP_OPTIONAL);
 	prevIter = iter;
 	prevIter = iter;
 	while (fonsTextIterNext(ctx->fs, &iter, &q)) {
 	while (fonsTextIterNext(ctx->fs, &iter, &q)) {
 		if (iter.prevGlyphIndex < 0 && nvg__allocTextAtlas(ctx)) { // can not retrieve glyph?
 		if (iter.prevGlyphIndex < 0 && nvg__allocTextAtlas(ctx)) { // can not retrieve glyph?
@@ -2576,7 +2584,7 @@ int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, floa
 
 
 	breakRowWidth *= scale;
 	breakRowWidth *= scale;
 
 
-	fonsTextIterInit(ctx->fs, &iter, 0, 0, string, end);
+	fonsTextIterInit(ctx->fs, &iter, 0, 0, string, end, FONS_GLYPH_BITMAP_OPTIONAL);
 	prevIter = iter;
 	prevIter = iter;
 	while (fonsTextIterNext(ctx->fs, &iter, &q)) {
 	while (fonsTextIterNext(ctx->fs, &iter, &q)) {
 		if (iter.prevGlyphIndex < 0 && nvg__allocTextAtlas(ctx)) { // can not retrieve glyph?
 		if (iter.prevGlyphIndex < 0 && nvg__allocTextAtlas(ctx)) { // can not retrieve glyph?

+ 5 - 2
examples/common/nanovg/nanovg.h

@@ -240,6 +240,9 @@ void nvgReset(NVGcontext* ctx);
 //
 //
 // Current render style can be saved and restored using nvgSave() and nvgRestore().
 // Current render style can be saved and restored using nvgSave() and nvgRestore().
 
 
+// Sets whether to draw antialias for nvgStroke() and nvgFill(). It's enabled by default.
+void nvgShapeAntiAlias(NVGcontext* ctx, int enabled);
+
 // Sets current stroke style to a solid color.
 // Sets current stroke style to a solid color.
 void nvgStrokeColor(NVGcontext* ctx, NVGcolor color);
 void nvgStrokeColor(NVGcontext* ctx, NVGcolor color);
 
 
@@ -268,7 +271,7 @@ void nvgLineCap(NVGcontext* ctx, int cap);
 void nvgLineJoin(NVGcontext* ctx, int join);
 void nvgLineJoin(NVGcontext* ctx, int join);
 
 
 // Sets the transparency applied to all rendered shapes.
 // Sets the transparency applied to all rendered shapes.
-// Already transparent paths will get proportionally more transparent as well.
+// Alreade transparent paths will get proportionally more transparent as well.
 void nvgGlobalAlpha(NVGcontext* ctx, float alpha);
 void nvgGlobalAlpha(NVGcontext* ctx, float alpha);
 
 
 //
 //
@@ -392,7 +395,7 @@ NVGpaint nvgLinearGradient(NVGcontext* ctx, float sx, float sy, float ex, float
 						   NVGcolor icol, NVGcolor ocol);
 						   NVGcolor icol, NVGcolor ocol);
 
 
 // Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering
 // Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering
-// drop shadows or highlights for boxes. Parameters (x,y) define the top-left corner of the rectangle,
+// drop shadows or hilights for boxes. Parameters (x,y) define the top-left corner of the rectangle,
 // (w,h) define the size of the rectangle, r defines the corner radius, and f feather. Feather defines how blurry
 // (w,h) define the size of the rectangle, r defines the corner radius, and f feather. Feather defines how blurry
 // the border of the rectangle is. Parameter icol specifies the inner color and ocol the outer color of the gradient.
 // the border of the rectangle is. Parameter icol specifies the inner color and ocol the outer color of the gradient.
 // The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().
 // The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().

+ 2 - 2
examples/common/nanovg/nanovg_bgfx.cpp

@@ -1144,12 +1144,12 @@ NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId) {
 	return nvgCreate(_edgeaa, _viewId, NULL);
 	return nvgCreate(_edgeaa, _viewId, NULL);
 }
 }
 
 
-void nvgDelete(struct NVGcontext* _ctx)
+void nvgDelete(NVGcontext* _ctx)
 {
 {
 	nvgDeleteInternal(_ctx);
 	nvgDeleteInternal(_ctx);
 }
 }
 
 
-void nvgSetViewId(struct NVGcontext* _ctx, bgfx::ViewId _viewId)
+void nvgSetViewId(NVGcontext* _ctx, bgfx::ViewId _viewId)
 {
 {
 	struct NVGparams* params = nvgInternalParams(_ctx);
 	struct NVGparams* params = nvgInternalParams(_ctx);
 	struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;
 	struct GLNVGcontext* gl = (struct GLNVGcontext*)params->userPtr;

+ 2 - 2
examples/common/nanovg/nanovg_bgfx.h

@@ -27,10 +27,10 @@ NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId, bx::AllocatorI* _al
 NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId);
 NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId);
 
 
 ///
 ///
-void nvgDelete(struct NVGcontext* _ctx);
+void nvgDelete(NVGcontext* _ctx);
 
 
 ///
 ///
-void nvgSetViewId(struct NVGcontext* _ctx, bgfx::ViewId _viewId);
+void nvgSetViewId(NVGcontext* _ctx, bgfx::ViewId _viewId);
 
 
 ///
 ///
 uint16_t nvgGetViewId(struct NVGcontext* _ctx);
 uint16_t nvgGetViewId(struct NVGcontext* _ctx);