summaryrefslogtreecommitdiffstats
path: root/opengl
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2014-11-06 18:08:07 -0800
committerbohu <bohu@google.com>2014-11-06 18:09:19 -0800
commit5fa17220c5f91d5ce2dc9737d6dc38edfe6d547d (patch)
tree128f4328560b6e0788fa0133c0c371657abd4f83 /opengl
parent3fe2263e2429a0611796e3e84c6f8b54bc30aa48 (diff)
downloadandroid_device_generic_goldfish-5fa17220c5f91d5ce2dc9737d6dc38edfe6d547d.tar.gz
android_device_generic_goldfish-5fa17220c5f91d5ce2dc9737d6dc38edfe6d547d.tar.bz2
android_device_generic_goldfish-5fa17220c5f91d5ce2dc9737d6dc38edfe6d547d.zip
Unbind buffer when buffer is deleted
When buffer is deleted, it should be un-bind also. Also fix error code related to buffer Change-Id: I3e7ec88399822469a36119c2de03157a2bbea812
Diffstat (limited to 'opengl')
-rw-r--r--opengl/shared/OpenglCodecCommon/GLClientState.h6
-rw-r--r--opengl/system/GLESv2_enc/GL2Encoder.cpp3
2 files changed, 9 insertions, 0 deletions
diff --git a/opengl/shared/OpenglCodecCommon/GLClientState.h b/opengl/shared/OpenglCodecCommon/GLClientState.h
index c86329b..09ee571 100644
--- a/opengl/shared/OpenglCodecCommon/GLClientState.h
+++ b/opengl/shared/OpenglCodecCommon/GLClientState.h
@@ -91,6 +91,12 @@ public:
void setActiveTexture(int texUnit) {m_activeTexture = texUnit; };
int getActiveTexture() const { return m_activeTexture; }
+ void unBindBuffer(GLuint id)
+ {
+ if (m_currentArrayVbo == id) m_currentArrayVbo = 0;
+ else if (m_currentIndexVbo == id) m_currentIndexVbo = 0;
+ }
+
int bindBuffer(GLenum target, GLuint id)
{
int err = 0;
diff --git a/opengl/system/GLESv2_enc/GL2Encoder.cpp b/opengl/system/GLESv2_enc/GL2Encoder.cpp
index 9490571..20e4063 100644
--- a/opengl/system/GLESv2_enc/GL2Encoder.cpp
+++ b/opengl/system/GLESv2_enc/GL2Encoder.cpp
@@ -191,6 +191,7 @@ void GL2Encoder::s_glBindBuffer(void *self, GLenum target, GLuint id)
void GL2Encoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage)
{
GL2Encoder *ctx = (GL2Encoder *) self;
+ SET_ERROR_IF(!(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER), GL_INVALID_ENUM);
GLuint bufferId = ctx->m_state->getBuffer(target);
SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION);
SET_ERROR_IF(size<0, GL_INVALID_VALUE);
@@ -202,6 +203,7 @@ void GL2Encoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, con
void GL2Encoder::s_glBufferSubData(void * self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data)
{
GL2Encoder *ctx = (GL2Encoder *) self;
+ SET_ERROR_IF(!(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER), GL_INVALID_ENUM);
GLuint bufferId = ctx->m_state->getBuffer(target);
SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION);
@@ -217,6 +219,7 @@ void GL2Encoder::s_glDeleteBuffers(void * self, GLsizei n, const GLuint * buffer
SET_ERROR_IF(n<0, GL_INVALID_VALUE);
for (int i=0; i<n; i++) {
ctx->m_shared->deleteBufferData(buffers[i]);
+ ctx->m_state->unBindBuffer(buffers[i]);
ctx->m_glDeleteBuffers_enc(self,1,&buffers[i]);
}
}