X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmatrix.cpp;h=a4c36a022a9ecb338406a496760f12c1d0655540;hp=4bf550aa090ffc44c2734992cd064e578ebb460a;hb=a4549c55a6d47129bd9e42c6a49a671b759ce6d9;hpb=fa5b232a16e11d7950e80764497f0167ec9e3b41 diff --git a/source/matrix.cpp b/source/matrix.cpp index 4bf550aa..a4c36a02 100644 --- a/source/matrix.cpp +++ b/source/matrix.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "error.h" #include "matrix.h" @@ -21,45 +22,19 @@ Matrix::Matrix(const LinAl::Matrix &other): Base(other) { } -void Matrix::multiply(const Matrix &other) +Matrix &Matrix::translate(const Vector3 &t) { - *this = *this*other; + return multiply(translation(t)); } -void Matrix::translate(const Vector3 &t) +Matrix &Matrix::rotate(const Angle &a, const Vector3 &x) { - multiply(translation(t)); + return multiply(rotation(a, x)); } -void Matrix::rotate(const Angle &a, const Vector3 &x) +Matrix &Matrix::scale(const Vector3 &s) { - multiply(rotation(a, x)); -} - -void Matrix::scale(const Vector3 &s) -{ - multiply(scaling(s)); -} - -Matrix Matrix::operator*(const Matrix &other) const -{ - return static_cast(*this)*static_cast(other); -} - -Matrix &Matrix::operator*=(const Matrix &other) -{ - multiply(other); - return *this; -} - -Vector4 Matrix::operator*(const Vector4 &vec) const -{ - return static_cast(*this)*LinAl::Vector(vec); -} - -Vector3 Matrix::operator*(const Vector3 &vec) const -{ - return Vector3((*this)*Vector4(vec, 1.0f)); + return multiply(scaling(s)); } float Matrix::operator[](unsigned i) const @@ -195,6 +170,8 @@ void MatrixStack::update() if(!mode) return; + static Require _req(MSP_legacy_features); + if(mode!=current_mode) { glMatrixMode(mode);