Browse Source

Bind a dummy texture in setUniforms when compiling with emscripten

fixes the WebGL error "RENDER WARNING: there is no texture bound to the unit 0"" in Chrome
shared-context
Oli Larkin 5 years ago
parent
commit
d98041b4ee
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      src/nanovg_gl.h

+ 16
- 0
src/nanovg_gl.h View File

@@ -268,6 +268,10 @@ struct GLNVGcontext {
GLuint stencilFuncMask;
GLNVGblend blendFunc;
#endif

#ifdef __EMSCRIPTEN__
int dummyTex;
#endif
};
typedef struct GLNVGcontext GLNVGcontext;

@@ -704,6 +708,10 @@ static int glnvg__renderCreate(void* uptr)

glFinish();

#ifdef __EMSCRIPTEN__
gl->dummyTex = 0;
#endif

return 1;
}

@@ -985,7 +993,15 @@ static void glnvg__setUniforms(GLNVGcontext* gl, int uniformOffset, int image)
glnvg__bindTexture(gl, tex != NULL ? tex->tex : 0);
glnvg__checkError(gl, "tex paint tex");
} else {
#ifdef __EMSCRIPTEN__
if(gl->dummyTex == 0) {
gl->dummyTex = glnvg__renderCreateTexture(&gl, NVG_TEXTURE_ALPHA, 2, 2, 0, NULL);
}
GLNVGtexture* tex = glnvg__findTexture(gl, gl->dummyTex);
glnvg__bindTexture(gl, tex->tex);
#else
glnvg__bindTexture(gl, 0);
#endif
}
}



Loading…
Cancel
Save