30 data_(kDataChanged, BufferData(), this),
31 target_(kArrayBuffer),
33 sub_data_changed_(kSubDataChanged, false, this) {}
37 data_(kDataChanged, BufferData(), this),
40 sub_data_changed_(kSubDataChanged, false, this) {}
47 const size_t component_count,
48 const size_t byte_offset) {
49 if (component_count > 4U) {
50 LOG(
ERROR) <<
"***ION: Elements must have no more than four components.";
53 Spec spec(type, component_count, byte_offset);
54 size_t index = specs_.size();
56 for (
size_t i = 0; i < index; ++i) {
57 if (spec == specs_[i]) {
63 if (index == specs_.size())
64 specs_.push_back(spec);
70 const size_t element_index)
const {
71 if (element_index >= specs_.size()) {
72 LOG(
ERROR) <<
"***ION: Invalid element index " << element_index
73 <<
" passed to BufferObject with " << specs_.size()
75 return base::InvalidReference<BufferObject::Spec>();
77 return specs_[element_index];
83 if (notifier ==
GetData().Get()) {
104 template <> ION_API
const EnumHelper::EnumData<BufferObject::ComponentType>
105 EnumHelper::GetEnumData() {
106 static const GLenum kValues[] = {
107 GL_INVALID_ENUM, GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT,
108 GL_INT, GL_UNSIGNED_INT, GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT
110 static const char* kStrings[] = {
111 "Invalid",
"Byte",
"Unsigned Byte",
"Short",
"Unsigned Short",
"Int",
112 "Unsigned Int",
"Float",
"Float Matrix Column 2",
"Float Matrix Column 3",
113 "Float Matrix Column 4"};
115 "EnumHelper size mismatch");
116 return EnumData<BufferObject::ComponentType>(
122 template <> ION_API
const EnumHelper::EnumData<BufferObject::Target>
123 EnumHelper::GetEnumData() {
124 static const GLenum kValues[] = { GL_ARRAY_BUFFER,
125 GL_ELEMENT_ARRAY_BUFFER,
129 static const char* kStrings[] = {
136 "EnumHelper size mismatch");
137 return EnumData<BufferObject::Target>(
143 template <> ION_API
const EnumHelper::EnumData<BufferObject::UsageMode>
144 EnumHelper::GetEnumData() {
145 static const GLenum kValues[] = {
146 GL_DYNAMIC_DRAW, GL_STATIC_DRAW, GL_STREAM_DRAW
148 static const char* kStrings[] = {
"DynamicDraw",
"StaticDraw",
"StreamDraw" };
150 "EnumHelper size mismatch");
151 return EnumData<BufferObject::UsageMode>(
const size_t kInvalidIndex
kInvalidIndex is a size_t value that is very unlikely to be a valid index.
size_t AddSpec(const ComponentType type, const size_t component_count, const size_t byte_offset)
Describes an element of an arbitrary datatype to the BufferObject.
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
A Notifier both sends notifications to and receives notifications from other Notifiers.
~BufferSubData()
See comment in .cc file.
void OnChanged(int bit) const
Forwards OnChanged to all resources.
void Notify() const
Notifies all contained Notifiers by calling their OnNotify().
The DataContainer class encapsulates arbitrary user data passed to Ion.
This template class can be used to map between two kinds of indices when the following assumptions ap...
A BufferObject describes a generic array of data used, for example, to describe the vertices in a Sha...
const base::DataContainerPtr & GetData() const
Gets the data container.
ComponentType
The type of the components of a spec.
Copyright 2016 Google Inc.
~BufferObject() override
The destructor is protected because all base::Referent classes must have protected or private destruc...
BufferObject()
Creates a BufferObject of type kArrayBuffer.
int GetResourceCount() const
Returns the number of resources that this holder holds.
#define ION_STATIC_ASSERT(expr, message)
Copyright 2016 Google Inc.
const Spec & GetSpec(const size_t spec_index) const
Gets the Spec at index spec_index.