2013-06-27 14:07:21 -07: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/. */
|
|
|
|
|
|
|
|
#ifndef WEBGLVERTEXARRAY_H_
|
|
|
|
#define WEBGLVERTEXARRAY_H_
|
|
|
|
|
2014-05-06 20:11:18 -07:00
|
|
|
#include "WebGLBindableName.h"
|
2013-06-27 14:07:21 -07:00
|
|
|
#include "WebGLObjectModel.h"
|
2013-07-17 09:13:38 -07:00
|
|
|
#include "WebGLBuffer.h"
|
2013-06-27 14:07:21 -07:00
|
|
|
#include "WebGLVertexAttribData.h"
|
|
|
|
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-06-10 17:23:50 -07:00
|
|
|
class WebGLVertexArrayFake;
|
|
|
|
|
2014-06-05 16:38:27 -07:00
|
|
|
class WebGLVertexArray
|
2013-09-04 05:14:48 -07:00
|
|
|
: public nsWrapperCache
|
2014-09-18 16:14:22 -07:00
|
|
|
, public WebGLBindableName<GLenum>
|
2013-06-27 14:07:21 -07:00
|
|
|
, public WebGLRefCountedObject<WebGLVertexArray>
|
|
|
|
, public LinkedListElement<WebGLVertexArray>
|
|
|
|
, public WebGLContextBoundObject
|
|
|
|
{
|
2013-08-06 17:05:51 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// PUBLIC
|
2013-06-27 14:07:21 -07:00
|
|
|
public:
|
2014-06-05 16:38:27 -07:00
|
|
|
static WebGLVertexArray* Create(WebGLContext* context);
|
2013-08-06 17:05:51 -07:00
|
|
|
|
2014-06-05 16:38:27 -07:00
|
|
|
void BindVertexArray() {
|
2014-05-06 20:11:18 -07:00
|
|
|
/* Bind to dummy value to signal that this vertex array has
|
|
|
|
ever been bound */
|
|
|
|
BindTo(LOCAL_GL_VERTEX_ARRAY_BINDING);
|
2014-06-05 16:38:27 -07:00
|
|
|
BindVertexArrayImpl();
|
2013-06-27 14:07:21 -07:00
|
|
|
};
|
|
|
|
|
2014-06-05 16:38:27 -07:00
|
|
|
virtual void GenVertexArray() = 0;
|
|
|
|
virtual void BindVertexArrayImpl() = 0;
|
|
|
|
|
|
|
|
GLuint GLName() const { return mGLName; }
|
2013-06-27 14:07:21 -07:00
|
|
|
|
2013-08-06 17:05:51 -07:00
|
|
|
// -------------------------------------------------------------------------
|
2014-06-05 16:38:27 -07:00
|
|
|
// IMPLEMENT PARENT CLASSES
|
2013-08-06 17:05:51 -07:00
|
|
|
|
|
|
|
void Delete();
|
2013-06-27 14:07:21 -07:00
|
|
|
|
2014-06-05 16:38:27 -07:00
|
|
|
virtual void DeleteImpl() = 0;
|
|
|
|
|
2013-06-27 14:07:21 -07:00
|
|
|
WebGLContext* GetParentObject() const {
|
|
|
|
return Context();
|
|
|
|
}
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
|
2013-06-27 14:07:21 -07:00
|
|
|
|
2013-09-04 05:14:48 -07:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray)
|
2013-06-27 14:07:21 -07:00
|
|
|
|
2013-08-06 17:05:51 -07:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// MEMBER FUNCTIONS
|
|
|
|
|
2013-10-11 06:16:44 -07:00
|
|
|
bool EnsureAttrib(GLuint index, const char *info);
|
|
|
|
bool HasAttrib(GLuint index) {
|
|
|
|
return index < mAttribs.Length();
|
|
|
|
}
|
|
|
|
bool IsAttribArrayEnabled(GLuint index) {
|
|
|
|
return HasAttrib(index) && mAttribs[index].enabled;
|
|
|
|
}
|
2013-08-06 17:05:51 -07:00
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2014-06-05 16:38:27 -07:00
|
|
|
// PROTECTED
|
|
|
|
protected:
|
2014-09-01 15:26:43 -07:00
|
|
|
explicit WebGLVertexArray(WebGLContext* aContext);
|
2014-06-05 16:38:27 -07:00
|
|
|
|
|
|
|
virtual ~WebGLVertexArray() {
|
|
|
|
MOZ_ASSERT(IsDeleted());
|
|
|
|
};
|
2013-08-06 17:05:51 -07:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// MEMBERS
|
|
|
|
|
2013-10-11 06:16:44 -07:00
|
|
|
nsTArray<WebGLVertexAttribData> mAttribs;
|
2014-06-05 16:38:27 -07:00
|
|
|
WebGLRefPtr<WebGLBuffer> mElementArrayBuffer;
|
2013-08-06 17:05:51 -07:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// FRIENDSHIPS
|
|
|
|
|
2014-06-10 17:23:50 -07:00
|
|
|
friend class WebGLVertexArrayFake;
|
2013-06-27 14:07:21 -07:00
|
|
|
friend class WebGLContext;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|