2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-11-29 10:04:26 +04:00
|
|
|
/* 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"
|
2018-10-17 07:18:15 +03:00
|
|
|
#include "WebGLFormats.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#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 {
|
|
|
|
public:
|
|
|
|
uint32_t mDivisor;
|
|
|
|
bool mEnabled;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-09-24 03:28:58 +03:00
|
|
|
private:
|
|
|
|
bool mIntegerFunc;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-09-24 03:28:58 +03:00
|
|
|
public:
|
|
|
|
WebGLRefPtr<WebGLBuffer> mBuf;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-09-24 03:28:58 +03:00
|
|
|
private:
|
|
|
|
GLenum mType;
|
2018-10-17 07:18:15 +03:00
|
|
|
webgl::AttribBaseType mBaseType = webgl::AttribBaseType::Float;
|
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;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-09-24 03:28:58 +03:00
|
|
|
public:
|
|
|
|
#define GETTER(X) \
|
|
|
|
const decltype(m##X)& X() const { return m##X; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-09-24 03:28:58 +03:00
|
|
|
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),
|
|
|
|
mSize(0),
|
|
|
|
mBytesPerVertex(0),
|
|
|
|
mNormalized(false),
|
|
|
|
mStride(0),
|
|
|
|
mExplicitStride(0),
|
|
|
|
mByteOffset(0) {
|
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
|
|
|
}
|
2018-11-30 13:46:48 +03: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);
|
2018-11-30 13:46:48 +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
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
inline void ImplCycleCollectionTraverse(
|
|
|
|
nsCycleCollectionTraversalCallback& callback,
|
|
|
|
mozilla::WebGLVertexAttribData& field, const char* name,
|
|
|
|
uint32_t flags = 0) {
|
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_
|