2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2013-08-14 02:11:01 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "WebGLExtensions.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
#include "GLContext.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
|
|
|
#include "WebGLContext.h"
|
2013-08-14 02:11:01 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
namespace mozilla {
|
2013-08-14 02:11:01 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLExtensionInstancedArrays::WebGLExtensionInstancedArrays(
|
|
|
|
WebGLContext* webgl)
|
|
|
|
: WebGLExtensionBase(webgl) {
|
|
|
|
MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
|
2013-08-14 02:11:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WebGLExtensionInstancedArrays::~WebGLExtensionInstancedArrays() {}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(
|
|
|
|
GLenum mode, GLint first, GLsizei count, GLsizei primcount) {
|
|
|
|
if (mIsLost) {
|
|
|
|
mContext->ErrorInvalidOperation("%s: Extension is lost.",
|
|
|
|
"drawArraysInstancedANGLE");
|
|
|
|
return;
|
|
|
|
}
|
2014-03-12 06:51:39 +04:00
|
|
|
|
2013-08-14 02:11:01 +04:00
|
|
|
mContext->DrawArraysInstanced(mode, first, count, primcount);
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void WebGLExtensionInstancedArrays::DrawElementsInstancedANGLE(
|
|
|
|
GLenum mode, GLsizei count, GLenum type, WebGLintptr offset,
|
2013-09-04 16:14:43 +04:00
|
|
|
GLsizei primcount) {
|
2014-11-14 07:03:50 +03:00
|
|
|
if (mIsLost) {
|
|
|
|
mContext->ErrorInvalidOperation("%s: Extension is lost.",
|
|
|
|
"drawElementsInstancedANGLE");
|
|
|
|
return;
|
|
|
|
}
|
2014-03-12 06:51:39 +04:00
|
|
|
|
2013-08-14 02:11:01 +04:00
|
|
|
mContext->DrawElementsInstanced(mode, count, type, offset, primcount);
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(GLuint index,
|
|
|
|
GLuint divisor) {
|
|
|
|
if (mIsLost) {
|
|
|
|
mContext->ErrorInvalidOperation("%s: Extension is lost.",
|
|
|
|
"vertexAttribDivisorANGLE");
|
|
|
|
return;
|
|
|
|
}
|
2014-03-12 06:51:39 +04:00
|
|
|
|
2013-08-14 02:11:01 +04:00
|
|
|
mContext->VertexAttribDivisor(index, divisor);
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool WebGLExtensionInstancedArrays::IsSupported(const WebGLContext* webgl) {
|
|
|
|
gl::GLContext* gl = webgl->GL();
|
2013-08-22 21:42:05 +04:00
|
|
|
return gl->IsSupported(gl::GLFeature::draw_instanced) &&
|
|
|
|
gl->IsSupported(gl::GLFeature::instanced_arrays);
|
2013-08-14 02:11:01 +04:00
|
|
|
}
|
|
|
|
|
2015-06-01 17:17:00 +03:00
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionInstancedArrays, ANGLE_instanced_arrays)
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|