opengles Translator: DrawTex impl - don't draw if no textures enabled.
This fixes a crash caused by covgl (on Nvidia linux driver) when our implementation
of glDrawTexOES calls glDrawArrays with GL_TEXTURE_COORD_ARRAY enabled - but none of texture
units are enabled and no data passed by glTexCoordPointer
Change-Id: Id28b0c35a5a17b139ab196db0e434d2f0a490132
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
index 17f8150..0f2c2c9 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -1946,6 +1946,7 @@
x+width, y+height, z,
x+width, y, z};
GLfloat texels[ctx->getMaxTexUnits()][4*2];
+ memset((void*)texels, 0, ctx->getMaxTexUnits()*4*2*sizeof(GLfloat));
ctx->dispatcher().glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
ctx->dispatcher().glPushAttrib(GL_TRANSFORM_BIT);
@@ -1976,6 +1977,7 @@
for (int i=0;i<numClipPlanes;++i)
ctx->dispatcher().glDisable(GL_CLIP_PLANE0+i);
+ int nTexPtrs = 0;
for (int i=0;i<ctx->getMaxTexUnits();++i) {
if (ctx->isTextureUnitEnabled(GL_TEXTURE0+i)) {
TextureData * texData = NULL;
@@ -1998,15 +2000,18 @@
texels[i][7] = (float)(texData->crop_rect[1])/(float)(texData->height);
ctx->dispatcher().glTexCoordPointer(2,GL_FLOAT,0,texels[i]);
+ nTexPtrs++;
}
}
}
- //draw rectangle
- ctx->dispatcher().glEnableClientState(GL_VERTEX_ARRAY);
- ctx->dispatcher().glVertexPointer(3,TypeName,0,vertices);
- ctx->dispatcher().glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- ctx->dispatcher().glDrawArrays(GL_TRIANGLE_FAN,0,4);
+ if (nTexPtrs>0) {
+ //draw rectangle - only if we have some textures enabled & ready
+ ctx->dispatcher().glEnableClientState(GL_VERTEX_ARRAY);
+ ctx->dispatcher().glVertexPointer(3,TypeName,0,vertices);
+ ctx->dispatcher().glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ ctx->dispatcher().glDrawArrays(GL_TRIANGLE_FAN,0,4);
+ }
//restore vbo's
ctx->dispatcher().glBindBuffer(GL_ARRAY_BUFFER,array_buffer);