From: bohu Date: Mon, 13 Oct 2014 18:45:06 +0000 (-0700) Subject: Fix emulator crashes on glDrawElements command X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=52371ec4383b7654497e9f0a0994bae68a6899e9;p=android-x86%2Fdevice-generic-goldfish-opengl.git Fix emulator crashes on glDrawElements command The current implementation does not properly handle the case when glDrawElements is called without a buffer binded. This commit fixes this problem and fixes the crash. Change-Id: Ic7a5b2fb90c860dad878ed53a369349d479ba4e5 --- diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp index 0f5abdd..305806e 100644 --- a/system/GLESv2_enc/GL2Encoder.cpp +++ b/system/GLESv2_enc/GL2Encoder.cpp @@ -424,15 +424,15 @@ void GL2Encoder::sendVertexAttributes(GLint first, GLsizei count) int stride = state->stride == 0 ? state->elementSize : state->stride; int firstIndex = stride * first; + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, state->bufferObject); if (state->bufferObject == 0) { this->glVertexAttribPointerData(this, i, state->size, state->type, state->normalized, state->stride, (unsigned char *)state->data + firstIndex, datalen); } else { - this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, state->bufferObject); this->glVertexAttribPointerOffset(this, i, state->size, state->type, state->normalized, state->stride, (uintptr_t) state->data + firstIndex); - this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); } + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); } else { this->m_glDisableVertexAttribArray_enc(this, i); }