|
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 "WebGLExtensions.h" |
|
8 #include "mozilla/dom/WebGLRenderingContextBinding.h" |
|
9 #include "GLContext.h" |
|
10 |
|
11 using namespace mozilla; |
|
12 |
|
13 WebGLExtensionInstancedArrays::WebGLExtensionInstancedArrays(WebGLContext* context) |
|
14 : WebGLExtensionBase(context) |
|
15 { |
|
16 MOZ_ASSERT(IsSupported(context), "should not construct WebGLExtensionInstancedArrays: " |
|
17 "ANGLE_instanced_arrays unsupported."); |
|
18 } |
|
19 |
|
20 WebGLExtensionInstancedArrays::~WebGLExtensionInstancedArrays() |
|
21 { |
|
22 } |
|
23 |
|
24 void |
|
25 WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(GLenum mode, GLint first, |
|
26 GLsizei count, GLsizei primcount) |
|
27 { |
|
28 if (mIsLost) |
|
29 return mContext->ErrorInvalidOperation("drawArraysInstancedANGLE: Extension is lost."); |
|
30 |
|
31 mContext->DrawArraysInstanced(mode, first, count, primcount); |
|
32 } |
|
33 |
|
34 void |
|
35 WebGLExtensionInstancedArrays::DrawElementsInstancedANGLE(GLenum mode, GLsizei count, |
|
36 GLenum type, WebGLintptr offset, |
|
37 GLsizei primcount) |
|
38 { |
|
39 if (mIsLost) |
|
40 return mContext->ErrorInvalidOperation("drawElementsInstancedANGLE: Extension is lost."); |
|
41 |
|
42 mContext->DrawElementsInstanced(mode, count, type, offset, primcount); |
|
43 } |
|
44 |
|
45 void |
|
46 WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
|
47 { |
|
48 if (mIsLost) |
|
49 return mContext->ErrorInvalidOperation("vertexAttribDivisorANGLE: Extension is lost."); |
|
50 |
|
51 mContext->VertexAttribDivisor(index, divisor); |
|
52 } |
|
53 |
|
54 bool |
|
55 WebGLExtensionInstancedArrays::IsSupported(const WebGLContext* context) |
|
56 { |
|
57 gl::GLContext* gl = context->GL(); |
|
58 |
|
59 return gl->IsSupported(gl::GLFeature::draw_instanced) && |
|
60 gl->IsSupported(gl::GLFeature::instanced_arrays); |
|
61 } |
|
62 |
|
63 IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionInstancedArrays) |