#ifndef WebGLVertexArrayObjectOES_h
#define WebGLVertexArrayObjectOES_h
#include "bindings/v8/ScriptWrappable.h"
#include "core/html/canvas/WebGLBuffer.h"
#include "core/html/canvas/WebGLContextObject.h"
#include "wtf/PassRefPtr.h"
namespace WebCore {
class WebGLVertexArrayObjectOES FINAL : public WebGLContextObject, public ScriptWrappable {
public:
enum VaoType {
VaoTypeDefault,
VaoTypeUser,
};
virtual ~WebGLVertexArrayObjectOES();
static PassRefPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContextBase*, VaoType);
struct VertexAttribState {
VertexAttribState()
: enabled(false)
, bytesPerElement(0)
, size(4)
, type(GL_FLOAT)
, normalized(false)
, stride(16)
, originalStride(0)
, offset(0)
, divisor(0)
{
}
bool enabled;
RefPtr<WebGLBuffer> bufferBinding;
GLsizei bytesPerElement;
GLint size;
GLenum type;
bool normalized;
GLsizei stride;
GLsizei originalStride;
GLintptr offset;
GLuint divisor;
};
bool isDefaultObject() const { return m_type == VaoTypeDefault; }
bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; }
void setHasEverBeenBound() { m_hasEverBeenBound = true; }
PassRefPtr<WebGLBuffer> boundElementArrayBuffer() const { return m_boundElementArrayBuffer; }
void setElementArrayBuffer(PassRefPtr<WebGLBuffer>);
VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
void setVertexAttribState(GLuint, GLsizei, GLint, GLenum, GLboolean, GLsizei, GLintptr, PassRefPtr<WebGLBuffer>);
void unbindBuffer(PassRefPtr<WebGLBuffer>);
void setVertexAttribDivisor(GLuint index, GLuint divisor);
private:
WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VaoType);
virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject) OVERRIDE;
VaoType m_type;
bool m_hasEverBeenBound;
RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
Vector<VertexAttribState> m_vertexAttribState;
};
}
#endif