From ee1e66e7218c15efe0e508b88096c411a810c8b9 Mon Sep 17 00:00:00 2001 From: Andrew Corrigan Date: Mon, 21 Apr 2014 21:35:51 -0400 Subject: [PATCH] fixes texture formats for GLES2/GLES3 --- src/nanovg_gl.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/nanovg_gl.h b/src/nanovg_gl.h index 26c227c..7c8d5ae 100644 --- a/src/nanovg_gl.h +++ b/src/nanovg_gl.h @@ -593,7 +593,13 @@ static int glnvg__renderCreateTexture(void* uptr, int type, int w, int h, const if (type == NVG_TEXTURE_RGBA) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); else +#if defined(NANOVG_GLES2) + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, w, h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); +#elif defined(NANOVG_GLES3) + glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, data); +#else glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, data); +#endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -647,7 +653,11 @@ static int glnvg__renderUpdateTexture(void* uptr, int image, int x, int y, int w if (tex->type == NVG_TEXTURE_RGBA) glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RGBA, GL_UNSIGNED_BYTE, data); else +#ifdef NANOVG_GLES2 + glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); +#else glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RED, GL_UNSIGNED_BYTE, data); +#endif glPixelStorei(GL_UNPACK_ALIGNMENT, 4); #ifndef NANOVG_GLES2