]> git.tdb.fi Git - libs/gl.git/blobdiff - source/batch.cpp
Rework exceptions
[libs/gl.git] / source / batch.cpp
index 1260c6abe5e995203af5ff3a70d10ce9fc1d8d63..b4b88176559a744ffa602fed13951ebd8a65b669 100644 (file)
@@ -1,6 +1,7 @@
 #include "batch.h"
 #include "bindable.h"
 #include "buffer.h"
+#include "error.h"
 #include "extension.h"
 #include "nv_primitive_restart.h"
 #include "vertexarray.h"
@@ -33,11 +34,11 @@ Batch::~Batch()
 void Batch::set_data_type(DataType t)
 {
        if(t!=UNSIGNED_BYTE && t!=UNSIGNED_SHORT && t!=UNSIGNED_INT)
-               throw InvalidParameterValue("Batch data type must be an unsigned integer");
+               throw invalid_argument("Batch::set_data_type");
        if(t==UNSIGNED_BYTE && max_index>0xFE)
-               throw InvalidState("UNSIGNED_BYTE can't hold all indices in Batch");
+               throw invalid_operation("Batch::set_data_type");
        else if(t==UNSIGNED_SHORT && max_index>0xFFFE)
-               throw InvalidState("UNSIGNED_SHORT can't hold all indices in Batch");
+               throw invalid_operation("Batch::set_data_type");
 
        if(data_type==UNSIGNED_BYTE && t==UNSIGNED_SHORT)
                expand_data<unsigned char, unsigned short>();
@@ -60,7 +61,7 @@ void Batch::set_data_type(DataType t)
 void Batch::use_index_buffer(Buffer *buf, Batch *prev)
 {
        if(buf && prev && prev->ibuf!=buf)
-               throw InvalidParameterValue("Previous batch is not in the same buffer");
+               throw invalid_argument("Batch::use_index_buffer");
 
        if(!buf)
        {
@@ -153,11 +154,11 @@ void Batch::append(const vector<unsigned> &ind)
 void Batch::append(const Batch &other)
 {
        if(other.prim_type!=prim_type)
-               throw InvalidParameterValue("Can't concatenate batches with different primitive types");
+               throw invalid_argument("Batch::append");
        if(prim_type==LINE_STRIP || prim_type==LINE_LOOP)
-               throw InvalidState("Can't concatenate line strips or loops");
+               throw incompatible_data("Batch::append");
        else if(prim_type==POLYGON)
-               throw InvalidState("Can't concatenate polygons");
+               throw incompatible_data("Batch::append");
        else if(prim_type==TRIANGLE_FAN)
                static RequireExtension _ext("GL_NV_primitive_restart");