Tweaks to GL ES
- use nvgCreateGLES2() instead of nvgCreateGL2() when NANOVG_GLES2 is specified (ditto for gl3) - use GL_RED instead of GL_LUMINANCE in ES3
This commit is contained in:
parent
ecb0a9c394
commit
8cb6eea358
@ -73,7 +73,7 @@ int main()
|
|||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
vg = nvgCreateGL2(512, 512, NVG_ANTIALIAS);
|
vg = nvgCreateGLES2(512, 512, NVG_ANTIALIAS);
|
||||||
if (vg == NULL) {
|
if (vg == NULL) {
|
||||||
printf("Could not init nanovg.\n");
|
printf("Could not init nanovg.\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -122,7 +122,7 @@ int main()
|
|||||||
|
|
||||||
freeDemoData(vg, &data);
|
freeDemoData(vg, &data);
|
||||||
|
|
||||||
nvgDeleteGL2(vg);
|
nvgDeleteGLES2(vg);
|
||||||
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -73,7 +73,7 @@ int main()
|
|||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
vg = nvgCreateGL3(512, 512, NVG_ANTIALIAS);
|
vg = nvgCreateGLES3(512, 512, NVG_ANTIALIAS);
|
||||||
if (vg == NULL) {
|
if (vg == NULL) {
|
||||||
printf("Could not init nanovg.\n");
|
printf("Could not init nanovg.\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -122,7 +122,7 @@ int main()
|
|||||||
|
|
||||||
freeDemoData(vg, &data);
|
freeDemoData(vg, &data);
|
||||||
|
|
||||||
nvgDeleteGL3(vg);
|
nvgDeleteGLES3(vg);
|
||||||
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -24,9 +24,19 @@ extern "C" {
|
|||||||
|
|
||||||
#define NVG_ANTIALIAS 1
|
#define NVG_ANTIALIAS 1
|
||||||
|
|
||||||
|
#ifdef NANOVG_GLES2
|
||||||
|
|
||||||
|
struct NVGcontext* nvgCreateGLES2(int atlasw, int atlash, int edgeaa);
|
||||||
|
void nvgDeleteGLES2(struct NVGcontext* ctx);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
struct NVGcontext* nvgCreateGL2(int atlasw, int atlash, int edgeaa);
|
struct NVGcontext* nvgCreateGL2(int atlasw, int atlash, int edgeaa);
|
||||||
void nvgDeleteGL2(struct NVGcontext* ctx);
|
void nvgDeleteGL2(struct NVGcontext* ctx);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -854,7 +864,11 @@ static void glnvg__renderDelete(void* uptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NANOVG_GLES2
|
||||||
|
struct NVGcontext* nvgCreateGLES2(int atlasw, int atlash, int edgeaa)
|
||||||
|
#else
|
||||||
struct NVGcontext* nvgCreateGL2(int atlasw, int atlash, int edgeaa)
|
struct NVGcontext* nvgCreateGL2(int atlasw, int atlash, int edgeaa)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct NVGparams params;
|
struct NVGparams params;
|
||||||
struct NVGcontext* ctx = NULL;
|
struct NVGcontext* ctx = NULL;
|
||||||
@ -891,7 +905,11 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NANOVG_GLES2
|
||||||
|
void nvgDeleteGLES2(struct NVGcontext* ctx)
|
||||||
|
#else
|
||||||
void nvgDeleteGL2(struct NVGcontext* ctx)
|
void nvgDeleteGL2(struct NVGcontext* ctx)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
nvgDeleteInternal(ctx);
|
nvgDeleteInternal(ctx);
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,18 @@ extern "C" {
|
|||||||
|
|
||||||
#define NVG_ANTIALIAS 1
|
#define NVG_ANTIALIAS 1
|
||||||
|
|
||||||
|
#ifdef NANOVG_GLES3
|
||||||
|
|
||||||
|
struct NVGcontext* nvgCreateGLES3(int atlasw, int atlash, int edgeaa);
|
||||||
|
void nvgDeleteGLES3(struct NVGcontext* ctx);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
struct NVGcontext* nvgCreateGL3(int atlasw, int atlash, int edgeaa);
|
struct NVGcontext* nvgCreateGL3(int atlasw, int atlash, int edgeaa);
|
||||||
void nvgDeleteGL3(struct NVGcontext* ctx);
|
void nvgDeleteGL3(struct NVGcontext* ctx);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -444,11 +453,7 @@ static int glnvg__renderCreateTexture(void* uptr, int type, int w, int h, const
|
|||||||
if (type == NVG_TEXTURE_RGBA)
|
if (type == NVG_TEXTURE_RGBA)
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||||
else
|
else
|
||||||
#ifdef NANOVG_GLES3
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, w, h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
|
|
||||||
#else
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, data);
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
@ -481,11 +486,7 @@ static int glnvg__renderUpdateTexture(void* uptr, int image, int x, int y, int w
|
|||||||
if (tex->type == NVG_TEXTURE_RGBA)
|
if (tex->type == NVG_TEXTURE_RGBA)
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||||
else
|
else
|
||||||
#ifdef NANOVG_GLES3
|
|
||||||
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);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RED, GL_UNSIGNED_BYTE, data);
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -869,7 +870,11 @@ static void glnvg__renderDelete(void* uptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NANOVG_GLES3
|
||||||
|
struct NVGcontext* nvgCreateGLES3(int atlasw, int atlash, int edgeaa)
|
||||||
|
#else
|
||||||
struct NVGcontext* nvgCreateGL3(int atlasw, int atlash, int edgeaa)
|
struct NVGcontext* nvgCreateGL3(int atlasw, int atlash, int edgeaa)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct NVGparams params;
|
struct NVGparams params;
|
||||||
struct NVGcontext* ctx = NULL;
|
struct NVGcontext* ctx = NULL;
|
||||||
@ -906,7 +911,11 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NANOVG_GLES3
|
||||||
|
void nvgDeleteGLES3(struct NVGcontext* ctx)
|
||||||
|
#else
|
||||||
void nvgDeleteGL3(struct NVGcontext* ctx)
|
void nvgDeleteGL3(struct NVGcontext* ctx)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
nvgDeleteInternal(ctx);
|
nvgDeleteInternal(ctx);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user