Fix glGetStringi
Change-Id: Ibccbbbe4122c96386ca4de2df505f1e350bd9bed
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp
index a7ff5c1..31f2c2a 100755
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -636,6 +636,9 @@
GLClientState* state = ctx->m_state;
switch (param) {
+ case GL_NUM_EXTENSIONS:
+ *ptr = (int)ctx->m_currExtensionsArray.size();
+ break;
case GL_MAJOR_VERSION:
*ptr = ctx->m_deviceMajorVersion;
break;
@@ -3901,7 +3904,7 @@
const GLubyte* GL2Encoder::s_glGetStringi(void* self, GLenum name, GLuint index) {
GL2Encoder *ctx = (GL2Encoder *)self;
- GLubyte *retval = (GLubyte *) "";
+ const GLubyte *retval = (GLubyte *) "";
RET_AND_SET_ERROR_IF(
name != GL_VENDOR &&
@@ -3915,11 +3918,16 @@
name == GL_VENDOR ||
name == GL_RENDERER ||
name == GL_VERSION ||
- name == GL_EXTENSIONS &&
index != 0,
GL_INVALID_VALUE,
retval);
+ RET_AND_SET_ERROR_IF(
+ name == GL_EXTENSIONS &&
+ index >= ctx->m_currExtensionsArray.size(),
+ GL_INVALID_VALUE,
+ retval);
+
switch (name) {
case GL_VENDOR:
retval = gVendorString;
@@ -3931,7 +3939,7 @@
retval = gVersionString;
break;
case GL_EXTENSIONS:
- retval = gExtensionsString;
+ retval = (const GLubyte*)(ctx->m_currExtensionsArray[index].c_str());
break;
}