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) {
|
2019-05-24 15:04:12 +03:00
|
|
|
if (mContext) {
|
|
|
|
mContext->ErrorInvalidOperation("%s: Extension is lost.",
|
|
|
|
"drawArraysInstancedANGLE");
|
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
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) {
|
2019-05-24 15:04:12 +03:00
|
|
|
if (mContext) {
|
|
|
|
mContext->ErrorInvalidOperation("%s: Extension is lost.",
|
|
|
|
"drawElementsInstancedANGLE");
|
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
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) {
|
2019-05-24 15:04:12 +03:00
|
|
|
if (mContext) {
|
|
|
|
mContext->ErrorInvalidOperation("%s: Extension is lost.",
|
|
|
|
"vertexAttribDivisorANGLE");
|
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
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) {
|
2019-02-05 06:34:49 +03:00
|
|
|
if (webgl->IsWebGL2()) return false;
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
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
|