]> git.tdb.fi Git - libs/gl.git/commitdiff
Rename batch's data_type to index_type
authorMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 01:13:29 +0000 (03:13 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 01:13:29 +0000 (03:13 +0200)
source/batch.cpp
source/batch.h

index 1f787d29a46f090b6a320a2dc07a07ab872eee87..64187eedb123aff7bdcef7d41fb5d67f8327f44b 100644 (file)
@@ -54,7 +54,7 @@ unsigned Batch::restart_index = 0;
 
 Batch::Batch(PrimitiveType t):
        prim_type(t),
-       data_type(UNSIGNED_SHORT),
+       index_type(UNSIGNED_SHORT),
        max_index(0),
        restart(false)
 { }
@@ -63,19 +63,19 @@ Batch::~Batch()
 {
 }
 
-void Batch::set_data_type(DataType t)
+void Batch::set_index_type(DataType t)
 {
        if(t!=UNSIGNED_SHORT && t!=UNSIGNED_INT)
                throw invalid_argument("Batch::set_data_type");
        if(t==UNSIGNED_SHORT && max_index>0xFFFE)
                throw invalid_operation("Batch::set_data_type");
 
-       if(data_type==UNSIGNED_SHORT && t==UNSIGNED_INT)
+       if(index_type==UNSIGNED_SHORT && t==UNSIGNED_INT)
                expand<UInt16, UInt32>(data);
-       else if(data_type==UNSIGNED_INT && t==UNSIGNED_SHORT)
+       else if(index_type==UNSIGNED_INT && t==UNSIGNED_SHORT)
                shrink<UInt32, UInt16>(data);
 
-       data_type = t;
+       index_type = t;
        update_offset();
        dirty = true;
 }
@@ -132,7 +132,7 @@ Batch &Batch::append(const Batch &other)
        else if(MSP_primitive_restart)
        {
                restart = true;
-               if(data_type==UNSIGNED_INT)
+               if(index_type==UNSIGNED_INT)
                        ::append<UInt32>(data, 0xFFFFFFFF);
                else
                        ::append<UInt16>(data, 0xFFFF);
@@ -162,10 +162,10 @@ void Batch::append_index(unsigned i)
        else
                max_index = max(max_index, i);
 
-       if(data_type==UNSIGNED_SHORT && max_index>0xFFFE)
-               set_data_type(UNSIGNED_INT);
+       if(index_type==UNSIGNED_SHORT && max_index>0xFFFE)
+               set_index_type(UNSIGNED_INT);
 
-       if(data_type==UNSIGNED_INT)
+       if(index_type==UNSIGNED_INT)
                ::append<UInt32>(data, i);
        else
                ::append<UInt16>(data, i);
@@ -173,12 +173,12 @@ void Batch::append_index(unsigned i)
 
 unsigned Batch::get_index_size() const
 {
-       return (data_type==UNSIGNED_INT ? sizeof(UInt32) : sizeof(UInt16));
+       return (index_type==UNSIGNED_INT ? sizeof(UInt32) : sizeof(UInt16));
 }
 
 unsigned Batch::get_index(unsigned i) const
 {
-       if(data_type==UNSIGNED_INT)
+       if(index_type==UNSIGNED_INT)
                return *(UInt32 *)&data[i*sizeof(UInt32)];
        else
                return *(UInt16 *)&data[i*sizeof(UInt16)];
@@ -189,7 +189,7 @@ void Batch::draw() const
        BindRestore _bind_ibuf(get_buffer(), ELEMENT_ARRAY_BUFFER);
        const void *data_ptr = setup_draw();
 
-       glDrawElements(prim_type, size(), data_type, data_ptr);
+       glDrawElements(prim_type, size(), index_type, data_ptr);
 }
 
 void Batch::draw_instanced(unsigned count) const
@@ -199,14 +199,14 @@ void Batch::draw_instanced(unsigned count) const
        BindRestore _bind_ibuf(get_buffer(), ELEMENT_ARRAY_BUFFER);
        const void *data_ptr = setup_draw();
 
-       glDrawElementsInstanced(prim_type, size(), data_type, data_ptr, count);
+       glDrawElementsInstanced(prim_type, size(), index_type, data_ptr, count);
 }
 
 const void *Batch::setup_draw() const
 {
        if(restart)
        {
-               unsigned index = (data_type==UNSIGNED_INT ? 0xFFFFFFFF : 0xFFFF);
+               unsigned index = (index_type==UNSIGNED_INT ? 0xFFFFFFFF : 0xFFFF);
 
                if(index!=restart_index)
                        set_restart_index(index);
index d42a8629d1a47df3be7ba8a5ea0eeefa68fad52b..6fb013af68e8de626757392a2e4644d9c734d2d8 100644 (file)
@@ -33,7 +33,7 @@ public:
 
 private:
        PrimitiveType prim_type;
-       DataType data_type;
+       DataType index_type;
        std::vector<UInt8> data;
        unsigned min_index;
        unsigned max_index;
@@ -46,8 +46,11 @@ public:
        ~Batch();
 
        PrimitiveType get_type() const { return prim_type; }
-       void set_data_type(DataType);
-       DataType get_data_type() const { return data_type; }
+       void set_index_type(DataType);
+       DataType get_index_type() const { return index_type; }
+
+       DEPRECATED void set_data_type(DataType t) { set_index_type(t); }
+       DEPRECATED DataType get_data_type() const { return index_type; }
 
        Batch &append(unsigned);
        Batch &append(const std::vector<unsigned> &);