+++ /dev/null
-#include <stdexcept>
-#include "misc.h"
-#include "texgen.h"
-#include "texunit.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-TexGen::TexGen():
- mode(EYE_LINEAR)
-{ }
-
-TexGen::~TexGen()
-{
- // TODO unbind
-}
-
-void TexGen::set_mode(TexGenMode m)
-{
- mode = m;
-}
-
-void TexGen::set_plane(const Vector4 &p)
-{
- plane = p;
-}
-
-void TexGen::bind_to(unsigned i, TexCoordComponent c) const
-{
- TexUnit &unit = TexUnit::get_unit(i);
- if(unit.set_texgen(coord_index(c), this))
- {
- unit.bind();
- glTexGeni(c, GL_TEXTURE_GEN_MODE, mode);
- if(mode==EYE_LINEAR)
- glTexGenfv(c, GL_EYE_PLANE, &plane.x);
- else if(mode==OBJECT_LINEAR)
- glTexGenfv(c, GL_OBJECT_PLANE, &plane.x);
- enable(GL_TEXTURE_GEN_S+coord_index(c));
- }
-}
-
-const TexGen *TexGen::current(unsigned i, TexCoordComponent c)
-{
- return TexUnit::get_unit(i).get_texgen(coord_index(c));
-}
-
-void TexGen::unbind_from(unsigned i, TexCoordComponent c)
-{
- TexUnit &unit = TexUnit::get_unit(i);
- if(unit.set_texgen(coord_index(c), 0))
- {
- unit.bind();
- disable(GL_TEXTURE_GEN_S+coord_index(c));
- }
-}
-
-unsigned TexGen::coord_index(TexCoordComponent c)
-{
- switch(c)
- {
- case SCOORD: return 0;
- case TCOORD: return 1;
- case RCOORD: return 2;
- case QCOORD: return 3;
- default: throw invalid_argument("TexGen::coord_index");
- }
-}
-
-} // namespace GL
-} // namespace Msp