X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Ftests.h;h=622834dcf888db6abb982abf1721a3291d8cc439;hb=f17794d55923d4fb4f63e9d082d8d84a735a04e8;hp=b906c0cec2afada2ba5ebb36adcf7ef53ede89a8;hpb=02dad9779326e5b8acc1fddbaec3a2f36da15c16;p=libs%2Fgl.git diff --git a/source/tests.h b/source/tests.h index b906c0ce..622834dc 100644 --- a/source/tests.h +++ b/source/tests.h @@ -1,13 +1,14 @@ /* $Id$ This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2007, 2010 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ #ifndef MSP_GL_TESTS_H_ #define MSP_GL_TESTS_H_ +#include "bindable.h" #include "gl.h" #include "predicate.h" @@ -21,12 +22,76 @@ enum DEPTH_TEST = GL_DEPTH_TEST }; -void scissor(int left, int bottom, unsigned width, unsigned height); +/** +Tests incoming fragment alpha values against a reference. If the test fails, +the fragment is discarded. +*/ +class AlphaTest: public Bindable +{ +private: + Predicate pred; + float ref; + +public: + AlphaTest(); + AlphaTest(Predicate, float); + + void bind() const; + + static void unbind(); +}; void alpha_func(Predicate func, float ref); + +/** +Tests incoming fragment depth values against the depth buffer. If the test +fails, the fragment is discarded. +*/ +class DepthTest: public Bindable +{ +private: + bool write; + Predicate pred; + + static const DepthTest *current; + +public: + DepthTest(); + DepthTest(Predicate, bool = true); + + void bind() const; + + static const DepthTest &lequal(); + static void unbind(); +}; + void depth_func(Predicate func); + +/** +Tests fragment coordinates against a rectangle. Any fragments outside the +rectangle are discarded. +*/ +class ScissorTest: public Bindable +{ +private: + int left; + int bottom; + unsigned width; + unsigned height; + +public: + ScissorTest(); + ScissorTest(int, int, unsigned, unsigned); + + void bind() const; + + static void unbind(); +}; + +void scissor(int left, int bottom, unsigned width, unsigned height); + } // namespace GL } // namespace Msp