+ if(data_type==UNSIGNED_SHORT)
+ return sizeof(unsigned short);
+ else if(data_type==UNSIGNED_INT)
+ return sizeof(unsigned);
+ return sizeof(unsigned char);
+}
+
+unsigned Batch::get_index(unsigned i) const
+{
+ if(data_type==UNSIGNED_SHORT)
+ return *(unsigned short *)&data[i*sizeof(unsigned short)];
+ else if(data_type==UNSIGNED_INT)
+ return *(unsigned *)&data[i*sizeof(unsigned )];
+ else
+ return data[i];
+}
+
+void Batch::draw() const
+{
+ if(restart)
+ {
+ unsigned index;
+ if(data_type==UNSIGNED_SHORT)
+ index = 0xFFFF;
+ else if(data_type==UNSIGNED_INT)
+ index = 0xFFFFFFFF;
+ else
+ index = 0xFF;
+
+ if(index!=restart_index)
+ {
+ if(!restart_index)
+ glEnableClientState(GL_PRIMITIVE_RESTART_NV);
+ glPrimitiveRestartIndexNV(index);
+ restart_index = index;
+ }
+ }
+ else if(restart_index && restart_index<=max_index)
+ {
+ glDisableClientState(GL_PRIMITIVE_RESTART_NV);
+ restart_index = 0;
+ }
+
+ if(get_buffer())
+ {
+ if(dirty)
+ update_buffer();
+
+ BufferAlias<ELEMENT_ARRAY_BUFFER> alias(*get_buffer());
+ Bind bind_ibuf(alias, true);
+
+ glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, reinterpret_cast<void *>(get_offset()));
+ }
+ else
+ glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, &data[0]);