]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove a number of rarely used legacy features
authorMikko Rasa <tdb@tdb.fi>
Wed, 15 Oct 2014 16:40:16 +0000 (19:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 15 Oct 2014 16:59:06 +0000 (19:59 +0300)
ShadowMap will now need shaders to work, but it was already broken in
fixed-function anyway due to using large texture unit numbers.  Since
all modern hardware supports shaders, even with free drivers, this is
unlikely to be an issue.

The removed pixel format GL_RED is used in ARB_texture_rg, but we don't
support that extension yet.

25 files changed:
Build
demos/texturing.cpp [deleted file]
source/batch.cpp
source/clip.cpp [deleted file]
source/clip.h [deleted file]
source/datatype.h
source/framebuffer.h
source/pixelformat.cpp
source/pixelformat.h
source/primitivetype.cpp
source/primitivetype.h
source/programbuilder.cpp
source/renderpass.cpp
source/renderpass.h
source/shadowmap.cpp
source/tests.cpp
source/tests.h
source/texenv.cpp [deleted file]
source/texenv.h [deleted file]
source/texgen.cpp [deleted file]
source/texgen.h [deleted file]
source/texturing.cpp
source/texturing.h
source/texunit.cpp
source/texunit.h

diff --git a/Build b/Build
index 1aae9864be396b10511dbcc663e831f7b254eac4..162e26ca6257bde4ab8b3f4c4d7b5e0e6af4542d 100644 (file)
--- a/Build
+++ b/Build
@@ -48,12 +48,6 @@ package "mspgl"
                use "mspgl";
        };
 
-       program "texturing"
-       {
-               source "demos/texturing.cpp";
-               use "mspgl";
-       };
-
        program "cubemap"
        {
                source "demos/cubemap.cpp";
diff --git a/demos/texturing.cpp b/demos/texturing.cpp
deleted file mode 100644 (file)
index 7a1f779..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#include <cmath>
-#include <msp/graphics/simplewindow.h>
-#include <msp/gl/framebuffer.h>
-#include <msp/gl/matrix.h>
-#include <msp/gl/mesh.h>
-#include <msp/gl/meshbuilder.h>
-#include <msp/gl/texenv.h>
-#include <msp/gl/texture2d.h>
-#include <msp/gl/texturing.h>
-#include <msp/time/timestamp.h>
-#include <msp/time/utils.h>
-#include <msp/time/units.h>
-
-using namespace Msp;
-
-int main()
-{
-       Graphics::SimpleGLWindow wnd(400, 400);
-
-       GL::Texture2D tex1;
-       GL::Texture2D tex2;
-
-       unsigned char *data = new unsigned char[256*256*4];
-       for(unsigned y=0; y<256; ++y)
-               for(unsigned x=0; x<256; ++x)
-               {
-                       unsigned i = (x+y*256)*3;
-                       data[i] = 255;
-                       data[i+1] = (((x/32)+(y/32))&1 ? 255 : 0);
-                       data[i+2] = 0;
-               }
-       tex1.storage(GL::RGB, 256, 256);
-       tex1.set_min_filter(GL::LINEAR);
-       tex1.image(0, GL::RGB, GL::UNSIGNED_BYTE, data);
-
-       for(unsigned y=0; y<256; ++y)
-               for(unsigned x=0; x<256; ++x)
-               {
-                       unsigned i = (x+y*256)*4;
-                       data[i] = data[i+1] = data[i+2] = 0;
-                       data[i+3] = (((x/32)+(y/32))&1 ? 255 : 0);
-               }
-       tex2.storage(GL::RGBA, 256, 256);
-       tex2.set_min_filter(GL::LINEAR);
-       tex2.image(0, GL::RGBA, GL::UNSIGNED_BYTE, data);
-       delete[] data;
-
-       GL::Texturing texturing;
-       texturing.attach(0, tex1);
-       GL::TexEnv texenv;
-       texenv.set_mode(GL::DECAL);
-       texturing.attach(1, tex2, texenv);
-
-       GL::MatrixStack::projection() = GL::Matrix::frustum_centered(0.2, 0.2, 0.2, 10);
-       GL::MatrixStack::modelview() = GL::Matrix::translation(0, 0, -3);
-       GL::MatrixStack::modelview() *= GL::Matrix::rotation(-45, 1, 0, 0);
-
-       GL::Mesh mesh((GL::TEXCOORD2, GL::TEXCOORD2,1, GL::VERTEX3));
-       GL::MeshBuilder bld(mesh);
-       bld.begin(GL::QUADS);
-       bld.texcoord(0, 0);
-       bld.multitexcoord(1, -0.2071, 0.5);
-       bld.vertex(-1, -1);
-       bld.texcoord(1, 0);
-       bld.multitexcoord(1, 0.5, -0.2071);
-       bld.vertex(1, -1);
-       bld.texcoord(1, 1);
-       bld.multitexcoord(1, 1.2071, 0.5);
-       bld.vertex(1, 1);
-       bld.texcoord(0, 1);
-       bld.multitexcoord(1, 0.5, 1.2071);
-       bld.vertex(-1, 1);
-       bld.end();
-
-       wnd.show();
-       float angle = 0;
-       Time::TimeStamp last;
-       while(1)
-       {
-               for(unsigned i=0; i<4; ++i)
-               {
-                       float *v = mesh.modify_vertex(i);
-                       v[2] = 0.5+sin(angle)*0.1+cos(angle+i*M_PI/2)*0.7071;
-                       v[3] = 0.5+cos(angle)*0.1+sin(angle+i*M_PI/2)*0.7071;
-               }
-               wnd.get_display().tick();
-               GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT);
-               {
-                       GL::Bind bind_tex(texturing);
-                       mesh.draw();
-               }
-               wnd.swap_buffers();
-               Time::TimeStamp t = Time::now();
-               if(last)
-                       angle += 0.5*((t-last)/Time::sec);
-               last = t;
-       }
-
-       return 0;
-}
index 1b0c47bf976dd212aa4270a962d7f98a40f34761..e097fd6365d52b65db4a8d37110ef0f3010a7ccf 100644 (file)
@@ -122,7 +122,7 @@ bool Batch::can_append(PrimitiveType other_type)
 {
        if(other_type!=prim_type)
                return false;
-       else if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN || prim_type==POLYGON)
+       else if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN)
                return NV_primitive_restart;
        else
                return true;
@@ -132,7 +132,7 @@ void Batch::append(const Batch &other)
 {
        if(other.prim_type!=prim_type)
                throw invalid_argument("Batch::append");
-       if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN || prim_type==POLYGON)
+       if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN)
                static Require _req(NV_primitive_restart);
 
        if(other.data.empty())
diff --git a/source/clip.cpp b/source/clip.cpp
deleted file mode 100644 (file)
index 9164177..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "clip.h"
-#include "gl.h"
-
-namespace Msp {
-namespace GL {
-
-ClipPlane::ClipPlane(double a, double b, double c, double d)
-{
-       eq[0] = a;
-       eq[1] = b;
-       eq[2] = c;
-       eq[3] = d;
-}
-
-void ClipPlane::apply_to(unsigned n)
-{
-       glClipPlane(GL_CLIP_PLANE0+n, eq);
-       glEnable(GL_CLIP_PLANE0+n);
-}
-
-void ClipPlane::disable(unsigned n)
-{
-       glDisable(GL_CLIP_PLANE0+n);
-}
-
-} // namespace GL
-} // namespace Msp
diff --git a/source/clip.h b/source/clip.h
deleted file mode 100644 (file)
index d658950..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef MSP_GL_CLIP_H_
-#define MSP_GL_CLIP_H_
-
-namespace Msp {
-namespace GL {
-
-class ClipPlane
-{
-public:
-       double eq[4];
-
-       ClipPlane(double, double, double, double);
-       void apply_to(unsigned);
-
-       static void disable(unsigned);
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif
index e0448c39c157f263566774b20786891f9678b2fe..76c87bc8d8fe7627e2ed7c3bf60e4f9db65d2228 100644 (file)
@@ -14,8 +14,7 @@ enum DataType
        UNSIGNED_SHORT = GL_UNSIGNED_SHORT,
        INT            = GL_INT,
        UNSIGNED_INT   = GL_UNSIGNED_INT,
-       FLOAT          = GL_FLOAT,
-       DOUBLE         = GL_DOUBLE
+       FLOAT          = GL_FLOAT
 };
 
 } // namespace GL
index f34ecf5c6eeea0204eaa685dfee5e7f4537e75b9..2e29dbc3f440c7f1b9f1646e7dd611d39e977dc4 100644 (file)
@@ -40,8 +40,7 @@ enum BufferBits
 {
        COLOR_BUFFER_BIT   = GL_COLOR_BUFFER_BIT,
        DEPTH_BUFFER_BIT   = GL_DEPTH_BUFFER_BIT,
-       STENCIL_BUFFER_BIT = GL_STENCIL_BUFFER_BIT,
-       ACCUM_BUFFER_BIT   = GL_ACCUM_BUFFER_BIT
+       STENCIL_BUFFER_BIT = GL_STENCIL_BUFFER_BIT
 };
 
 enum RWBuffer
index ee3cad099dd989bb87ff6932866c675d24815165..cd3bb2aa78e30709293dd8dfb13f4d42cd4c481d 100644 (file)
@@ -10,20 +10,10 @@ namespace GL {
 
 void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
 {
-       if(conv.get()=="COLOR_INDEX")
-               fmt = COLOR_INDEX;
-       else if(conv.get()=="STENCIL_INDEX")
+       if(conv.get()=="STENCIL_INDEX")
                fmt = STENCIL_INDEX;
        else if(conv.get()=="DEPTH_COMPONENT")
                fmt = DEPTH_COMPONENT;
-       else if(conv.get()=="RED")
-               fmt = RED;
-       else if(conv.get()=="GREEN")
-               fmt = GREEN;
-       else if(conv.get()=="BLUE")
-               fmt = BLUE;
-       else if(conv.get()=="ALPHA")
-               fmt = ALPHA;
        else if(conv.get()=="RGB")
                fmt = RGB;
        else if(conv.get()=="RGBA")
@@ -52,7 +42,6 @@ PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf)
 {
        switch(pf)
        {
-       case Graphics::COLOR_INDEX: return COLOR_INDEX;
        case Graphics::LUMINANCE: return LUMINANCE;
        case Graphics::LUMINANCE_ALPHA: return LUMINANCE_ALPHA;
        case Graphics::RGB: return RGB;
@@ -125,12 +114,8 @@ unsigned get_component_count(PixelFormat pf)
 {
        switch(get_base_pixelformat(pf))
        {
-       case COLOR_INDEX:
        case STENCIL_INDEX:
        case DEPTH_COMPONENT:
-       case RED:
-       case GREEN:
-       case BLUE:
        case LUMINANCE:
        case SLUMINANCE:
                return 1;
index 4da1a1517ae60b45b85aea8d41b7452744326f19..a0e578a6a65443dab00fd69007f669ac1d546730 100644 (file)
@@ -13,13 +13,8 @@ namespace GL {
 
 enum PixelFormat
 {
-       COLOR_INDEX     = GL_COLOR_INDEX,
        STENCIL_INDEX   = GL_STENCIL_INDEX,
        DEPTH_COMPONENT = GL_DEPTH_COMPONENT,
-       RED             = GL_RED,
-       GREEN           = GL_GREEN,
-       BLUE            = GL_BLUE,
-       ALPHA           = GL_ALPHA,
        RGB             = GL_RGB,
        RGBA            = GL_RGBA,
        RGB8            = GL_RGB8,
index 7b47dfd852b927db1285bdb37fa27513c39682e0..98053660e595cb4189e6b15fe016e6f31cbfd425 100644 (file)
@@ -24,8 +24,6 @@ void operator>>(const LexicalConverter &conv, PrimitiveType &pt)
                pt = QUADS;
        else if(conv.get()=="QUAD_STRIP")
                pt = QUAD_STRIP;
-       else if(conv.get()=="POLYGON")
-               pt = POLYGON;
        else
                throw lexical_error(format("conversion of '%s' to PrimitiveType", conv.get()));
 }
index 52a6e8754f733c2273440a3dd42cd7c3736100cc..777558a1ac9a22757ef9b043b5cea4ee17a939c1 100644 (file)
@@ -17,8 +17,7 @@ enum PrimitiveType
        TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
        TRIANGLE_FAN   = GL_TRIANGLE_FAN,
        QUADS          = GL_QUADS,
-       QUAD_STRIP     = GL_QUAD_STRIP,
-       POLYGON        = GL_POLYGON
+       QUAD_STRIP     = GL_QUAD_STRIP
 };
 
 void operator>>(const LexicalConverter &, PrimitiveType &);
index 1706b9d4ad70c0dc8e362f7c37b754e5df7a02b8..1e8f55773de8081a9ae99504289df7d7e5418f63 100644 (file)
@@ -106,8 +106,7 @@ const ProgramBuilder::VariableDefinition ProgramBuilder::standard_variables[] =
        { FRAGMENT, "tex_sample", "vec4", "texture2D(texture, texture_coord)", 0 },
 
        { VERTEX, "gl_Position", "vec4", "projection_matrix*eye_vertex", 0 },
-       { VERTEX, "shd_vertex", "vec3", "vec3(dot(eye_vertex, gl_EyePlaneS[shadow_unit]), dot(eye_vertex, gl_EyePlaneT[shadow_unit]), dot(eye_vertex, gl_EyePlaneR[shadow_unit]))", "g" },
-       { VERTEX, "shd_vertex", "vec3", "(shd_eye_matrix*eye_vertex).xyz", "!g" },
+       { VERTEX, "shd_vertex", "vec3", "(shd_eye_matrix*eye_vertex).xyz", 0 },
        { VERTEX, "tbn_sky_dir", "vec3", "eye_sky_dir*eye_tbn_matrix", "n" },
        { VERTEX, "tbn_light_dir[i]", "vec3", "eye_light_dir[i]*eye_tbn_matrix", 0 },
        { VERTEX, "eye_light_dir[i]", "vec3", "normalize(eye_light_position[i].xyz-eye_vertex.xyz*eye_light_position[i].w)", 0 },
@@ -128,7 +127,6 @@ const ProgramBuilder::VariableDefinition ProgramBuilder::standard_variables[] =
        { ATTRIBUTE, "tangent", "vec3", 0, 0 },
        { ATTRIBUTE, "binormal", "vec3", 0, 0 },
 
-       { UNIFORM, "ShadowMap::shadow_unit", "int", 0, 0 },
        { UNIFORM, "texture", "sampler2D", 0, 0 },
        { UNIFORM, "shadow", "sampler2DShadow", 0, 0 },
        { UNIFORM, "ShadowMap::shadow_darkness", "float", 0, 0 },
index 448db60a91f967cca6362a2ad9e5c41ff5afdc68..45ed6af7b579e2071209590864535d474b1ae7f6 100644 (file)
@@ -6,7 +6,6 @@
 #include "program.h"
 #include "programdata.h"
 #include "renderer.h"
-#include "texenv.h"
 #include "texture.h"
 #include "texture2d.h"
 #include "texturing.h"
@@ -151,22 +150,11 @@ void RenderPass::TextureLoader::finish()
 {
        if(tex)
        {
-               if(env)
-                       obj.attach(index, *tex, *env);
-               else
-                       obj.attach(index, *tex);
+               obj.attach(index, *tex);
                tex.release();
-               env.release();
        }
 }
 
-void RenderPass::TextureLoader::texenv()
-{
-       throw runtime_error("TexEnvs can't be loaded yet");
-       /*env = new TexEnv;
-       load_sub(*env);*/
-}
-
 void RenderPass::TextureLoader::texture(const string &name)
 {
        tex = &get_collection().get<Texture>(name);
index 934a213e3e815f0f855dfc10ca3b9add2c2193e5..eec60793ea3ca23b9052ae27dd75cdcfbfd97c52 100644 (file)
@@ -12,7 +12,6 @@ class Material;
 class Program;
 class ProgramData;
 class Renderer;
-class TexEnv;
 class Texture;
 class Texturing;
 
@@ -46,14 +45,12 @@ private:
        private:
                unsigned index;
                RefPtr<Texture> tex;
-               RefPtr<TexEnv> env;
 
        public:
                TextureLoader(Texturing &, unsigned, Collection *);
        private:
                virtual void finish();
 
-               void texenv();
                void texture(const std::string &);
                void texture2d();
        };
index 7575051e6e7d956e89299a8eed47db54ca8f9546..dd689935055093c5b5652b9e0c7a216099265bfd 100644 (file)
@@ -8,7 +8,6 @@
 #include "scene.h"
 #include "shadowmap.h"
 #include "tests.h"
-#include "texgen.h"
 #include "texunit.h"
 
 using namespace std;
@@ -126,16 +125,8 @@ void ShadowMap::render(Renderer &renderer, const Tag &tag) const
        unsigned unit = renderer.allocate_effect_texunit();
        int iunit = unit;
        shdata.uniform("shadow", iunit);
-       shdata.uniform("shadow_unit", iunit);
 
        Bind _bind_depth(depth_buf, unit);
-       TexGen tg_s, tg_t, tg_r;
-       tg_s.set_plane(Vector4(shadow_matrix(0, 0), shadow_matrix(0, 1), shadow_matrix(0, 2), shadow_matrix(0, 3)));
-       tg_t.set_plane(Vector4(shadow_matrix(1, 0), shadow_matrix(1, 1), shadow_matrix(1, 2), shadow_matrix(1, 3)));
-       tg_r.set_plane(Vector4(shadow_matrix(2, 0), shadow_matrix(2, 1), shadow_matrix(2, 2), shadow_matrix(2, 3)));
-       tg_s.bind_to(unit, SCOORD);
-       tg_t.bind_to(unit, TCOORD);
-       tg_r.bind_to(unit, RCOORD);
 
        if(const Camera *camera = renderer.get_camera())
                /* Multiply by camera's object matrix to form a matrix that transforms
@@ -146,10 +137,6 @@ void ShadowMap::render(Renderer &renderer, const Tag &tag) const
 
        renderer.add_shader_data(shdata);
        renderer.render(renderable, tag);
-
-       TexGen::unbind_from(unit, SCOORD);
-       TexGen::unbind_from(unit, TCOORD);
-       TexGen::unbind_from(unit, RCOORD);
 }
 
 } // namespace GL
index f8489ede9cfee6787520265d1bc5e1b5cc655a4a..8e24bb52facc436a0a75451a57726737a574bb22 100644 (file)
@@ -3,32 +3,6 @@
 namespace Msp {
 namespace GL {
 
-AlphaTest::AlphaTest():
-       pred(ALWAYS),
-       ref(0)
-{ }
-
-AlphaTest::AlphaTest(Predicate p, float r):
-       pred(p),
-       ref(r)
-{ }
-
-void AlphaTest::bind() const
-{
-       if(set_current(this))
-       {
-               glEnable(GL_ALPHA_TEST);
-               glAlphaFunc(pred, ref);
-       }
-}
-
-void AlphaTest::unbind()
-{
-       if(set_current(0))
-               glDisable(GL_ALPHA_TEST);
-}
-
-
 DepthTest::DepthTest():
        write(true),
        pred(LESS)
index 0d7e2384dcaea1bf3990048d9f396e377b1035a7..f7d729504a37f34b477a635675197f4166c29791 100644 (file)
@@ -8,26 +8,6 @@
 namespace Msp {
 namespace GL {
 
-/**
-Tests incoming fragment alpha values against a reference.  If the test fails,
-the fragment is discarded.
-*/
-class AlphaTest: public Bindable<AlphaTest>
-{
-private:
-       Predicate pred;
-       float ref;
-
-public:
-       AlphaTest();
-       AlphaTest(Predicate, float);
-
-       void bind() const;
-
-       static void unbind();
-};
-
-
 /**
 Tests incoming fragment depth values against the depth buffer.  If the test
 fails, the fragment is discarded.
diff --git a/source/texenv.cpp b/source/texenv.cpp
deleted file mode 100644 (file)
index c8af55f..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#include "texenv.h"
-#include "texunit.h"
-
-namespace Msp {
-namespace GL {
-
-TexEnv::TexEnv():
-       mode(MODULATE),
-       color(0, 0, 0, 0)
-{ }
-
-TexEnv::~TexEnv()
-{
-       if(this!=&default_object())
-       {
-               while(TexUnit *unit = TexUnit::find_unit(this))
-                       unbind_from(unit->get_index());
-       }
-}
-
-const TexEnv &TexEnv::default_object()
-{
-       static TexEnv obj;
-       return obj;
-}
-
-void TexEnv::update_parameter(int mask) const
-{
-       if(TexUnit::current().get_texenv()!=this)
-       {
-               TexUnit *unit = TexUnit::find_unit(this);
-               if(!unit)
-                       return;
-
-               unit->bind();
-       }
-
-       if(mask&MODE)
-               glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
-       if(mask&COLOR)
-               glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &color.r);
-}
-
-void TexEnv::set_mode(TexEnvMode m)
-{
-       mode = m;
-       update_parameter(MODE);
-}
-
-void TexEnv::set_color(const Color &c)
-{
-       color = c;
-       update_parameter(COLOR);
-}
-
-void TexEnv::bind_to(unsigned i) const
-{
-       TexUnit &unit = TexUnit::get_unit(i);
-       if(unit.set_texenv(this))
-       {
-               unit.bind();
-               update_parameter(-1);
-       }
-}
-
-const TexEnv *TexEnv::current(unsigned i)
-{
-       return TexUnit::get_unit(i).get_texenv();
-}
-
-void TexEnv::unbind_from(unsigned i)
-{
-       default_object().bind_to(i);
-}
-
-} // namespace GL
-} // namespace Msp
diff --git a/source/texenv.h b/source/texenv.h
deleted file mode 100644 (file)
index c422331..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef MSP_GL_TEXENV_H_
-#define MSP_GL_TEXENV_H_
-
-#include "color.h"
-#include "gl.h"
-
-namespace Msp {
-namespace GL {
-
-enum TexEnvMode
-{
-       REPLACE  = GL_REPLACE,
-       MODULATE = GL_MODULATE,
-       DECAL    = GL_DECAL,
-       BLEND    = GL_BLEND,
-       ADD      = GL_ADD,
-       COMBINE  = GL_COMBINE
-};
-
-class TexEnv
-{
-private:
-       enum ParameterMask
-       {
-               MODE = 1,
-               COLOR = 2
-       };
-
-       TexEnvMode mode;
-       Color color;
-
-public:
-       TexEnv();
-       ~TexEnv();
-
-       static const TexEnv &default_object();
-
-private:
-       void update_parameter(int) const;
-
-public:
-       void set_mode(TexEnvMode);
-       void set_color(const Color &);
-       TexEnvMode get_mode() const { return mode; }
-       const Color &get_color() const { return color; }
-       void bind() const { bind_to(0); }
-       void bind_to(unsigned) const;
-
-       static const TexEnv *current(unsigned = 0);
-       static void unbind() { unbind_from(0); }
-       static void unbind_from(unsigned);
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif
diff --git a/source/texgen.cpp b/source/texgen.cpp
deleted file mode 100644 (file)
index 4310d19..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#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
diff --git a/source/texgen.h b/source/texgen.h
deleted file mode 100644 (file)
index 5858efb..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef MSP_GL_TEXGEN_H_
-#define MSP_GL_TEXGEN_H_
-
-#include "gl.h"
-#include "vector.h"
-
-namespace Msp {
-namespace GL {
-
-enum TexCoordComponent
-{
-       SCOORD = GL_S,
-       TCOORD = GL_T,
-       RCOORD = GL_R,
-       QCOORD = GL_Q
-};
-
-enum TexGenMode
-{
-       EYE_LINEAR = GL_EYE_LINEAR,
-       OBJECT_LINEAR = GL_OBJECT_LINEAR,
-       REFLECTION_MAP = GL_REFLECTION_MAP,
-       NORMAL_MAP = GL_NORMAL_MAP
-};
-
-class TexGen
-{
-private:
-       TexGenMode mode;
-       Vector4 plane;
-
-public:
-       TexGen();
-       ~TexGen();
-
-       void set_mode(TexGenMode);
-       void set_plane(const Vector4 &);
-
-       void bind_to(TexCoordComponent c) const { bind_to(0, c); }
-       void bind_to(unsigned, TexCoordComponent) const;
-
-       static const TexGen *current(TexCoordComponent c) { return current(0, c); }
-       static const TexGen *current(unsigned, TexCoordComponent);
-       static void unbind_from(TexCoordComponent c) { unbind_from(0, c); }
-       static void unbind_from(unsigned, TexCoordComponent);
-private:
-       static unsigned coord_index(TexCoordComponent);
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif
index 1c8410c57a6bff3ee9388805964a1cca0876981c..db8ee65359a87993fe707fd0182bda4f210e1f51 100644 (file)
@@ -1,4 +1,3 @@
-#include "texenv.h"
 #include "texture.h"
 #include "texturing.h"
 #include "texunit.h"
@@ -16,20 +15,15 @@ Texturing::~Texturing()
 
 void Texturing::attach(unsigned attch, const Texture &tex)
 {
-       set_attachment(attch, &tex, 0);
-}
-
-void Texturing::attach(unsigned attch, const Texture &tex, const TexEnv &env)
-{
-       set_attachment(attch, &tex, &env);
+       set_attachment(attch, &tex);
 }
 
 void Texturing::detach(unsigned attch)
 {
-       set_attachment(attch, 0, 0);
+       set_attachment(attch, 0);
 }
 
-void Texturing::set_attachment(unsigned attch, const Texture *tex, const TexEnv *env)
+void Texturing::set_attachment(unsigned attch, const Texture *tex)
 {
        if(attch>=TexUnit::get_n_units())
                throw out_of_range("Texturing::set_attachment");
@@ -38,7 +32,6 @@ void Texturing::set_attachment(unsigned attch, const Texture *tex, const TexEnv
                attachments.resize(attch+1);
 
        attachments[attch].tex = tex;
-       attachments[attch].env = env;
 
        if(current()==this)
                bind_attachment(attch);
@@ -51,16 +44,11 @@ void Texturing::bind_attachment(unsigned i) const
                attch.tex->bind_to(i);
        else
                Texture::unbind_from(i);
-       if(attch.env)
-               attch.env->bind_to(i);
-       else
-               TexEnv::unbind_from(i);
 }
 
 void Texturing::unbind_attachment(unsigned i)
 {
        Texture::unbind_from(i);
-       TexEnv::unbind_from(i);
 }
 
 void Texturing::bind() const
@@ -90,8 +78,7 @@ void Texturing::unbind()
 
 
 Texturing::Attachment::Attachment():
-       tex(0),
-       env(0)
+       tex(0)
 { }
 
 } // namespace GL
index 51070ffa4d06cdbf3291529eef50cb1ca7a27821..daeb2bb812d7bfe62331951070a9fb4977d18490 100644 (file)
@@ -7,7 +7,6 @@
 namespace Msp {
 namespace GL {
 
-class TexEnv;
 class Texture;
 
 class Texturing: public Bindable<Texturing>
@@ -16,7 +15,6 @@ private:
        struct Attachment
        {
                const Texture *tex;
-               const TexEnv *env;
 
                Attachment();
        };
@@ -27,10 +25,9 @@ public:
        ~Texturing();
 
        void attach(unsigned, const Texture &);
-       void attach(unsigned, const Texture &, const TexEnv &);
        void detach(unsigned);
 private:
-       void set_attachment(unsigned, const Texture *, const TexEnv *);
+       void set_attachment(unsigned, const Texture *);
        void bind_attachment(unsigned) const;
 
        static void unbind_attachment(unsigned);
index fd36a4f15b5e77b7455af08ed4133f6e578c8c44..9b905120db6861d54204b172264d58c6f5340383 100644 (file)
@@ -14,11 +14,8 @@ vector<TexUnit> TexUnit::units;
 TexUnit *TexUnit::cur_unit = 0;
 
 TexUnit::TexUnit():
-       texture(0),
-       texenv(0)
-{
-       fill(texgen, texgen+4, static_cast<const TexGen *>(0));
-}
+       texture(0)
+{ }
 
 bool TexUnit::set_texture(const Texture *tex)
 {
@@ -27,29 +24,6 @@ bool TexUnit::set_texture(const Texture *tex)
        return result;
 }
 
-bool TexUnit::set_texenv(const TexEnv *env)
-{
-       bool result = (texenv!=env);
-       texenv = env;
-       return result;
-}
-
-bool TexUnit::set_texgen(unsigned i, const TexGen *gen)
-{
-       if(i>=4)
-               throw out_of_range("TexUnit::set_texgen");
-       bool result = (texgen[i]!=gen);
-       texgen[i] = gen;
-       return result;
-}
-
-const TexGen *TexUnit::get_texgen(unsigned i)
-{
-       if(i>=4)
-               throw out_of_range("TexUnit::get_texgen");
-       return texgen[i];
-}
-
 void TexUnit::bind()
 {
        if(cur_unit!=this && (cur_unit || index))
@@ -105,13 +79,5 @@ TexUnit *TexUnit::find_unit(const Texture *tex)
        return 0;
 }
 
-TexUnit *TexUnit::find_unit(const TexEnv *env)
-{
-       for(vector<TexUnit>::iterator i=units.begin(); i!=units.end(); ++i)
-               if(i->texenv==env)
-                       return &*i;
-       return 0;
-}
-
 } // namespace GL
 } // namespace Msp
index 9c4d93f6971ea5b60b10b78b367a60a81092a629..f3f95e7e422b2179ffea94f6d9c3834891ea8bc9 100644 (file)
@@ -18,8 +18,6 @@ class TexUnit
 private:
        unsigned index;
        const Texture *texture;
-       const TexEnv *texenv;
-       const TexGen *texgen[4];
 
        static std::vector<TexUnit> units;
        static TexUnit *cur_unit;
@@ -30,17 +28,12 @@ public:
        unsigned get_index() const { return index; }
        bool set_texture(const Texture *);
        const Texture *get_texture() const { return texture; }
-       bool set_texenv(const TexEnv *);
-       const TexEnv *get_texenv() const { return texenv; }
-       bool set_texgen(unsigned, const TexGen *);
-       const TexGen *get_texgen(unsigned);
        void bind();
 
        static unsigned get_n_units();
        static TexUnit &get_unit(unsigned);
        static TexUnit &current();
        static TexUnit *find_unit(const Texture *);
-       static TexUnit *find_unit(const TexEnv *);
 };
 
 } // namespace GL