2012-11-29 10:04:26 +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
|
2013-06-11 00:00:35 +04:00
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#ifndef WEBGL_VERTEX_ATTRIB_DATA_H_
|
|
|
|
#define WEBGL_VERTEX_ATTRIB_DATA_H_
|
|
|
|
|
|
|
|
#include "GLDefs.h"
|
|
|
|
#include "WebGLObjectModel.h"
|
2013-06-11 00:00:35 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class WebGLBuffer;
|
|
|
|
|
2016-09-24 03:28:58 +03:00
|
|
|
class WebGLVertexAttribData final
|
2014-11-14 07:03:50 +03:00
|
|
|
{
|
2016-09-24 03:28:58 +03:00
|
|
|
public:
|
|
|
|
uint32_t mDivisor;
|
|
|
|
bool mEnabled;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool mIntegerFunc;
|
|
|
|
public:
|
|
|
|
WebGLRefPtr<WebGLBuffer> mBuf;
|
|
|
|
private:
|
|
|
|
GLenum mType;
|
2016-12-22 06:42:07 +03:00
|
|
|
GLenum mBaseType;
|
2016-09-24 03:28:58 +03:00
|
|
|
uint8_t mSize; // num of mType vals per vert
|
|
|
|
uint8_t mBytesPerVertex;
|
|
|
|
bool mNormalized;
|
|
|
|
uint32_t mStride; // bytes
|
|
|
|
uint32_t mExplicitStride;
|
|
|
|
uint64_t mByteOffset;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
#define GETTER(X) const decltype(m##X)& X() const { return m##X; }
|
|
|
|
|
|
|
|
GETTER(IntegerFunc)
|
|
|
|
GETTER(Type)
|
2016-12-22 06:42:07 +03:00
|
|
|
GETTER(BaseType)
|
2016-09-24 03:28:58 +03:00
|
|
|
GETTER(Size)
|
|
|
|
GETTER(BytesPerVertex)
|
|
|
|
GETTER(Normalized)
|
|
|
|
GETTER(Stride)
|
|
|
|
GETTER(ExplicitStride)
|
|
|
|
GETTER(ByteOffset)
|
|
|
|
|
|
|
|
#undef GETTER
|
|
|
|
|
2012-11-29 10:04:26 +04:00
|
|
|
// note that these initial values are what GL initializes vertex attribs to
|
|
|
|
WebGLVertexAttribData()
|
2018-04-13 16:01:28 +03:00
|
|
|
: mDivisor(0)
|
|
|
|
, mEnabled(false)
|
2018-07-06 10:56:24 +03:00
|
|
|
, mIntegerFunc(false)
|
|
|
|
, mType(0)
|
|
|
|
, mBaseType(0)
|
|
|
|
, mSize(0)
|
|
|
|
, mBytesPerVertex(0)
|
|
|
|
, mNormalized(false)
|
|
|
|
, mStride(0)
|
|
|
|
, mExplicitStride(0)
|
|
|
|
, mByteOffset(0)
|
2016-09-24 03:28:58 +03:00
|
|
|
{
|
2018-04-13 16:01:28 +03:00
|
|
|
VertexAttribPointer(false, nullptr, 4, LOCAL_GL_FLOAT, false, 0, 0);
|
2012-11-29 10:04:26 +04:00
|
|
|
}
|
|
|
|
|
2016-09-24 03:28:58 +03:00
|
|
|
void VertexAttribPointer(bool integerFunc, WebGLBuffer* buf, uint8_t size,
|
|
|
|
GLenum type, bool normalized, uint32_t stride,
|
|
|
|
uint64_t byteOffset);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2016-09-24 03:28:58 +03:00
|
|
|
void DoVertexAttribPointer(gl::GLContext* gl, GLuint index) const;
|
2013-06-11 00:00:35 +04:00
|
|
|
};
|
|
|
|
|
2012-11-29 10:04:26 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
inline void
|
2014-11-14 07:03:50 +03:00
|
|
|
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& callback,
|
|
|
|
mozilla::WebGLVertexAttribData& field,
|
|
|
|
const char* name,
|
|
|
|
uint32_t flags = 0)
|
2012-11-29 10:04:26 +04:00
|
|
|
{
|
2016-09-24 03:28:58 +03:00
|
|
|
CycleCollectionNoteChild(callback, field.mBuf.get(), name, flags);
|
2013-06-11 00:00:35 +04:00
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_VERTEX_ATTRIB_DATA_H_
|