X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbatch.cpp;h=cdbba871ced2882160cae191683f5941350ee7b0;hb=afd625b06702e7a25e0730601f03955832b64e65;hp=102b6487281244457950b6e0625b262e2ac3408e;hpb=c48cb5362edb16c33ed5f6862a908bb9a754c85a;p=libs%2Fgl.git diff --git a/source/batch.cpp b/source/batch.cpp index 102b6487..cdbba871 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -1,13 +1,7 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007-2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "batch.h" #include "bindable.h" #include "buffer.h" +#include "error.h" #include "extension.h" #include "nv_primitive_restart.h" #include "vertexarray.h" @@ -40,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(); @@ -67,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) { @@ -160,11 +154,11 @@ void Batch::append(const vector &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"); @@ -250,7 +244,7 @@ void Batch::draw() const BufferAlias alias(*ibuf); Bind bind_ibuf(alias, true); - glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, (void *)ibuf_offset); + glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, reinterpret_cast(ibuf_offset)); } else glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, &data[0]);