1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "WebGLContext.h"
9 #include "WebGLBuffer.h"
10 #include "WebGLVertexArray.h"
11 #include "WebGLVertexAttribData.h"
16 WebGLContext::BindVertexArray(WebGLVertexArray
* array
)
21 if (!ValidateObjectAllowDeletedOrNull("bindVertexArrayObject", array
))
24 if (array
&& array
->IsDeleted()) {
25 /* http://www.khronos.org/registry/gles/extensions/OES/OES_vertex_array_object.txt
26 * BindVertexArrayOES fails and an INVALID_OPERATION error is
27 * generated if array is not a name returned from a previous call to
28 * GenVertexArraysOES, or if such a name has since been deleted with
29 * DeleteVertexArraysOES
31 ErrorInvalidOperation("bindVertexArray: can't bind a deleted array!");
35 InvalidateBufferFetching();
39 if (array
== nullptr) {
40 array
= mDefaultVertexArray
;
43 array
->BindVertexArray();
45 MOZ_ASSERT(mBoundVertexArray
== array
);
48 already_AddRefed
<WebGLVertexArray
>
49 WebGLContext::CreateVertexArray()
54 nsRefPtr
<WebGLVertexArray
> globj
= WebGLVertexArray::Create(this);
57 globj
->GenVertexArray();
59 return globj
.forget();
63 WebGLContext::DeleteVertexArray(WebGLVertexArray
* array
)
71 if (array
->IsDeleted())
74 if (mBoundVertexArray
== array
)
75 BindVertexArray(static_cast<WebGLVertexArray
*>(nullptr));
77 array
->RequestDelete();
81 WebGLContext::IsVertexArray(WebGLVertexArray
* array
)
89 return ValidateObjectAllowDeleted("isVertexArray", array
) &&
90 !array
->IsDeleted() &&
91 array
->HasEverBeenBound();
94 } // namespace mozilla