diff --git a/src/nanovg_gl3.h b/src/nanovg_gl3.h index 56b692b..971fb6b 100644 --- a/src/nanovg_gl3.h +++ b/src/nanovg_gl3.h @@ -522,14 +522,6 @@ static int glnvg__renderGetTextureSize(void* uptr, int image, int* w, int* h) return 1; } -static void glnvg__toFloatColor(float* fc, unsigned int c) -{ - fc[0] = ((c) & 0xff) / 255.0f; - fc[1] = ((c>>8) & 0xff) / 255.0f; - fc[2] = ((c>>16) & 0xff) / 255.0f; - fc[3] = ((c>>24) & 0xff) / 255.0f; -} - static void glnvg__xformIdentity(float* t) { t[0] = 1.0f; t[1] = 0.0f; @@ -568,15 +560,15 @@ static void glnvg__xformToMat3x3(float* m3, float* t) static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, struct NVGscissor* scissor, float width, float fringe) { - float innerCol[4]; - float outerCol[4]; + struct NVGcolor innerCol; + struct NVGcolor outerCol; struct GLNVGtexture* tex = NULL; float invxform[6], paintMat[9], scissorMat[9]; float scissorx = 0, scissory = 0; float scissorsx = 0, scissorsy = 0; - glnvg__toFloatColor(innerCol, paint->innerColor); - glnvg__toFloatColor(outerCol, paint->outerColor); + innerCol = paint->innerColor; + outerCol = paint->outerColor; glnvg__xformInverse(invxform, paint->xform); glnvg__xformToMat3x3(paintMat, invxform); @@ -624,8 +616,8 @@ static int glnvg__setupPaint(struct GLNVGcontext* gl, struct NVGpaint* paint, st glUniform2f(gl->shader.loc[GLNVG_LOC_EXTENT], paint->extent[0], paint->extent[1]); glUniform1f(gl->shader.loc[GLNVG_LOC_RADIUS], paint->radius); glUniform1f(gl->shader.loc[GLNVG_LOC_FEATHER], paint->feather); - glUniform4fv(gl->shader.loc[GLNVG_LOC_INNERCOL], 1, innerCol); - glUniform4fv(gl->shader.loc[GLNVG_LOC_OUTERCOL], 1, outerCol); + glUniform4fv(gl->shader.loc[GLNVG_LOC_INNERCOL], 1, innerCol.rgba); + glUniform4fv(gl->shader.loc[GLNVG_LOC_OUTERCOL], 1, outerCol.rgba); glUniform1f(gl->shader.loc[GLNVG_LOC_STROKEMULT], (width*0.5f + fringe*0.5f)/fringe); glnvg__checkError("grad paint loc"); } @@ -858,7 +850,7 @@ static void glnvg__renderTriangles(void* uptr, struct NVGpaint* paint, struct NV { struct GLNVGcontext* gl = (struct GLNVGcontext*)uptr; struct GLNVGtexture* tex = glnvg__findTexture(gl, paint->image); - float color[4]; + struct NVGcolor color; NVG_NOTUSED(scissor); if (gl->shader.prog == 0) @@ -884,8 +876,8 @@ static void glnvg__renderTriangles(void* uptr, struct NVGpaint* paint, struct NV glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); - glnvg__toFloatColor(color, paint->innerColor); - glVertexAttrib4fv(2, color); + color = paint->innerColor; + glVertexAttrib4fv(2, color.rgba); glDrawArrays(GL_TRIANGLES, 0, nverts);