2013-06-27 21:07:21 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* 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 "WebGLContext.h"
|
|
|
|
#include "WebGLBuffer.h"
|
|
|
|
#include "WebGLVertexArray.h"
|
|
|
|
#include "WebGLExtensions.h"
|
|
|
|
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
2013-09-04 12:14:52 +00:00
|
|
|
#include "GLContext.h"
|
2013-06-27 21:07:21 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
|
|
|
WebGLExtensionVertexArray::WebGLExtensionVertexArray(WebGLContext* context)
|
|
|
|
: WebGLExtensionBase(context)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsSupported(context), "should not construct WebGLExtensionVertexArray :"
|
|
|
|
"OES_vertex_array_object unsuported.");
|
|
|
|
}
|
|
|
|
|
|
|
|
WebGLExtensionVertexArray::~WebGLExtensionVertexArray()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<WebGLVertexArray> WebGLExtensionVertexArray::CreateVertexArrayOES()
|
|
|
|
{
|
2014-03-12 02:51:39 +00:00
|
|
|
if (mIsLost) {
|
2014-07-28 20:42:02 +00:00
|
|
|
mContext->GenerateWarning("createVertexArrayOES: Extension is lost. Returning null.");
|
2014-03-12 02:51:39 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-06-27 21:07:21 +00:00
|
|
|
return mContext->CreateVertexArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
|
|
|
|
{
|
2014-03-12 02:51:39 +00:00
|
|
|
if (mIsLost)
|
2014-07-28 20:42:02 +00:00
|
|
|
return mContext->GenerateWarning("deleteVertexArrayOES: Extension is lost.");
|
2014-03-12 02:51:39 +00:00
|
|
|
|
2013-06-27 21:07:21 +00:00
|
|
|
mContext->DeleteVertexArray(array);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array)
|
|
|
|
{
|
2014-03-12 02:51:39 +00:00
|
|
|
if (mIsLost) {
|
2014-07-28 20:42:02 +00:00
|
|
|
mContext->GenerateWarning("isVertexArrayOES: Extension is lost. Returning false.");
|
2014-03-12 02:51:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-27 21:07:21 +00:00
|
|
|
return mContext->IsVertexArray(array);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array)
|
|
|
|
{
|
2014-03-12 02:51:39 +00:00
|
|
|
if (mIsLost)
|
2014-07-28 20:42:02 +00:00
|
|
|
return mContext->GenerateWarning("bindVertexArrayOES: Extension is lost.");
|
2014-03-12 02:51:39 +00:00
|
|
|
|
2013-06-27 21:07:21 +00:00
|
|
|
mContext->BindVertexArray(array);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebGLExtensionVertexArray::IsSupported(const WebGLContext* context)
|
|
|
|
{
|
2014-06-05 23:38:27 +00:00
|
|
|
// If it is not supported then it's emulated, therefore it's always 'supported'
|
|
|
|
// See - WebGLVertexArrayFake.h/cpp for the emulation
|
|
|
|
return true;
|
2013-06-27 21:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionVertexArray)
|