X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmatrix.cpp;h=311958ab99542574edfe3cda35059d0eade1b24b;hb=a40fc85277dba5c34402a0e703d038efd30cc57b;hp=a4c36a022a9ecb338406a496760f12c1d0655540;hpb=2fa1bb084e54af7134b44d3ee7512056e28de67e;p=libs%2Fgl.git diff --git a/source/matrix.cpp b/source/matrix.cpp index a4c36a02..311958ab 100644 --- a/source/matrix.cpp +++ b/source/matrix.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "error.h" #include "matrix.h" @@ -117,93 +116,5 @@ Matrix Matrix::perspective(const Angle &h, float a, float n, float f) return frustum(-hh*a, hh*a, -hh, hh, n, f); } - -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()); -} - -const Matrix &MatrixStack::top() const -{ - return matrices.back(); -} - -void MatrixStack::load(const Matrix &m) -{ - matrices.back() = m; - update(); -} - -void MatrixStack::multiply(const Matrix &m) -{ - matrices.back() *= m; - update(); -} - -void MatrixStack::push() -{ - matrices.push_back(top()); -} - -void MatrixStack::pop() -{ - if(matrices.size()==1) - throw stack_underflow("MatrixStack::pop()"); - - matrices.pop_back(); - update(); -} - -void MatrixStack::update() -{ - if(!mode) - return; - - static Require _req(MSP_legacy_features); - - if(mode!=current_mode) - { - glMatrixMode(mode); - current_mode = mode; - } - - glLoadMatrixf(matrices.back().data()); -} - -MatrixStack &MatrixStack::operator=(const Matrix &m) -{ - load(m); - return *this; -} - -MatrixStack &MatrixStack::operator*=(const Matrix &m) -{ - multiply(m); - return *this; -} - -MatrixStack &MatrixStack::modelview() -{ - static MatrixStack ms(GL_MODELVIEW); - return ms; -} - -MatrixStack &MatrixStack::projection() -{ - static MatrixStack ms(GL_PROJECTION); - return ms; -} - } // namespace GL } // namespace Msp