OESVertexArrayObject.cpp [plain text]
#include "config.h"
#if ENABLE(WEBGL)
#include "OESVertexArrayObject.h"
#include "Extensions3D.h"
namespace WebCore {
OESVertexArrayObject::OESVertexArrayObject(WebGLRenderingContext* context)
: WebGLExtension(context)
{
}
OESVertexArrayObject::~OESVertexArrayObject()
{
}
WebGLExtension::ExtensionName OESVertexArrayObject::getName() const
{
return OESVertexArrayObjectName;
}
PassRefPtr<WebGLVertexArrayObjectOES> OESVertexArrayObject::createVertexArrayOES()
{
if (m_context->isContextLost())
return 0;
RefPtr<WebGLVertexArrayObjectOES> o = WebGLVertexArrayObjectOES::create(m_context, WebGLVertexArrayObjectOES::VaoTypeUser);
m_context->addContextObject(o.get());
return o.release();
}
void OESVertexArrayObject::deleteVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject)
{
if (!arrayObject || m_context->isContextLost())
return;
if (!arrayObject->isDefaultObject() && arrayObject == m_context->m_boundVertexArrayObject)
m_context->setBoundVertexArrayObject(0);
arrayObject->deleteObject(m_context->graphicsContext3D());
}
GC3Dboolean OESVertexArrayObject::isVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject)
{
if (!arrayObject || m_context->isContextLost())
return 0;
if (!arrayObject->hasEverBeenBound())
return 0;
Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions();
return extensions->isVertexArrayOES(arrayObject->object());
}
void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (m_context->isContextLost())
return;
if (arrayObject && (arrayObject->isDeleted() || !arrayObject->validate(0, context()))) {
m_context->graphicsContext3D()->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions();
if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) {
extensions->bindVertexArrayOES(arrayObject->object());
arrayObject->setHasEverBeenBound();
m_context->setBoundVertexArrayObject(arrayObject);
} else {
extensions->bindVertexArrayOES(0);
m_context->setBoundVertexArrayObject(0);
}
}
}
#endif // ENABLE(WEBGL)