|
1 /* -*- Mode: C++; tab-width: 20; 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/. */ |
|
5 |
|
6 #include "WebGLContext.h" |
|
7 #include "WebGLBuffer.h" |
|
8 #include "WebGLVertexArray.h" |
|
9 #include "WebGLExtensions.h" |
|
10 #include "mozilla/dom/WebGLRenderingContextBinding.h" |
|
11 #include "GLContext.h" |
|
12 |
|
13 using namespace mozilla; |
|
14 |
|
15 WebGLExtensionVertexArray::WebGLExtensionVertexArray(WebGLContext* context) |
|
16 : WebGLExtensionBase(context) |
|
17 { |
|
18 MOZ_ASSERT(IsSupported(context), "should not construct WebGLExtensionVertexArray :" |
|
19 "OES_vertex_array_object unsuported."); |
|
20 } |
|
21 |
|
22 WebGLExtensionVertexArray::~WebGLExtensionVertexArray() |
|
23 { |
|
24 } |
|
25 |
|
26 already_AddRefed<WebGLVertexArray> WebGLExtensionVertexArray::CreateVertexArrayOES() |
|
27 { |
|
28 if (mIsLost) { |
|
29 mContext->ErrorInvalidOperation("createVertexArrayOES: Extension is lost. Returning NULL."); |
|
30 return nullptr; |
|
31 } |
|
32 |
|
33 return mContext->CreateVertexArray(); |
|
34 } |
|
35 |
|
36 void WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array) |
|
37 { |
|
38 if (mIsLost) |
|
39 return mContext->ErrorInvalidOperation("deleteVertexArrayOES: Extension is lost."); |
|
40 |
|
41 mContext->DeleteVertexArray(array); |
|
42 } |
|
43 |
|
44 bool WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array) |
|
45 { |
|
46 if (mIsLost) { |
|
47 mContext->ErrorInvalidOperation("isVertexArrayOES: Extension is lost. Returning false."); |
|
48 return false; |
|
49 } |
|
50 |
|
51 return mContext->IsVertexArray(array); |
|
52 } |
|
53 |
|
54 void WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array) |
|
55 { |
|
56 if (mIsLost) |
|
57 return mContext->ErrorInvalidOperation("bindVertexArrayOES: Extension is lost."); |
|
58 |
|
59 mContext->BindVertexArray(array); |
|
60 } |
|
61 |
|
62 bool WebGLExtensionVertexArray::IsSupported(const WebGLContext* context) |
|
63 { |
|
64 gl::GLContext* gl = context->GL(); |
|
65 |
|
66 return gl->IsSupported(gl::GLFeature::vertex_array_object); |
|
67 } |
|
68 |
|
69 IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionVertexArray) |