29 : primitive_type_(kTriangles), vertex_ranges_(*this), instance_count_(0) {}
35 if (range.IsEmpty()) {
36 LOG(
WARNING) <<
"Ignoring empty range passed to Shape::AddVertexRange.";
39 const size_t index = vertex_ranges_.size();
40 vertex_ranges_.push_back(VertexRange(range,
true, 0));
46 if (CheckRangeIndex(i,
"SetVertexRange")) {
48 LOG(
WARNING) <<
"Ignoring empty range passed to Shape::SetVertexRange.";
50 vertex_ranges_[i].range = range;
55 if (CheckRangeIndex(i,
"GetVertexRange"))
56 return vertex_ranges_[i].range;
61 if (CheckRangeIndex(i,
"EnableVertexRange"))
62 vertex_ranges_[i].is_enabled = enable;
66 if (CheckRangeIndex(i,
"IsVertexRangeEnabled"))
67 return vertex_ranges_[i].is_enabled;
72 if (CheckRangeIndex(i,
"SetVertexRangeInstanceCount"))
73 vertex_ranges_[i].instance_count = instance_count;
77 if (CheckRangeIndex(i,
"GetVertexRangeInstanceCount"))
78 return vertex_ranges_[i].instance_count;
82 bool Shape::CheckRangeIndex(
size_t i,
const char*
name)
const {
85 if (i < vertex_ranges_.size()) {
88 LOG(
WARNING) <<
"Out of bounds index " << i <<
" passed to "
89 <<
"Shape::" << name <<
"; shape has "
90 << vertex_ranges_.size() <<
" ranges";
102 template <> ION_API
const EnumHelper::EnumData<Shape::PrimitiveType>
103 EnumHelper::GetEnumData() {
104 static const GLenum kValues[] = {
105 GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP, GL_POINTS, GL_TRIANGLES,
106 GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP
108 static const char* kStrings[] = {
109 "Lines",
"Line Loop",
"Line Strip",
"Points",
"Triangles",
"Triangle Fan",
113 "EnumHelper size mismatch");
114 return EnumData<Shape::PrimitiveType>(
void SetVertexRangeInstanceCount(size_t i, int instance_count)
Sets/Gets the instance count of vertex range.
void EnableVertexRange(size_t i, bool enable)
Enables or disables a specific vertex range.
Range< 1, int32 > Range1i
const size_t kInvalidIndex
kInvalidIndex is a size_t value that is very unlikely to be a valid index.
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
int GetVertexRangeInstanceCount(size_t i) const
Returns the instance count that the vertex range is set to.
const math::Range1i GetVertexRange(size_t i) const
Returns the i-th vertex range.
This template class can be used to map between two kinds of indices when the following assumptions ap...
size_t AddVertexRange(const math::Range1i &range)
By default, a Shape draws all of its vertices (if there is no IndexBuffer) or all of its indexed vert...
void SetVertexRange(size_t i, const math::Range1i &range)
Modifies the specified vertex range if the passed index is valid (i.e., there is a range at i that ha...
~Shape() override
The destructor is protected because all base::Referent classes must have protected or private destruc...
bool IsVertexRangeEnabled(size_t i) const
Returns whether the i-th vertex range is enabled, or false if i does not refer to a valid range...
#define ION_STATIC_ASSERT(expr, message)
Copyright 2016 Google Inc.