X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmatrix.cpp;h=b7f76bc77528965fcff8f15ef90b353cf3dd836b;hb=bd141418a0712feeb64bcaff7f57e29913b0317b;hp=f5089285d63295458698e1c392511348fc34a696;hpb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8;p=libs%2Fgl.git diff --git a/source/matrix.cpp b/source/matrix.cpp index f5089285..b7f76bc7 100644 --- a/source/matrix.cpp +++ b/source/matrix.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include "error.h" #include "matrix.h" using namespace std; @@ -149,7 +149,7 @@ Vector4 Matrix::operator*(const Vector4 &vec) const double Matrix::operator[](unsigned i) const { if(i>=16) - throw InvalidParameterValue("Matrix element index out of range"); + throw out_of_range("Matrix::operator[]"); return matrix[i]; } @@ -215,7 +215,7 @@ Matrix Matrix::scaling(double x, double y, double z) Matrix Matrix::ortho(double l, double r, double b, double t, double n, double f) { if(l==r || b==t || n==f) - throw InvalidParameterValue("Orthogonal projection can't have zero dimension"); + throw invalid_argument("Matrix::ortho"); Matrix result; result.matrix[0] = 2/(r-l); @@ -246,7 +246,7 @@ Matrix Matrix::ortho_topleft(double w, double h) Matrix Matrix::frustum(double l, double r, double b, double t, double n, double f) { if(l==r || b==t || n<=0 || f<=n) - throw InvalidParameterValue("Invalid frustum parameters"); + throw invalid_argument("Matrix::frustum"); Matrix result; result.matrix[0] = 2*n/(r-l); @@ -278,12 +278,14 @@ GLenum MatrixStack::current_mode = GL_MODELVIEW; MatrixStack::MatrixStack(GLenum m): mode(m) { + matrices.reserve(mode==GL_MODELVIEW ? 32 : 4); matrices.push_back(Matrix()); } MatrixStack::MatrixStack(): mode(0) { + matrices.reserve(32); matrices.push_back(Matrix()); } @@ -312,7 +314,7 @@ void MatrixStack::push() void MatrixStack::pop() { if(matrices.size()==1) - throw InvalidState("Can't pop the last matrix"); + throw stack_underflow("MatrixStack::pop()"); matrices.pop_back(); update(); @@ -368,7 +370,7 @@ void matrix_mode(MatrixMode m) else if(m==PROJECTION) active_stack = &MatrixStack::projection(); else - throw InvalidParameterValue("Texture matrices are not supported"); + throw invalid_argument("matrix_mode"); } void load_identity()