X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftests.cpp;fp=source%2Fcore%2Ftests.cpp;h=8e24bb52facc436a0a75451a57726737a574bb22;hb=7aaec9a70b8d7733429bec043f8e33e02956f266;hp=0000000000000000000000000000000000000000;hpb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;p=libs%2Fgl.git diff --git a/source/core/tests.cpp b/source/core/tests.cpp new file mode 100644 index 00000000..8e24bb52 --- /dev/null +++ b/source/core/tests.cpp @@ -0,0 +1,73 @@ +#include "tests.h" + +namespace Msp { +namespace GL { + +DepthTest::DepthTest(): + write(true), + pred(LESS) +{ } + +DepthTest::DepthTest(Predicate p, bool w): + write(w), + pred(p) +{ } + +void DepthTest::bind() const +{ + if(set_current(this)) + { + glEnable(GL_DEPTH_TEST); + glDepthFunc(pred); + glDepthMask(write); + } +} + +const DepthTest &DepthTest::lequal() +{ + static DepthTest test(LEQUAL); + return test; +} + +void DepthTest::unbind() +{ + if(set_current(0)) + { + glDisable(GL_DEPTH_TEST); + // Allow glClear(GL_DEPTH_BUFFER_BIT) to work + glDepthMask(true); + } +} + + +ScissorTest::ScissorTest(): + left(0), + bottom(0), + width(1), + height(1) +{ } + +ScissorTest::ScissorTest(int l, int b, unsigned w, unsigned h): + left(l), + bottom(b), + width(w), + height(h) +{ } + +void ScissorTest::bind() const +{ + if(set_current(this)) + { + glEnable(GL_SCISSOR_TEST); + glScissor(left, bottom, width, height); + } +} + +void ScissorTest::unbind() +{ + if(set_current(0)) + glDisable(GL_SCISSOR_TEST); +} + +} // namespace GL +} // namespace Msp