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