WebGLVertexArrayObjectBase.h [plain text]
#pragma once
#include "WebGLBuffer.h"
#include "WebGLContextObject.h"
namespace WebCore {
class WebGLVertexArrayObjectBase : public WebGLContextObject {
public:
enum VAOType {
VAOTypeDefault,
VAOTypeUser,
};
virtual ~WebGLVertexArrayObjectBase() { }
struct VertexAttribState {
VertexAttribState()
: enabled(false)
, bytesPerElement(0)
, size(4)
, type(GraphicsContext3D::FLOAT)
, normalized(false)
, stride(16)
, originalStride(0)
, offset(0)
, divisor(0)
{
}
bool isBound() const { return bufferBinding && bufferBinding->object(); }
bool validateBinding() const { return !enabled || isBound(); }
bool enabled;
RefPtr<WebGLBuffer> bufferBinding;
GC3Dsizei bytesPerElement;
GC3Dint size;
GC3Denum type;
bool normalized;
GC3Dsizei stride;
GC3Dsizei originalStride;
GC3Dintptr offset;
GC3Duint divisor;
};
bool isDefaultObject() const { return m_type == VAOTypeDefault; }
bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; }
void setHasEverBeenBound() { m_hasEverBeenBound = true; }
PassRefPtr<WebGLBuffer> getElementArrayBuffer() const { return m_boundElementArrayBuffer; }
void setElementArrayBuffer(PassRefPtr<WebGLBuffer>);
VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
void setVertexAttribState(GC3Duint, GC3Dsizei, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr, PassRefPtr<WebGLBuffer>);
void unbindBuffer(PassRefPtr<WebGLBuffer>);
void setVertexAttribDivisor(GC3Duint index, GC3Duint divisor);
protected:
WebGLVertexArrayObjectBase(WebGLRenderingContextBase&, VAOType);
void deleteObjectImpl(GraphicsContext3D*, Platform3DObject) override = 0;
VAOType m_type;
bool m_hasEverBeenBound;
RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
Vector<VertexAttribState> m_vertexAttribState;
};
}