2013-07-17 20:13:38 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; 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"
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
#include "GLContext.h"
|
2013-07-17 20:13:38 +04:00
|
|
|
#include "WebGLBuffer.h"
|
|
|
|
#include "WebGLVertexArray.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLVertexAttribData.h"
|
2013-07-17 20:13:38 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
namespace mozilla {
|
2013-07-17 20:13:38 +04:00
|
|
|
|
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::BindVertexArray(WebGLVertexArray* array)
|
2013-07-17 20:13:38 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-07-17 20:13:38 +04:00
|
|
|
return;
|
|
|
|
|
2016-11-30 05:30:28 +03:00
|
|
|
if (array && !ValidateObject("bindVertexArrayObject", *array))
|
2013-07-17 20:13:38 +04:00
|
|
|
return;
|
|
|
|
|
2016-12-29 11:08:39 +03:00
|
|
|
if (mBoundVertexArray) {
|
|
|
|
mBoundVertexArray->AddBufferBindCounts(-1);
|
|
|
|
}
|
|
|
|
|
2014-06-11 04:23:50 +04:00
|
|
|
if (array == nullptr) {
|
|
|
|
array = mDefaultVertexArray;
|
2013-07-17 20:13:38 +04:00
|
|
|
}
|
2014-06-06 03:38:27 +04:00
|
|
|
|
2014-06-11 04:23:50 +04:00
|
|
|
array->BindVertexArray();
|
|
|
|
|
|
|
|
MOZ_ASSERT(mBoundVertexArray == array);
|
2016-12-29 11:08:39 +03:00
|
|
|
if (mBoundVertexArray) {
|
|
|
|
mBoundVertexArray->AddBufferBindCounts(+1);
|
|
|
|
}
|
2013-07-17 20:13:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<WebGLVertexArray>
|
|
|
|
WebGLContext::CreateVertexArray()
|
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-07-17 20:13:38 +04:00
|
|
|
return nullptr;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<WebGLVertexArray> globj = CreateVertexArrayImpl();
|
2013-07-17 20:13:38 +04:00
|
|
|
|
2014-06-06 03:38:27 +04:00
|
|
|
globj->GenVertexArray();
|
2013-07-17 20:13:38 +04:00
|
|
|
|
|
|
|
return globj.forget();
|
|
|
|
}
|
|
|
|
|
2015-06-01 09:49:47 +03:00
|
|
|
WebGLVertexArray*
|
|
|
|
WebGLContext::CreateVertexArrayImpl()
|
|
|
|
{
|
|
|
|
return WebGLVertexArray::Create(this);
|
|
|
|
}
|
|
|
|
|
2013-07-17 20:13:38 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::DeleteVertexArray(WebGLVertexArray* array)
|
2013-07-17 20:13:38 +04:00
|
|
|
{
|
2016-11-30 05:30:28 +03:00
|
|
|
if (!ValidateDeleteObject("deleteVertexArray", array))
|
2013-07-17 20:13:38 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (mBoundVertexArray == array)
|
|
|
|
BindVertexArray(static_cast<WebGLVertexArray*>(nullptr));
|
|
|
|
|
|
|
|
array->RequestDelete();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-11-30 05:30:28 +03:00
|
|
|
WebGLContext::IsVertexArray(const WebGLVertexArray* array)
|
2013-07-17 20:13:38 +04:00
|
|
|
{
|
2016-11-30 05:30:28 +03:00
|
|
|
if (!ValidateIsObject("isVertexArray", array))
|
2015-05-21 02:58:36 +03:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return array->IsVertexArray();
|
2013-07-17 20:13:38 +04:00
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|