diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp index 17ec52f1e..2a4a2d375 100644 --- a/src/libGLESv2/Context.cpp +++ b/src/libGLESv2/Context.cpp @@ -776,6 +776,9 @@ GLuint Context::createVertexArray() { GLuint handle = mVertexArrayHandleAllocator.allocate(); + // Although the spec states VAO state is not initialized until the object is bound, + // we create it immediately. The resulting behaviour is transparent to the application, + // since it's not currently possible to access the state until the object is bound. mVertexArrayMap[handle] = new VertexArray(mRenderer, handle); return handle; diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp index 89672bd78..e860dd6a0 100644 --- a/src/libGLESv2/libGLESv2.cpp +++ b/src/libGLESv2/libGLESv2.cpp @@ -9186,8 +9186,16 @@ void __stdcall glBindVertexArray(GLuint array) return gl::error(GL_INVALID_OPERATION); } - // glBindVertexArray - UNIMPLEMENTED(); + gl::VertexArray *vao = context->getVertexArray(array); + + if (!vao) + { + // The default VAO should always exist + ASSERT(array != 0); + return gl::error(GL_INVALID_OPERATION); + } + + context->bindVertexArray(array); } } catch(std::bad_alloc&) @@ -9211,8 +9219,18 @@ void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) return gl::error(GL_INVALID_OPERATION); } - // glDeleteVertexArrays - UNIMPLEMENTED(); + if (n < 0) + { + return gl::error(GL_INVALID_VALUE); + } + + for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) + { + if (arrays[arrayIndex] != 0) + { + context->deleteVertexArray(arrays[arrayIndex]); + } + } } } catch(std::bad_alloc&) @@ -9236,8 +9254,15 @@ void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) return gl::error(GL_INVALID_OPERATION); } - // glGenVertexArrays - UNIMPLEMENTED(); + if (n < 0) + { + return gl::error(GL_INVALID_VALUE); + } + + for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) + { + arrays[arrayIndex] = context->createVertexArray(); + } } } catch(std::bad_alloc&) @@ -9261,8 +9286,14 @@ GLboolean __stdcall glIsVertexArray(GLuint array) return gl::error(GL_INVALID_OPERATION, GL_FALSE); } - // glIsVertexArray - UNIMPLEMENTED(); + if (array == 0) + { + return GL_FALSE; + } + + gl::VertexArray *vao = context->getVertexArray(array); + + return (vao != NULL ? GL_TRUE : GL_FALSE); } } catch(std::bad_alloc&)