]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove support for legacy OpenGL features
authorMikko Rasa <mikko.rasa@mikkosoft.fi>
Sun, 20 Oct 2019 17:20:57 +0000 (20:20 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 23 Oct 2019 23:45:29 +0000 (02:45 +0300)
This includes all fixed-point functionality as well as the
NV_primitive_restart and SGIS_generate_mipmap extensions, which have
better alternatives available in modern OpenGL.

49 files changed:
extensions/msp_legacy_features.glext [deleted file]
extensions/nv_primitive_restart.glext [deleted file]
extensions/sgis_generate_mipmap.glext [deleted file]
gl.msp.xml
source/batch.cpp
source/camera.cpp
source/camera.h
source/clipping.cpp
source/clipping.h
source/clipplane.cpp
source/clipplane.h
source/clipunit.cpp [deleted file]
source/clipunit.h [deleted file]
source/extension.cpp
source/font.cpp
source/light.cpp
source/light.h
source/lighting.cpp
source/lighting.h
source/lightunit.cpp [deleted file]
source/lightunit.h [deleted file]
source/material.cpp
source/material.h
source/matrix.cpp
source/matrix.h
source/mesh.cpp
source/pixelformat.cpp
source/pixelformat.h
source/primitivetype.cpp
source/primitivetype.h
source/program.cpp
source/program.h
source/renderer.cpp
source/renderer.h
source/text.cpp
source/texture.cpp
source/texture.h
source/texture1d.cpp
source/texture2d.cpp
source/texture3d.cpp
source/texturecube.cpp
source/texturing.cpp
source/texturing.h
source/texunit.cpp
source/texunit.h
source/vertexarray.cpp
source/vertexarray.h
source/vertexbuilder.h
source/vertexformat.h

diff --git a/extensions/msp_legacy_features.glext b/extensions/msp_legacy_features.glext
deleted file mode 100644 (file)
index 7128081..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extension MSP_legacy_features
diff --git a/extensions/nv_primitive_restart.glext b/extensions/nv_primitive_restart.glext
deleted file mode 100644 (file)
index 4321861..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extension NV_primitive_restart
diff --git a/extensions/sgis_generate_mipmap.glext b/extensions/sgis_generate_mipmap.glext
deleted file mode 100644 (file)
index 9ccaffc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extension SGIS_generate_mipmap
index a1787cb02f124fb3dbf0a1a2752f5025bbf43d0c..0309a61d9b21bbc35156a98fd4deba00e0b12d12 100644 (file)
@@ -5,67 +5,6 @@
     extension. -->
 
     <extensions>
     extension. -->
 
     <extensions>
-        <extension name="GL_MSP_legacy_features" supported="gl">
-            <require>
-                <command name="glEnableClientState" />
-                <command name="glDisableClientState" />
-
-                <enum name="GL_QUADS" />
-                <enum name="GL_QUAD_STRIP" />
-                <enum name="GL_LUMINANCE8" />
-                <enum name="GL_LUMINANCE8_ALPHA8" />
-
-                <enum name="GL_AMBIENT" />
-                <enum name="GL_DIFFUSE" />
-                <enum name="GL_SPECULAR" />
-                <enum name="GL_EMISSION" />
-                <enum name="GL_SHININESS" />
-                <enum name="GL_LIGHTING" />
-                <enum name="GL_LIGHT_MODEL_AMBIENT" />
-                <enum name="GL_LIGHT0" />
-                <enum name="GL_MAX_LIGHTS" />
-                <enum name="GL_POSITION" />
-                <enum name="GL_SPOT_DIRECTION" />
-                <enum name="GL_SPOT_EXPONENT" />
-                <enum name="GL_SPOT_CUTOFF" />
-                <enum name="GL_CONSTANT_ATTENUATION" />
-                <enum name="GL_LINEAR_ATTENUATION" />
-                <enum name="GL_QUADRATIC_ATTENUATION" />
-                <command name="glLightModelfv" />
-                <command name="glLightf" />
-                <command name="glLightfv" />
-                <command name="glMaterialf" />
-                <command name="glMaterialfv" />
-
-                <enum name="GL_FOG" />
-                <enum name="GL_FOG_MODE" />
-                <enum name="GL_FOG_DENSITY" />
-                <enum name="GL_FOG_COLOR" />
-                <enum name="GL_EXP" />
-                <command name="glFogi" />
-                <command name="glFogf" />
-                <command name="glFogfv" />
-
-                <enum name="GL_MODELVIEW" />
-                <enum name="GL_PROJECTION" />
-                <command name="glMatrixMode" />
-                <command name="glLoadMatrixf" />
-
-                <!-- Can't reuse EXT_vertex_array for these, as the functions
-                defined there have different signatures. -->
-                <enum name="GL_VERTEX_ARRAY" />
-                <enum name="GL_NORMAL_ARRAY" />
-                <enum name="GL_COLOR_ARRAY" />
-                <enum name="GL_TEXTURE_COORD_ARRAY" />
-                <command name="glVertexPointer" />
-                <command name="glNormalPointer" />
-                <command name="glColorPointer" />
-                <command name="glTexCoordPointer" />
-
-                <command name="glClipPlane" />
-            </require>
-        </extension>
-
         <!-- OpenGL ES does not have glDrawBuffer. -->
         <extension name="GL_MSP_buffer_control" supported="gl">
             <require>
         <!-- OpenGL ES does not have glDrawBuffer. -->
         <extension name="GL_MSP_buffer_control" supported="gl">
             <require>
index af1d243e6cba1551e6be65255a55e69a4e7029cf..b61da0bac79aee1507ac536efa46815c6a5c127a 100644 (file)
@@ -1,8 +1,6 @@
 #include <msp/gl/extensions/arb_draw_instanced.h>
 #include <msp/gl/extensions/ext_draw_range_elements.h>
 #include <msp/gl/extensions/arb_draw_instanced.h>
 #include <msp/gl/extensions/ext_draw_range_elements.h>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include <msp/gl/extensions/msp_primitive_restart.h>
 #include <msp/gl/extensions/msp_primitive_restart.h>
-#include <msp/gl/extensions/nv_primitive_restart.h>
 #include "batch.h"
 #include "bindable.h"
 #include "buffer.h"
 #include "batch.h"
 #include "bindable.h"
 #include "buffer.h"
@@ -124,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)
        if(other_type!=prim_type)
                return false;
        else if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN)
-               return MSP_primitive_restart || NV_primitive_restart;
+               return MSP_primitive_restart;
        else
                return true;
 }
        else
                return true;
 }
@@ -134,21 +132,14 @@ Batch &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)
        if(other.prim_type!=prim_type)
                throw invalid_argument("Batch::append");
        if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN)
-       {
-               if(!MSP_primitive_restart)
-               {
-                       static Require _req(NV_primitive_restart);
-                       // Make sure we have glEnable/DisableClientState as well
-                       static Require _req2(MSP_legacy_features);
-               }
-       }
+               static Require _req(MSP_primitive_restart);
 
        if(other.data.empty())
                return *this;
 
 
        if(other.data.empty())
                return *this;
 
-       if(prim_type==POINTS || prim_type==LINES || prim_type==TRIANGLES || prim_type==QUADS)
+       if(prim_type==POINTS || prim_type==LINES || prim_type==TRIANGLES)
                ;
                ;
-       else if(MSP_primitive_restart || NV_primitive_restart)
+       else if(MSP_primitive_restart)
        {
                restart = true;
                if(data_type==UNSIGNED_SHORT)
        {
                restart = true;
                if(data_type==UNSIGNED_SHORT)
@@ -165,13 +156,6 @@ Batch &Batch::append(const Batch &other)
                if(size()&1)
                        append(other.get_index(0));
        }
                if(size()&1)
                        append(other.get_index(0));
        }
-       else if(prim_type==QUAD_STRIP)
-       {
-               append(get_index(size()-1));
-               append(get_index(size()-1));
-               append(other.get_index(0));
-               append(other.get_index(0));
-       }
 
        unsigned count = other.size();
        for(unsigned i=0; i<count; ++i)
 
        unsigned count = other.size();
        for(unsigned i=0; i<count; ++i)
@@ -277,28 +261,14 @@ const void *Batch::setup_draw() const
 
 void Batch::set_restart_index(unsigned index)
 {
 
 void Batch::set_restart_index(unsigned index)
 {
-       if(MSP_primitive_restart)
+       if(index>0)
        {
        {
-               if(index>0)
-               {
-                       if(!restart_index)
-                               glEnable(GL_PRIMITIVE_RESTART);
-                       glPrimitiveRestartIndex(index);
-               }
-               else
-                       glDisable(GL_PRIMITIVE_RESTART);
+               if(!restart_index)
+                       glEnable(GL_PRIMITIVE_RESTART);
+               glPrimitiveRestartIndex(index);
        }
        else
        }
        else
-       {
-               if(index>0)
-               {
-                       if(!restart_index)
-                               glEnableClientState(GL_PRIMITIVE_RESTART_NV);
-                       glPrimitiveRestartIndexNV(index);
-               }
-               else
-                       glDisableClientState(GL_PRIMITIVE_RESTART_NV);
-       }
+               glDisable(GL_PRIMITIVE_RESTART);
 
        restart_index = index;
 }
 
        restart_index = index;
 }
index b3cedbc62ad628813b5eee552302a2151ea586c1..3bba0eaf38e00385e68a077474095a980a10f340 100644 (file)
@@ -116,12 +116,6 @@ Vector3 Camera::unproject(const Vector3 &p) const
        return unproject(Vector4(p.x, p.y, p.z, 1.0f)).slice<3>(0);
 }
 
        return unproject(Vector4(p.x, p.y, p.z, 1.0f)).slice<3>(0);
 }
 
-void Camera::apply() const
-{
-       MatrixStack::projection() = proj_matrix;
-       MatrixStack::modelview() = view_matrix;
-}
-
 void Camera::update_projection_matrix()
 {
        float frustum_h = (fov!=Geometry::Angle<float>::zero() ? tan(fov/2.0f)*clip_near : height/2);
 void Camera::update_projection_matrix()
 {
        float frustum_h = (fov!=Geometry::Angle<float>::zero() ? tan(fov/2.0f)*clip_near : height/2);
index a58023017745e37b65179b283c9e1ff3f928f2c2..d0e80bc9b795ca989fda0493c75e791e33524baa 100644 (file)
@@ -93,8 +93,6 @@ public:
        Vector4 unproject(const Vector4 &) const;
        Vector3 unproject(const Vector3 &) const;
 
        Vector4 unproject(const Vector4 &) const;
        Vector3 unproject(const Vector3 &) const;
 
-       void apply() const;
-
 private:
        void update_projection_matrix();
        void update_object_matrix();
 private:
        void update_projection_matrix();
        void update_object_matrix();
index 6508ecf7f695306df3e76cf4e7f03689e00eee8b..3bdeee3ca8b3367624504f9815338f1810c4dcb9 100644 (file)
@@ -1,8 +1,6 @@
 #include <msp/gl/extensions/msp_clipping.h>
 #include <msp/gl/extensions/msp_clipping.h>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include "clipping.h"
 #include "clipplane.h"
 #include "clipping.h"
 #include "clipplane.h"
-#include "clipunit.h"
 #include "matrix.h"
 #include "misc.h"
 
 #include "matrix.h"
 #include "misc.h"
 
@@ -11,11 +9,16 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
 namespace Msp {
 namespace GL {
 
-bool Clipping::bound_with_legacy = false;
+unsigned Clipping::get_n_attach_points()
+{
+       static Require _req(MSP_clipping);
+       static int count = get_i(GL_MAX_CLIP_PLANES);
+       return count;
+}
 
 void Clipping::attach(unsigned i, const ClipPlane &p)
 {
 
 void Clipping::attach(unsigned i, const ClipPlane &p)
 {
-       if(i>=ClipUnit::get_n_units())
+       if(i>=get_n_attach_points())
                throw out_of_range("Clipping::attach");
 
        if(i>=planes.size())
                throw out_of_range("Clipping::attach");
 
        if(i>=planes.size())
@@ -23,12 +26,7 @@ void Clipping::attach(unsigned i, const ClipPlane &p)
 
        planes[i] = &p;
        if(current()==this)
 
        planes[i] = &p;
        if(current()==this)
-       {
-               if(bound_with_legacy)
-                       p.bind_to(i);
-               else
-                       glEnable(GL_CLIP_PLANE0+i);
-       }
+               glEnable(GL_CLIP_PLANE0+i);
 }
 
 void Clipping::detach(unsigned i)
 }
 
 void Clipping::detach(unsigned i)
@@ -38,12 +36,7 @@ void Clipping::detach(unsigned i)
 
        planes[i] = 0;
        if(current()==this)
 
        planes[i] = 0;
        if(current()==this)
-       {
-               if(bound_with_legacy)
-                       ClipPlane::unbind_from(i);
-               else
-                       disable(GL_CLIP_PLANE0+i);
-       }
+               disable(GL_CLIP_PLANE0+i);
 }
 
 void Clipping::update_shader_data(ProgramData &shdata, const Matrix &view_matrix) const
 }
 
 void Clipping::update_shader_data(ProgramData &shdata, const Matrix &view_matrix) const
@@ -54,51 +47,26 @@ void Clipping::update_shader_data(ProgramData &shdata, const Matrix &view_matrix
                        planes[i]->update_shader_data(shdata, view_inverse, i);
 }
 
                        planes[i]->update_shader_data(shdata, view_inverse, i);
 }
 
-void Clipping::bind(bool legacy) const
+void Clipping::bind() const
 {
        static Require _req(MSP_clipping);
 {
        static Require _req(MSP_clipping);
-       if(legacy)
-               static Require _req2(MSP_legacy_features);
-       
-       if(legacy!=bound_with_legacy)
-               unbind();
 
        const Clipping *old = current();
        if(!set_current(this))
                return;
 
 
        const Clipping *old = current();
        if(!set_current(this))
                return;
 
-       bound_with_legacy = legacy;
-       if(legacy)
+       for(unsigned i=0; i<planes.size(); ++i)
        {
        {
-               for(unsigned i=0; i<planes.size(); ++i)
-               {
-                       if(planes[i])
-                               planes[i]->bind_to(i);
-                       else
-                               ClipPlane::unbind_from(i);
-               }
-
-               if(old)
-               {
-                       for(unsigned i=planes.size(); i<old->planes.size(); ++i)
-                               ClipPlane::unbind_from(i);
-               }
+               if(planes[i])
+                       enable(GL_CLIP_PLANE0+i);
+               else
+                       disable(GL_CLIP_PLANE0+i);
        }
        }
-       else
+
+       if(old)
        {
        {
-               for(unsigned i=0; i<planes.size(); ++i)
-               {
-                       if(planes[i])
-                               enable(GL_CLIP_PLANE0+i);
-                       else
-                               disable(GL_CLIP_PLANE0+i);
-               }
-
-               if(old)
-               {
-                       for(unsigned i=planes.size(); i<old->planes.size(); ++i)
-                               disable(GL_CLIP_PLANE0+i);
-               }
+               for(unsigned i=planes.size(); i<old->planes.size(); ++i)
+                       disable(GL_CLIP_PLANE0+i);
        }
 }
 
        }
 }
 
@@ -108,18 +76,9 @@ void Clipping::unbind()
        if(!set_current(0))
                return;
 
        if(!set_current(0))
                return;
 
-       if(bound_with_legacy)
-       {
-               for(unsigned i=0; i<old->planes.size(); ++i)
-                       if(old->planes[i])
-                               ClipPlane::unbind_from(i);
-       }
-       else
-       {
-               for(unsigned i=0; i<old->planes.size(); ++i)
-                       if(old->planes[i])
-                               disable(GL_CLIP_PLANE0+i);
-       }
+       for(unsigned i=0; i<old->planes.size(); ++i)
+               if(old->planes[i])
+                       disable(GL_CLIP_PLANE0+i);
 }
 
 } // namespace GL
 }
 
 } // namespace GL
index 2a4330bac2ecb55dfffae77534ad4196418c3de7..e42c28e6394b6c1c519afc26f182957b1f75be20 100644 (file)
@@ -16,15 +16,15 @@ class Clipping: public Bindable<Clipping>
 private:
        std::vector<const ClipPlane *> planes;
 
 private:
        std::vector<const ClipPlane *> planes;
 
-       static bool bound_with_legacy;
-
 public:
 public:
+       static unsigned get_n_attach_points();
+
        void attach(unsigned, const ClipPlane &);
        void detach(unsigned);
 
        void update_shader_data(ProgramData &, const Matrix &) const;
 
        void attach(unsigned, const ClipPlane &);
        void detach(unsigned);
 
        void update_shader_data(ProgramData &, const Matrix &) const;
 
-       void bind(bool legacy = true) const;
+       void bind() const;
 
        static void unbind();
 };
 
        static void unbind();
 };
index 21df0d17e36e1dc63567de245649e8634f03fd11..4adf2bf5a45d55b1707b85f40629cd7597189ee7 100644 (file)
@@ -1,8 +1,5 @@
-#include <msp/gl/extensions/msp_clipping.h>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include <msp/strings/format.h>
 #include "clipplane.h"
 #include <msp/strings/format.h>
 #include "clipplane.h"
-#include "clipunit.h"
 #include "gl.h"
 #include "matrix.h"
 #include "misc.h"
 #include "gl.h"
 #include "matrix.h"
 #include "misc.h"
@@ -23,19 +20,9 @@ ClipPlane::ClipPlane(const Vector3 &p, const Vector3 &d):
        eq(compose(d, -dot(p, d)))
 { }
 
        eq(compose(d, -dot(p, d)))
 { }
 
-void ClipPlane::update(unsigned index) const
-{
-       double deq[4];
-       for(unsigned i=0; i<4; ++i)
-               deq[i] = eq[i];
-       glClipPlane(GL_CLIP_PLANE0+index, deq);
-}
-
 void ClipPlane::set_equation(const Vector4 &e)
 {
        eq = e;
 void ClipPlane::set_equation(const Vector4 &e)
 {
        eq = e;
-       if(ClipUnit *unit = ClipUnit::find_unit(this))
-               update(unit->get_index());
 }
 
 void ClipPlane::set_plane(const Vector3 &p, const Vector3 &d)
 }
 
 void ClipPlane::set_plane(const Vector3 &p, const Vector3 &d)
@@ -49,25 +36,5 @@ void ClipPlane::update_shader_data(ProgramData &shdata, const Matrix &view_inver
        shdata.uniform(format("clip_planes[%d].equation", i), eq*view_inverse);
 }
 
        shdata.uniform(format("clip_planes[%d].equation", i), eq*view_inverse);
 }
 
-void ClipPlane::bind_to(unsigned i) const
-{
-       Require _req(MSP_clipping);
-       Require _req2(MSP_legacy_features);
-
-       ClipUnit &unit = ClipUnit::get_unit(i);
-       if(unit.set_plane(this))
-       {
-               enable(GL_CLIP_PLANE0+unit.get_index());
-               update(unit.get_index());
-       }
-}
-
-void ClipPlane::unbind_from(unsigned i)
-{
-       ClipUnit &unit = ClipUnit::get_unit(i);
-       if(unit.set_plane(0))
-               disable(GL_CLIP_PLANE0+unit.get_index());
-}
-
 } // namespace GL
 } // namespace Msp
 } // namespace GL
 } // namespace Msp
index cc3efd0f42bf2c8d439b4f1a46fbb897d8d2e134..98c633b70fd7933bedf39824aa0abe851b2f6412 100644 (file)
@@ -19,16 +19,9 @@ public:
        ClipPlane(const Vector4 &);
        ClipPlane(const Vector3 &, const Vector3 &);
 
        ClipPlane(const Vector4 &);
        ClipPlane(const Vector3 &, const Vector3 &);
 
-private:
-       void update(unsigned) const;
-public:
        void set_equation(const Vector4 &);
        void set_plane(const Vector3 &, const Vector3 &);
        void update_shader_data(ProgramData &, const Matrix &, unsigned) const;
        void set_equation(const Vector4 &);
        void set_plane(const Vector3 &, const Vector3 &);
        void update_shader_data(ProgramData &, const Matrix &, unsigned) const;
-
-       void bind_to(unsigned) const;
-
-       static void unbind_from(unsigned);
 };
 
 } // namespace GL
 };
 
 } // namespace GL
diff --git a/source/clipunit.cpp b/source/clipunit.cpp
deleted file mode 100644 (file)
index 2db721c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <msp/gl/extensions/msp_clipping.h>
-#include <stdexcept>
-#include "clipunit.h"
-#include "gl.h"
-#include "misc.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-vector<ClipUnit> ClipUnit::units;
-
-ClipUnit::ClipUnit():
-       index(0),
-       plane(0)
-{ }
-
-bool ClipUnit::set_plane(const ClipPlane *p)
-{
-       bool result = (p!=plane);
-       plane = p;
-       return result;
-}
-
-unsigned ClipUnit::get_n_units()
-{
-       static Require _req(MSP_clipping);
-       static int count = get_i(GL_MAX_CLIP_PLANES);
-       return count;
-}
-
-ClipUnit &ClipUnit::get_unit(unsigned i)
-{
-       if(i>=get_n_units())
-               throw out_of_range("ClipUnit::get_unit");
-
-       if(units.size()<=i)
-       {
-               unsigned j = units.size();
-               units.resize(i+1, ClipUnit());
-               for(; j<units.size(); ++j)
-                       units[j].index = j;
-       }
-
-       return units[i];
-}
-
-ClipUnit *ClipUnit::find_unit(const ClipPlane *p)
-{
-       for(vector<ClipUnit>::iterator i=units.begin(); i!=units.end(); ++i)
-               if(i->plane==p)
-                       return &*i;
-       return 0;
-}
-
-} // namespace GL
-} // namespace Msp
diff --git a/source/clipunit.h b/source/clipunit.h
deleted file mode 100644 (file)
index b4af967..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef MSP_GL_CLIPUNIT_H_
-#define MSP_GL_CLIPUNIT_H_
-
-#include <vector>
-
-namespace Msp {
-namespace GL {
-
-class ClipPlane;
-
-class ClipUnit
-{
-private:
-       unsigned index;
-       const ClipPlane *plane;
-
-       static std::vector<ClipUnit> units;
-
-       ClipUnit();
-
-public:
-       unsigned get_index() const { return index; }
-       bool set_plane(const ClipPlane *);
-       const ClipPlane *get_plane() const { return plane; } 
-
-       static unsigned get_n_units();
-       static ClipUnit &get_unit(unsigned);
-       static ClipUnit *find_unit(const ClipPlane *);
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif
index 21fab9a290161b55cb46d234bb5cb43ffa742a08..8618cc3eeef599e7c7a1dc36fe2ef724f234e91f 100644 (file)
@@ -139,11 +139,6 @@ bool is_disabled(const string &ext)
                        string renderer = renderer_ptr;
                        if(renderer.find("Radeon")!=string::npos || renderer.find("AMD")!=string::npos)
                        {
                        string renderer = renderer_ptr;
                        if(renderer.find("Radeon")!=string::npos || renderer.find("AMD")!=string::npos)
                        {
-                               /* Radeon doesn't process NV_primitive_restart correctly and treats
-                               the restart index as a normal element if the indices are stored in a
-                               buffer. */
-                               disabled_exts.insert("GL_NV_primitive_restart");
-
                                // The core primitive restart feature does not work either.
                                disabled_exts.insert("GL_MSP_primitive_restart");
 
                                // The core primitive restart feature does not work either.
                                disabled_exts.insert("GL_MSP_primitive_restart");
 
index fba9f331fb7e7cbcceaaf04e21eca8215f89aa46..623f1ebebda04df2e97909b66c51416602e694a6 100644 (file)
@@ -74,7 +74,7 @@ void Font::draw_string(const string &str, StringCodec::Decoder &dec, const Color
 
 void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveBuilder &bld) const
 {
 
 void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveBuilder &bld) const
 {
-       MatrixStack::Push push_mtx(bld.matrix());
+       VertexBuilder::PushMatrix push_mtx(bld);
 
        unsigned prev = 0;
        unsigned next = 0;
 
        unsigned prev = 0;
        unsigned next = 0;
@@ -94,7 +94,7 @@ void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveB
                        continue;
 
                if(prev)
                        continue;
 
                if(prev)
-                       bld.matrix() *= Matrix::translation(get_glyph_advance(prev, c), 0, 0);
+                       bld.transform(Matrix::translation(get_glyph_advance(prev, c), 0, 0));
 
                create_glyph_quad(j->second, bld);
                prev = c;
 
                create_glyph_quad(j->second, bld);
                prev = c;
index 4ba581e029f0083068e1517b1b870b4d7b552c18..8104e8969b1baf373b8bd64097dcc1bda72c27f5 100644 (file)
@@ -1,8 +1,6 @@
 #include <stdexcept>
 #include <stdexcept>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include <msp/strings/format.h>
 #include "light.h"
 #include <msp/strings/format.h>
 #include "light.h"
-#include "lightunit.h"
 #include "matrix.h"
 #include "misc.h"
 #include "programdata.h"
 #include "matrix.h"
 #include "misc.h"
 #include "programdata.h"
@@ -25,44 +23,6 @@ Light::Light():
        attenuation[2] = 0;
 }
 
        attenuation[2] = 0;
 }
 
-Light::~Light()
-{
-       while(LightUnit *unit = LightUnit::find_unit(this))
-               unbind_from(unit->get_index());
-}
-
-void Light::update_parameter(int mask, int index) const
-{
-       if(index<0)
-       {
-               LightUnit *unit = LightUnit::find_unit(this);
-               if(!unit)
-                       return;
-
-               index = unit->get_index();
-       }
-
-       GLenum l = GL_LIGHT0+index;
-       if(mask&DIFFUSE)
-               glLightfv(l, GL_DIFFUSE, &diffuse.r);
-       if(mask&SPECULAR)
-               glLightfv(l, GL_SPECULAR, &specular.r);
-       if(mask&POSITION)
-               glLightfv(l, GL_POSITION, &position.x);
-       if(mask&SPOT_DIR)
-               glLightfv(l, GL_SPOT_DIRECTION, &spot_dir.x);
-       if(mask&SPOT_EXP)
-               glLightf(l, GL_SPOT_EXPONENT, spot_exp);
-       if(mask&SPOT_CUTOFF)
-               glLightf(l, GL_SPOT_CUTOFF, spot_cutoff.degrees());
-       if(mask&ATTENUATION)
-       {
-               glLightf(l, GL_CONSTANT_ATTENUATION, attenuation[0]);
-               glLightf(l, GL_LINEAR_ATTENUATION, attenuation[1]);
-               glLightf(l, GL_QUADRATIC_ATTENUATION, attenuation[2]);
-       }
-}
-
 void Light::update_matrix()
 {
        Vector3 up_dir;
 void Light::update_matrix()
 {
        Vector3 up_dir;
@@ -83,13 +43,11 @@ void Light::update_matrix()
 void Light::set_diffuse(const Color &c)
 {
        diffuse = c;
 void Light::set_diffuse(const Color &c)
 {
        diffuse = c;
-       update_parameter(DIFFUSE);
 }
 
 void Light::set_specular(const Color &c)
 {
        specular = c;
 }
 
 void Light::set_specular(const Color &c)
 {
        specular = c;
-       update_parameter(SPECULAR);
 }
 
 void Light::set_matrix(const Matrix &m)
 }
 
 void Light::set_matrix(const Matrix &m)
@@ -98,14 +56,12 @@ void Light::set_matrix(const Matrix &m)
        position = matrix.column(3);
        spot_dir = normalize(-matrix.column(2).slice<3>(0));
        direction = (position.w ? spot_dir : normalize(-position.slice<3>(0)));
        position = matrix.column(3);
        spot_dir = normalize(-matrix.column(2).slice<3>(0));
        direction = (position.w ? spot_dir : normalize(-position.slice<3>(0)));
-       update_parameter(POSITION|SPOT_DIR);
        update_matrix();
 }
 
 void Light::set_position(const Vector4 &p)
 {
        position = p;
        update_matrix();
 }
 
 void Light::set_position(const Vector4 &p)
 {
        position = p;
-       update_parameter(POSITION);
        if(!position.w)
                direction = normalize(-position.slice<3>(0));
        update_matrix();
        if(!position.w)
                direction = normalize(-position.slice<3>(0));
        update_matrix();
@@ -116,7 +72,6 @@ void Light::set_spot_direction(const Vector3 &d)
        spot_dir = normalize(d);
        if(position.w)
                direction = spot_dir;
        spot_dir = normalize(d);
        if(position.w)
                direction = spot_dir;
-       update_parameter(SPOT_DIR);
        update_matrix();
 }
 
        update_matrix();
 }
 
@@ -126,7 +81,6 @@ void Light::set_spot_exponent(float e)
                throw invalid_argument("Light::set_spot_exponent");
 
        spot_exp = e;
                throw invalid_argument("Light::set_spot_exponent");
 
        spot_exp = e;
-       update_parameter(SPOT_EXP);
 }
 
 void Light::set_spot_cutoff(float c)
 }
 
 void Light::set_spot_cutoff(float c)
@@ -140,7 +94,6 @@ void Light::set_spot_cutoff(const Geometry::Angle<float> &c)
                throw invalid_argument("Light::set_spot_cutoff");
 
        spot_cutoff = c;
                throw invalid_argument("Light::set_spot_cutoff");
 
        spot_cutoff = c;
-       update_parameter(SPOT_CUTOFF);
 }
 
 void Light::disable_spot_cutoff()
 }
 
 void Light::disable_spot_cutoff()
@@ -153,7 +106,6 @@ void Light::set_attenuation(float c, float l, float q)
        attenuation[0] = c;
        attenuation[1] = l;
        attenuation[2] = q;
        attenuation[0] = c;
        attenuation[1] = l;
        attenuation[2] = q;
-       update_parameter(ATTENUATION);
 }
 
 void Light::update_shader_data(ProgramData &shdata, const Matrix &view_matrix, unsigned i) const
 }
 
 void Light::update_shader_data(ProgramData &shdata, const Matrix &view_matrix, unsigned i) const
@@ -164,30 +116,6 @@ void Light::update_shader_data(ProgramData &shdata, const Matrix &view_matrix, u
        shdata.uniform(base+".specular", specular);
 }
 
        shdata.uniform(base+".specular", specular);
 }
 
-void Light::bind_to(unsigned i) const
-{
-       static Require _req(MSP_legacy_features);
-
-       LightUnit &unit = LightUnit::get_unit(i);
-       if(unit.set_light(this))
-       {
-               enable(GL_LIGHT0+unit.get_index());
-               update_parameter(-1, unit.get_index());
-       }
-}
-
-const Light *Light::current(unsigned i)
-{
-       return LightUnit::get_unit(i).get_light();
-}
-
-void Light::unbind_from(unsigned i)
-{
-       LightUnit &unit = LightUnit::get_unit(i);
-       if(unit.set_light(0))
-               disable(GL_LIGHT0+unit.get_index());
-}
-
 
 Light::Loader::Loader(Light &l):
        DataFile::ObjectLoader<Light>(l)
 
 Light::Loader::Loader(Light &l):
        DataFile::ObjectLoader<Light>(l)
index 31dc3c0db709285c7f918820752b9c668d2ddcbf..b2047262edbba6ec4aea310f5a50f01650939d0a 100644 (file)
@@ -44,17 +44,6 @@ public:
        };
 
 private:
        };
 
 private:
-       enum ParameterMask
-       {
-               DIFFUSE = 1,
-               SPECULAR = 2,
-               POSITION = 4,
-               SPOT_DIR = 8,
-               SPOT_EXP = 16,
-               SPOT_CUTOFF = 32,
-               ATTENUATION = 64
-       };
-
        Color diffuse;
        Color specular;
        Vector4 position;
        Color diffuse;
        Color specular;
        Vector4 position;
@@ -66,10 +55,8 @@ private:
 
 public:
        Light();
 
 public:
        Light();
-       ~Light();
 
 private:
 
 private:
-       void update_parameter(int, int = -1) const;
        void update_matrix();
 
 public:
        void update_matrix();
 
 public:
@@ -122,13 +109,6 @@ public:
        /** Updates a ProgramData object with the uniforms for the Light.  A view
        matrix and light source index must be passed in. */
        void update_shader_data(ProgramData &, const Matrix &, unsigned) const;
        /** Updates a ProgramData object with the uniforms for the Light.  A view
        matrix and light source index must be passed in. */
        void update_shader_data(ProgramData &, const Matrix &, unsigned) const;
-
-       void bind() const { return bind_to(0); }
-       void bind_to(unsigned) const;
-
-       static const Light *current(unsigned = 0);
-       static void unbind() { return unbind_from(0); }
-       static void unbind_from(unsigned);
 };
 
 } // namespace GL
 };
 
 } // namespace GL
index 108edf16b9ac848d6a2b34323abc60f8b60b9ea5..c6207a7673f574d73a01b51dbbb2ec506d383b16 100644 (file)
@@ -1,10 +1,8 @@
 #include <stdexcept>
 #include <cmath>
 #include <stdexcept>
 #include <cmath>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include "error.h"
 #include "light.h"
 #include "lighting.h"
 #include "error.h"
 #include "light.h"
 #include "lighting.h"
-#include "lightunit.h"
 #include "matrix.h"
 #include "misc.h"
 
 #include "matrix.h"
 #include "misc.h"
 
@@ -71,8 +69,6 @@ void Lighting::attach(unsigned i, const Light &l)
                lights.resize(i+1);
 
        lights[i] = &l;
                lights.resize(i+1);
 
        lights[i] = &l;
-       if(current()==this)
-               l.bind_to(i);
 }
 
 void Lighting::detach(unsigned i)
 }
 
 void Lighting::detach(unsigned i)
@@ -81,8 +77,6 @@ void Lighting::detach(unsigned i)
                return;
 
        lights[i] = 0;
                return;
 
        lights[i] = 0;
-       if(current()==this)
-               Light::unbind_from(i);
 }
 
 const Light *Lighting::get_attached_light(unsigned i) const
 }
 
 const Light *Lighting::get_attached_light(unsigned i) const
@@ -107,56 +101,6 @@ void Lighting::update_shader_data(ProgramData &shdata, const Matrix &view_matrix
                        lights[i]->update_shader_data(shdata, view_matrix, i);
 }
 
                        lights[i]->update_shader_data(shdata, view_matrix, i);
 }
 
-void Lighting::bind() const
-{
-       static Require _req(MSP_legacy_features);
-       if(lights.size()>LightUnit::get_n_units())
-               throw invalid_operation("Lighting::bind");
-
-       const Lighting *old = current();
-       if(!set_current(this))
-               return;
-
-       enable(GL_LIGHTING);
-       glLightModelfv(GL_LIGHT_MODEL_AMBIENT, &ambient.r);
-       for(unsigned i=0; i<lights.size(); ++i)
-       {
-               if(lights[i])
-                       lights[i]->bind_to(i);
-               else
-                       Light::unbind_from(i);
-       }
-
-       if(old)
-       {
-               for(unsigned i=lights.size(); i<old->lights.size(); ++i)
-                       Light::unbind_from(i);
-       }
-
-       if(fog_density)
-       {
-               enable(GL_FOG);
-               glFogi(GL_FOG_MODE, GL_EXP);
-               glFogf(GL_FOG_DENSITY, fog_density);
-               glFogfv(GL_FOG_COLOR, &fog_color.r);
-       }
-}
-
-void Lighting::unbind()
-{
-       const Lighting *old = current();
-       if(!set_current(0))
-               return;
-
-       for(unsigned i=0; i<old->lights.size(); ++i)
-               if(old->lights[i])
-                       Light::unbind_from(i);
-
-       disable(GL_LIGHTING);
-       if(old->fog_density)
-               disable(GL_FOG);
-}
-
 
 Lighting::Loader::Loader(Lighting &l):
        DataFile::ObjectLoader<Lighting>(l)
 
 Lighting::Loader::Loader(Lighting &l):
        DataFile::ObjectLoader<Lighting>(l)
index 94ccdd5e968170bdca6b4c0dd4230a4643d893fa..c36b33527c98eb031f0e7454ca6411ac0cb9f669 100644 (file)
@@ -17,7 +17,7 @@ class Light;
 Encapsulates global lighting parameters and any number of individual light
 sources.
 */
 Encapsulates global lighting parameters and any number of individual light
 sources.
 */
-class Lighting: public Bindable<Lighting>
+class Lighting
 {
 public:
        class Loader: public DataFile::ObjectLoader<Lighting>
 {
 public:
        class Loader: public DataFile::ObjectLoader<Lighting>
@@ -79,8 +79,7 @@ public:
        distance is 50%. */
        void set_fog_half_distance(float);
 
        distance is 50%. */
        void set_fog_half_distance(float);
 
-       /** Attaches a light source.  If the attachment index is greater than
-       LightUnit::get_n_units, the Lighting can't be bound for legacy mode. */
+       /** Attaches a light source. */
        void attach(unsigned, const Light &);
 
        /** Detaches a light source. */
        void attach(unsigned, const Light &);
 
        /** Detaches a light source. */
@@ -93,10 +92,6 @@ public:
        /** Updates a ProgramData object with the uniforms for the Lighting,
        including all attached light sources.  A view matrix must be passed in. */
        void update_shader_data(ProgramData &, const Matrix &) const;
        /** Updates a ProgramData object with the uniforms for the Lighting,
        including all attached light sources.  A view matrix must be passed in. */
        void update_shader_data(ProgramData &, const Matrix &) const;
-
-       void bind() const;
-
-       static void unbind();
 };
 
 } // namespace GL
 };
 
 } // namespace GL
diff --git a/source/lightunit.cpp b/source/lightunit.cpp
deleted file mode 100644 (file)
index e7cf741..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#include <stdexcept>
-#include <msp/gl/extensions/msp_legacy_features.h>
-#include "gl.h"
-#include "misc.h"
-#include "lightunit.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-vector<LightUnit> LightUnit::units;
-
-LightUnit::LightUnit():
-       light(0)
-{ }
-
-bool LightUnit::set_light(const Light *l)
-{
-       bool result = (l!=light);
-       light = l;
-       return result;
-}
-
-unsigned LightUnit::get_n_units()
-{
-       static int count = (MSP_legacy_features ? get_i(GL_MAX_LIGHTS) : 0);
-       return count;
-}
-
-LightUnit &LightUnit::get_unit(unsigned n)
-{
-       if(n>=get_n_units())
-               throw out_of_range("LightUnit::get_unit");
-
-       if(units.size()<=n)
-       {
-               unsigned i = units.size();
-               units.resize(n+1, LightUnit());
-               for(; i<units.size(); ++i)
-                       units[i].index = i;
-       }
-
-       return units[n];
-}
-
-LightUnit *LightUnit::find_unit(const Light *l)
-{
-       for(vector<LightUnit>::iterator i=units.begin(); i!=units.end(); ++i)
-               if(i->light==l)
-                       return &*i;
-       return 0;
-}
-
-} // namespace GL
-} // namespace Msp
diff --git a/source/lightunit.h b/source/lightunit.h
deleted file mode 100644 (file)
index bc200ea..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef MSP_GL_LIGHTUNIT_H_
-#define MSP_GL_LIGHTUNIT_H_
-
-#include <vector>
-
-namespace Msp {
-namespace GL {
-
-class Light;
-
-class LightUnit
-{
-private:
-       unsigned index;
-       const Light *light;
-
-       static std::vector<LightUnit> units;
-
-       LightUnit();
-
-public:
-       unsigned get_index() const { return index; }
-       bool set_light(const Light *);
-       const Light *get_light() const { return light; }
-
-       static unsigned get_n_units();
-       static LightUnit &get_unit(unsigned i);
-       static LightUnit *find_unit(const Light *);
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif
index a2814cff1ad6ccfdac3347e14f5a3ce130451e45..1d5a4087af2b3b8f6c9db232792c7eff45732a1c 100644 (file)
@@ -1,4 +1,3 @@
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include "gl.h"
 #include "material.h"
 #include "resources.h"
 #include "gl.h"
 #include "material.h"
 #include "resources.h"
@@ -16,56 +15,34 @@ Material::Material()
        set_reflectivity(0);
 }
 
        set_reflectivity(0);
 }
 
-void Material::update_parameter(int mask) const
-{
-       if(cur_obj!=this)
-               return;
-
-       if(mask&AMBIENT)
-               glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
-       if(mask&DIFFUSE)
-               glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
-       if(mask&SPECULAR)
-               glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r);
-       if(mask&EMISSION)
-               glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r);
-       if(mask&SHININESS)
-               glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
-}
-
 void Material::set_ambient(const Color &a)
 {
        ambient = a;
        shdata.uniform("material.ambient", ambient);
 void Material::set_ambient(const Color &a)
 {
        ambient = a;
        shdata.uniform("material.ambient", ambient);
-       update_parameter(AMBIENT);
 }
 
 void Material::set_diffuse(const Color &d)
 {
        diffuse = d;
        shdata.uniform("material.diffuse", diffuse);
 }
 
 void Material::set_diffuse(const Color &d)
 {
        diffuse = d;
        shdata.uniform("material.diffuse", diffuse);
-       update_parameter(DIFFUSE);
 }
 
 void Material::set_specular(const Color &s)
 {
        specular = s;
        shdata.uniform("material.specular", specular);
 }
 
 void Material::set_specular(const Color &s)
 {
        specular = s;
        shdata.uniform("material.specular", specular);
-       update_parameter(SPECULAR);
 }
 
 void Material::set_emission(const Color &e)
 {
        emission = e;
        shdata.uniform("material.emission", emission);
 }
 
 void Material::set_emission(const Color &e)
 {
        emission = e;
        shdata.uniform("material.emission", emission);
-       update_parameter(EMISSION);
 }
 
 void Material::set_shininess(float s)
 {
        shininess = s;
        shdata.uniform("material.shininess", shininess);
 }
 
 void Material::set_shininess(float s)
 {
        shininess = s;
        shdata.uniform("material.shininess", shininess);
-       update_parameter(SHININESS);
 }
 
 void Material::set_reflectivity(float r)
 }
 
 void Material::set_reflectivity(float r)
@@ -74,14 +51,6 @@ void Material::set_reflectivity(float r)
        shdata.uniform("reflectivity", reflectivity);
 }
 
        shdata.uniform("reflectivity", reflectivity);
 }
 
-void Material::bind() const
-{
-       static Require _req(MSP_legacy_features);
-
-       if(set_current(this))
-               update_parameter(-1);
-}
-
 
 Material::Loader::Loader(Material &m):
        DataFile::CollectionObjectLoader<Material>(m, 0)
 
 Material::Loader::Loader(Material &m):
        DataFile::CollectionObjectLoader<Material>(m, 0)
index e1bfec4caa0707419941b88476394955ab651244..17ea88391238ec31533261578c43ae244cf4e3a7 100644 (file)
@@ -15,12 +15,9 @@ parameters, but does not include texturing.  Materials interact with light
 soucres and ambient lighting to produce the base color of a surface.  Textures
 can be used to add detail.
 
 soucres and ambient lighting to produce the base color of a surface.  Textures
 can be used to add detail.
 
-Material provides a set of uniform variables for use with shaders.  Standard
-shaders generated by ProgramBuilder only use it when legacy mode is disabled.
-
-In legacy mode, materials are applied with several calls to glMaterial.
+Material provides a set of uniform variables for use with shaders.
 */
 */
-class Material: public BindableWithDefault<Material>
+class Material
 {
 public:
        class Loader: public DataFile::CollectionObjectLoader<Material>
 {
 public:
        class Loader: public DataFile::CollectionObjectLoader<Material>
@@ -44,15 +41,6 @@ public:
        };
 
 private:
        };
 
 private:
-       enum ParameterMask
-       {
-               AMBIENT = 1,
-               DIFFUSE = 2,
-               SPECULAR = 4,
-               EMISSION = 8,
-               SHININESS = 16
-       };
-
        Color ambient;
        Color diffuse;
        Color specular;
        Color ambient;
        Color diffuse;
        Color specular;
@@ -64,10 +52,6 @@ private:
 public:
        Material();
 
 public:
        Material();
 
-private:
-       void update_parameter(int) const;
-
-public:
        /** Sets the ambient color of the material.  Provided to shaders with the
        name material.ambient. */
        void set_ambient(const Color &);
        /** Sets the ambient color of the material.  Provided to shaders with the
        name material.ambient. */
        void set_ambient(const Color &);
@@ -96,11 +80,8 @@ public:
        float get_shininess() const { return shininess; }
        float get_reflectivity() const { return reflectivity; }
 
        float get_shininess() const { return shininess; }
        float get_reflectivity() const { return reflectivity; }
 
-       /** Returns the uniforms for the material.  Not needed for shaders that use
-       the legacy built-in uniform gl_FrontMaterial and have no reflections. */
+       /** Returns the uniforms for the material. */
        const ProgramData &get_shader_data() const { return shdata; }
        const ProgramData &get_shader_data() const { return shdata; }
-
-       void bind() const;
 };
 
 } // namespace GL
 };
 
 } // namespace GL
index a4c36a022a9ecb338406a496760f12c1d0655540..311958ab99542574edfe3cda35059d0eade1b24b 100644 (file)
@@ -1,7 +1,6 @@
 #include <algorithm>
 #include <cmath>
 #include <msp/geometry/affinetransformation.h>
 #include <algorithm>
 #include <cmath>
 #include <msp/geometry/affinetransformation.h>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include "error.h"
 #include "matrix.h"
 
 #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);
 }
 
        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
 } // namespace GL
 } // namespace Msp
index 2e1096f5f4586d7f6c05ea0620f59a5425b4b450..971d2b362e5441ab2d1dd5f8ff7496424d6d1021 100644 (file)
@@ -63,47 +63,6 @@ public:
        static Matrix perspective(const Angle &, float, float, float);
 };
 
        static Matrix perspective(const Angle &, float, float, float);
 };
 
-class MatrixStack
-{
-public:
-       class Push
-       {
-       private:
-               MatrixStack &stack;
-
-       public:
-               Push(MatrixStack &s): stack(s) { stack.push(); }
-               ~Push() { stack.pop(); }
-       };
-
-private:
-       GLenum mode;
-       std::vector<Matrix> matrices;
-
-       static GLenum current_mode;
-
-       MatrixStack(const MatrixStack &);
-       MatrixStack &operator=(const MatrixStack &);
-       MatrixStack(GLenum);
-public:
-       MatrixStack();
-
-       const Matrix &top() const;
-       void load(const Matrix &);
-       void multiply(const Matrix &);
-       void push();
-       void pop();
-private:
-       virtual void update();
-
-public:
-       MatrixStack &operator=(const Matrix &);
-       MatrixStack &operator*=(const Matrix &);
-
-       static MatrixStack &modelview();
-       static MatrixStack &projection();
-};
-
 } // namespace GL
 } // namespace Msp
 
 } // namespace GL
 } // namespace Msp
 
index 5f9c60d03919e2fe262d4bf848325eaee30dd6e5..a8129d9bdc70ec426519f01289f667b8ba39f58f 100644 (file)
@@ -1,7 +1,6 @@
 #include <msp/gl/extensions/arb_vertex_array_object.h>
 #include <msp/gl/extensions/arb_vertex_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
 #include <msp/gl/extensions/arb_vertex_array_object.h>
 #include <msp/gl/extensions/arb_vertex_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
-#include <msp/gl/extensions/nv_primitive_restart.h>
 #include "buffer.h"
 #include "error.h"
 #include "mesh.h"
 #include "buffer.h"
 #include "error.h"
 #include "mesh.h"
@@ -201,7 +200,7 @@ void Mesh::bind() const
        if(!vtx_setup)
        {
                unbind();
        if(!vtx_setup)
        {
                unbind();
-               vertices.apply(false);
+               vertices.apply();
        }
        else if(set_current(this))
        {
        }
        else if(set_current(this))
        {
@@ -290,9 +289,6 @@ Mesh::AsyncLoader::AsyncLoader(Mesh &m, IO::Seekable &i):
        index_updater(0),
        phase(0)
 {
        index_updater(0),
        phase(0)
 {
-       // Make sure the extension is initialized in the rendering thread.
-       (void)(bool)NV_primitive_restart;
-
        mesh.disallow_rendering = true;
        if(mesh.defer_buffers)
                mesh.create_buffers();
        mesh.disallow_rendering = true;
        if(mesh.defer_buffers)
                mesh.create_buffers();
index 0b13f3ccefa7fe53cf2e5868b157a7d0c0e5588b..547a6a6970b4d69566b1a5552ca93a6a39c3fb47 100644 (file)
@@ -34,10 +34,6 @@ void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
                fmt = LUMINANCE;
        else if(conv.get()=="LUMINANCE_ALPHA")
                fmt = LUMINANCE_ALPHA;
                fmt = LUMINANCE;
        else if(conv.get()=="LUMINANCE_ALPHA")
                fmt = LUMINANCE_ALPHA;
-       else if(conv.get()=="SLUMINANCE")
-               fmt = SLUMINANCE;
-       else if(conv.get()=="SLUMINANCE_ALPHA")
-               fmt = SLUMINANCE_ALPHA;
        else
                throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get()));
 }
        else
                throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get()));
 }
@@ -83,8 +79,6 @@ PixelFormat get_base_pixelformat(PixelFormat pf)
        {
        case SRGB: return RGB;
        case SRGB_ALPHA: return RGBA;
        {
        case SRGB: return RGB;
        case SRGB_ALPHA: return RGBA;
-       case SLUMINANCE: return LUMINANCE;
-       case SLUMINANCE_ALPHA: return LUMINANCE_ALPHA;
        default: return unsized;
        }
 }
        default: return unsized;
        }
 }
@@ -108,9 +102,7 @@ PixelFormat get_unsized_pixelformat(PixelFormat pf)
        case RGBA32F: return RGBA;
        case SRGB8_ALPHA8: return SRGB_ALPHA;
        case LUMINANCE8: return LUMINANCE;
        case RGBA32F: return RGBA;
        case SRGB8_ALPHA8: return SRGB_ALPHA;
        case LUMINANCE8: return LUMINANCE;
-       case SLUMINANCE8: return SLUMINANCE;
-       case LUMINANCE_ALPHA8: return LUMINANCE_ALPHA;
-       case SLUMINANCE8_ALPHA8: return SLUMINANCE_ALPHA;
+       case LUMINANCE8_ALPHA8: return LUMINANCE_ALPHA;
        case DEPTH_COMPONENT16:
        case DEPTH_COMPONENT24:
        case DEPTH_COMPONENT32:
        case DEPTH_COMPONENT16:
        case DEPTH_COMPONENT24:
        case DEPTH_COMPONENT32:
@@ -138,9 +130,7 @@ PixelFormat get_sized_pixelformat(PixelFormat pf, unsigned size)
                case SRGB: return SRGB8;
                case SRGB_ALPHA: return SRGB8_ALPHA8;
                case LUMINANCE: return LUMINANCE8;
                case SRGB: return SRGB8;
                case SRGB_ALPHA: return SRGB8_ALPHA8;
                case LUMINANCE: return LUMINANCE8;
-               case SLUMINANCE: return SLUMINANCE8;
                case LUMINANCE_ALPHA: return LUMINANCE8_ALPHA8;
                case LUMINANCE_ALPHA: return LUMINANCE8_ALPHA8;
-               case SLUMINANCE_ALPHA: return SLUMINANCE8_ALPHA8;
                default: throw invalid_argument("get_sized_pixelformat");
                }
        case 2:
                default: throw invalid_argument("get_sized_pixelformat");
                }
        case 2:
@@ -195,10 +185,6 @@ PixelFormat get_srgb_pixelformat(PixelFormat pf)
        case RGBA: return SRGB_ALPHA;
        case RGB8: return SRGB8;
        case RGBA8: return SRGB8_ALPHA8;
        case RGBA: return SRGB_ALPHA;
        case RGB8: return SRGB8;
        case RGBA8: return SRGB8_ALPHA8;
-       case LUMINANCE: return SLUMINANCE;
-       case LUMINANCE8: return SLUMINANCE8;
-       case LUMINANCE_ALPHA: return SLUMINANCE_ALPHA;
-       case LUMINANCE_ALPHA8: return SLUMINANCE8_ALPHA8;
        default: return pf;
        }
 }
        default: return pf;
        }
 }
@@ -211,11 +197,9 @@ unsigned get_component_count(PixelFormat pf)
        case DEPTH_COMPONENT:
        case RED:
        case LUMINANCE:
        case DEPTH_COMPONENT:
        case RED:
        case LUMINANCE:
-       case SLUMINANCE:
                return 1;
        case RG:
        case LUMINANCE_ALPHA:
                return 1;
        case RG:
        case LUMINANCE_ALPHA:
-       case SLUMINANCE_ALPHA:
                return 2;
        case RGB:
        case BGR:
                return 2;
        case RGB:
        case BGR:
@@ -240,8 +224,6 @@ unsigned get_component_size(PixelFormat pf)
        case SRGB8_ALPHA8:
        case LUMINANCE8:
        case LUMINANCE8_ALPHA8:
        case SRGB8_ALPHA8:
        case LUMINANCE8:
        case LUMINANCE8_ALPHA8:
-       case SLUMINANCE8:
-       case SLUMINANCE8_ALPHA8:
                return 1;
        case R16F:
        case RG16F:
                return 1;
        case R16F:
        case RG16F:
@@ -304,10 +286,6 @@ void require_pixelformat(PixelFormat pf)
        case SRGB8:
        case SRGB_ALPHA:
        case SRGB8_ALPHA8:
        case SRGB8:
        case SRGB_ALPHA:
        case SRGB8_ALPHA8:
-       case SLUMINANCE:
-       case SLUMINANCE8:
-       case SLUMINANCE_ALPHA:
-       case SLUMINANCE8_ALPHA8:
                { static Require _req(EXT_texture_sRGB); }
                break;
        case BGR:
                { static Require _req(EXT_texture_sRGB); }
                break;
        case BGR:
index 2db894a78447ed0d6b7b2892f7c5e8a499509774..eca0b0e5833970f858f64e08e5c7061b0a9cd3e0 100644 (file)
@@ -10,7 +10,6 @@
 #include <msp/gl/extensions/arb_texture_rg.h>
 #include <msp/gl/extensions/ext_bgra.h>
 #include <msp/gl/extensions/ext_texture_srgb.h>
 #include <msp/gl/extensions/arb_texture_rg.h>
 #include <msp/gl/extensions/ext_bgra.h>
 #include <msp/gl/extensions/ext_texture_srgb.h>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include <msp/gl/extensions/oes_required_internalformat.h>
 #include <msp/gl/extensions/oes_texture_stencil8.h>
 
 #include <msp/gl/extensions/oes_required_internalformat.h>
 #include <msp/gl/extensions/oes_texture_stencil8.h>
 
@@ -50,16 +49,7 @@ enum PixelFormat
        LUMINANCE       = GL_LUMINANCE,
        LUMINANCE8      = GL_LUMINANCE8,
        LUMINANCE_ALPHA    = GL_LUMINANCE_ALPHA,
        LUMINANCE       = GL_LUMINANCE,
        LUMINANCE8      = GL_LUMINANCE8,
        LUMINANCE_ALPHA    = GL_LUMINANCE_ALPHA,
-       LUMINANCE8_ALPHA8  = GL_LUMINANCE8_ALPHA8,
-
-       // Deprecated
-       SLUMINANCE         = GL_SLUMINANCE,
-       SLUMINANCE8        = GL_SLUMINANCE8,
-       SLUMINANCE_ALPHA   = GL_SLUMINANCE_ALPHA,
-       SLUMINANCE8_ALPHA8 = GL_SLUMINANCE8_ALPHA8,
-
-       // Typo, deprecated
-       LUMINANCE_ALPHA8   = GL_LUMINANCE8_ALPHA8
+       LUMINANCE8_ALPHA8  = GL_LUMINANCE8_ALPHA8
 };
 
 void operator>>(const LexicalConverter &, PixelFormat &);
 };
 
 void operator>>(const LexicalConverter &, PixelFormat &);
index c9a827926a108805ef9c7e1b6aba8fc7c02f4699..81375843c9f649609e4ef2c7e60873eca3534dfa 100644 (file)
@@ -20,19 +20,9 @@ void operator>>(const LexicalConverter &conv, PrimitiveType &pt)
                pt = TRIANGLE_STRIP;
        else if(conv.get()=="TRIANGLE_FAN")
                pt = TRIANGLE_FAN;
                pt = TRIANGLE_STRIP;
        else if(conv.get()=="TRIANGLE_FAN")
                pt = TRIANGLE_FAN;
-       else if(conv.get()=="QUADS")
-               pt = QUADS;
-       else if(conv.get()=="QUAD_STRIP")
-               pt = QUAD_STRIP;
        else
                throw lexical_error(format("conversion of '%s' to PrimitiveType", conv.get()));
 }
 
        else
                throw lexical_error(format("conversion of '%s' to PrimitiveType", conv.get()));
 }
 
-void require_primitive_type(PrimitiveType type)
-{
-       if(type==QUADS || type==QUAD_STRIP)
-               static Require _req(MSP_legacy_features);
-}
-
 } // namespace GL
 } // namespace Msp
 } // namespace GL
 } // namespace Msp
index 9e65cbf711983c9da5c6f0b79f47a22ea828ef3f..8e33b1da141fc6cfabfc473329c9e73bb71f3607 100644 (file)
@@ -2,7 +2,6 @@
 #define MSP_GL_PRIMITIVETYPE_H_
 
 #include <msp/strings/lexicalcast.h>
 #define MSP_GL_PRIMITIVETYPE_H_
 
 #include <msp/strings/lexicalcast.h>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include "gl.h"
 
 namespace Msp {
 #include "gl.h"
 
 namespace Msp {
@@ -16,15 +15,11 @@ enum PrimitiveType
        LINE_LOOP      = GL_LINE_LOOP,
        TRIANGLES      = GL_TRIANGLES,
        TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
        LINE_LOOP      = GL_LINE_LOOP,
        TRIANGLES      = GL_TRIANGLES,
        TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
-       TRIANGLE_FAN   = GL_TRIANGLE_FAN,
-       QUADS          = GL_QUADS,
-       QUAD_STRIP     = GL_QUAD_STRIP
+       TRIANGLE_FAN   = GL_TRIANGLE_FAN
 };
 
 void operator>>(const LexicalConverter &, PrimitiveType &);
 
 };
 
 void operator>>(const LexicalConverter &, PrimitiveType &);
 
-void require_primitive_type(PrimitiveType);
-
 } // namespace GL
 } // namespace Msp
 
 } // namespace GL
 } // namespace Msp
 
index d8827ab5d0f5f095fed0d53424571aff7147f472..e65a703f77a8d1f5f4b2d769e7c85ca0d439b2bd 100644 (file)
@@ -129,7 +129,6 @@ void Program::link()
                        (*i)->compile();
 
        uniforms.clear();
                        (*i)->compile();
 
        uniforms.clear();
-       legacy_vars = false;
 
        glLinkProgram(id);
        linked = get_program_i(id, GL_LINK_STATUS);
 
        glLinkProgram(id);
        linked = get_program_i(id, GL_LINK_STATUS);
@@ -173,8 +172,6 @@ void Program::query_uniforms()
                        info.type = type;
                        uniforms_by_index[i] = &info;
                }
                        info.type = type;
                        uniforms_by_index[i] = &info;
                }
-               else
-                       legacy_vars = true;
        }
 
        if(ARB_uniform_buffer_object)
        }
 
        if(ARB_uniform_buffer_object)
@@ -294,8 +291,6 @@ void Program::query_attributes()
                        info.size = size;
                        info.type = type;
                }
                        info.size = size;
                        info.type = type;
                }
-               else
-                       legacy_vars = true;
        }
 }
 
        }
 }
 
index d2032a5cd46843e36def08c91f8a95d699025bd1..734d665b3d5e21c5ec6e1efe8a7106980c5da003 100644 (file)
@@ -81,7 +81,6 @@ private:
        UniformMap uniforms;
        LayoutHash uniform_layout_hash;
        AttributeMap attributes;
        UniformMap uniforms;
        LayoutHash uniform_layout_hash;
        AttributeMap attributes;
-       bool legacy_vars;
 
 public:
        /// Constructs an empty Program with no Shaders attached.
 
 public:
        /// Constructs an empty Program with no Shaders attached.
@@ -131,8 +130,6 @@ public:
        const AttributeInfo &get_attribute_info(const std::string &) const;
        int get_attribute_location(const std::string &) const;
 
        const AttributeInfo &get_attribute_info(const std::string &) const;
        int get_attribute_location(const std::string &) const;
 
-       bool uses_legacy_variables() const { return legacy_vars; }
-
        void bind() const;
        static void unbind();
 };
        void bind() const;
        static void unbind();
 };
index c5fe3c64a8baca0d39b7966d43edc61c3efa9be4..302d943727a2812e66bd6b85f748f398117bd4d9 100644 (file)
@@ -25,7 +25,6 @@ namespace GL {
 Renderer::Renderer(const Camera *c):
        default_camera(c),
        changed(0),
 Renderer::Renderer(const Camera *c):
        default_camera(c),
        changed(0),
-       matrices_loaded(false),
        state_stack(1)
 {
        state_stack.reserve(16);
        state_stack(1)
 {
        state_stack.reserve(16);
@@ -58,7 +57,7 @@ void Renderer::set_camera(const Camera &c)
        state->camera = &c;
        standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix());
        standard_shdata.uniform("eye_world_matrix", state->camera->get_view_matrix());
        state->camera = &c;
        standard_shdata.uniform("projection_matrix", state->camera->get_projection_matrix());
        standard_shdata.uniform("eye_world_matrix", state->camera->get_view_matrix());
-       changed |= STANDARD_SHDATA|LEGACY_PROJECTION;
+       changed |= STANDARD_SHDATA;
        set_matrix(state->camera->get_view_matrix());
 }
 
        set_matrix(state->camera->get_view_matrix());
 }
 
@@ -106,7 +105,6 @@ void Renderer::set_lighting(const Lighting *l)
                l->update_shader_data(standard_shdata, state->lighting_matrix);
                changed |= STANDARD_SHDATA;
        }
                l->update_shader_data(standard_shdata, state->lighting_matrix);
                changed |= STANDARD_SHDATA;
        }
-       changed |= LEGACY_LIGHTING;
 }
 
 void Renderer::set_clipping(const Clipping *c)
 }
 
 void Renderer::set_clipping(const Clipping *c)
@@ -118,7 +116,6 @@ void Renderer::set_clipping(const Clipping *c)
                c->update_shader_data(standard_shdata, state->clipping_matrix);
                changed |= STANDARD_SHDATA;
        }
                c->update_shader_data(standard_shdata, state->clipping_matrix);
                changed |= STANDARD_SHDATA;
        }
-       changed |= LEGACY_CLIPPING;
 }
 
 void Renderer::set_shader_program(const Program *p, const ProgramData *d)
 }
 
 void Renderer::set_shader_program(const Program *p, const ProgramData *d)
@@ -202,7 +199,7 @@ void Renderer::pop_state()
                        standard_shdata.uniform("projection_matrix", Matrix());
                        standard_shdata.uniform("eye_world_matrix", Matrix());
                }
                        standard_shdata.uniform("projection_matrix", Matrix());
                        standard_shdata.uniform("eye_world_matrix", Matrix());
                }
-               changed |= STANDARD_SHDATA|LEGACY_PROJECTION;
+               changed |= STANDARD_SHDATA;
        }
        /* This actually should compare the relevant matrices rather than check for
        camera, but in practice lighting and clipping is set right after the camera
        }
        /* This actually should compare the relevant matrices rather than check for
        camera, but in practice lighting and clipping is set right after the camera
@@ -214,7 +211,6 @@ void Renderer::pop_state()
                        state->lighting->update_shader_data(standard_shdata, state->lighting_matrix);
                        changed |= STANDARD_SHDATA;
                }
                        state->lighting->update_shader_data(standard_shdata, state->lighting_matrix);
                        changed |= STANDARD_SHDATA;
                }
-               changed |= LEGACY_LIGHTING;
        }
        if(state->clipping!=old_clipping || camera_changed)
        {
        }
        if(state->clipping!=old_clipping || camera_changed)
        {
@@ -223,7 +219,6 @@ void Renderer::pop_state()
                        state->clipping->update_shader_data(standard_shdata, state->clipping_matrix);
                        changed |= STANDARD_SHDATA;
                }
                        state->clipping->update_shader_data(standard_shdata, state->clipping_matrix);
                        changed |= STANDARD_SHDATA;
                }
-               changed |= LEGACY_CLIPPING;
        }
 }
 
        }
 }
 
@@ -243,20 +238,11 @@ void Renderer::end()
        Mesh::unbind();
        Texturing::unbind();
        Texture::unbind_from(0);
        Mesh::unbind();
        Texturing::unbind();
        Texture::unbind_from(0);
-       Material::unbind();
-       Lighting::unbind();
        Clipping::unbind();
        Program::unbind();
        VertexSetup::unbind();
        Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
        WindingTest::unbind();
        Clipping::unbind();
        Program::unbind();
        VertexSetup::unbind();
        Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
        WindingTest::unbind();
-
-       if(matrices_loaded)
-       {
-               MatrixStack::projection().pop();
-               MatrixStack::modelview().pop();
-               matrices_loaded = false;
-       }
 }
 
 void Renderer::exclude(const Renderable &renderable)
 }
 
 void Renderer::exclude(const Renderable &renderable)
@@ -294,54 +280,19 @@ void Renderer::apply_state()
        /* We (mostly) let the objects themselves figure out if the binding has
        changed */
 
        /* We (mostly) let the objects themselves figure out if the binding has
        changed */
 
-       bool legacy_bindings = (!state->shprog || state->shprog->uses_legacy_variables());
-       bool legacy_textures = !state->shprog;
-
        if(state->texturing)
        if(state->texturing)
-               state->texturing->bind(legacy_textures);
+               state->texturing->bind();
        else
        {
                Texturing::unbind();
                if(state->texture)
        else
        {
                Texturing::unbind();
                if(state->texture)
-                       state->texture->bind_to(0, legacy_textures);
+                       state->texture->bind_to(0);
                else
                        Texture::unbind_from(0);
        }
 
                else
                        Texture::unbind_from(0);
        }
 
-       if(legacy_bindings)
-       {
-               if(state->material)
-                       state->material->bind();
-               else
-                       Material::unbind();
-
-               if(changed&LEGACY_LIGHTING)
-               {
-                       if(state->lighting)
-                       {
-                               MatrixStack::modelview() = state->lighting_matrix;
-                               state->lighting->bind();
-                               changed = (changed&~LEGACY_LIGHTING)|LEGACY_MATRIX;
-                       }
-                       else
-                               Lighting::unbind();
-               }
-       }
-
        if(state->clipping)
        if(state->clipping)
-       {
-               if(legacy_bindings)
-               {
-                       if(changed&LEGACY_CLIPPING)
-                       {
-                               MatrixStack::modelview() = state->clipping_matrix;
-                               state->clipping->bind(true);
-                               changed = (changed&~LEGACY_CLIPPING)|LEGACY_MATRIX;
-                       }
-               }
-               else
-                       state->clipping->bind(false);
-       }
+               state->clipping->bind();
        else
                Clipping::unbind();
 
        else
                Clipping::unbind();
 
@@ -350,28 +301,25 @@ void Renderer::apply_state()
                bool shprog_changed = (state->shprog!=Program::current());
                state->shprog->bind();
 
                bool shprog_changed = (state->shprog!=Program::current());
                state->shprog->bind();
 
-               if(!legacy_bindings)
+               if(changed&MATRIX)
+               {
+                       standard_shdata.uniform("eye_obj_matrix", state->modelview_matrix);
+                       LinAl::SquareMatrix<float, 3> nm = state->modelview_matrix.block<3, 3>(0, 0);
+                       nm = transpose(invert(nm));
+                       standard_shdata.uniform_matrix3("eye_obj_normal_matrix", &nm(0, 0));
+                       changed = (changed&~MATRIX)|STANDARD_SHDATA;
+               }
+
+               if(state->material && ((changed&MATERIAL_SHDATA) || shprog_changed))
                {
                {
-                       if(changed&MODERN_MATRIX)
-                       {
-                               standard_shdata.uniform("eye_obj_matrix", state->modelview_matrix);
-                               LinAl::SquareMatrix<float, 3> nm = state->modelview_matrix.block<3, 3>(0, 0);
-                               nm = transpose(invert(nm));
-                               standard_shdata.uniform_matrix3("eye_obj_normal_matrix", &nm(0, 0));
-                               changed = (changed&~MODERN_MATRIX)|STANDARD_SHDATA;
-                       }
-
-                       if(state->material && ((changed&MATERIAL_SHDATA) || shprog_changed))
-                       {
-                               state->material->get_shader_data().apply();
-                               changed &= ~MATERIAL_SHDATA;
-                       }
-
-                       if((changed&STANDARD_SHDATA) || shprog_changed)
-                       {
-                               standard_shdata.apply();
-                               changed &= ~STANDARD_SHDATA;
-                       }
+                       state->material->get_shader_data().apply();
+                       changed &= ~MATERIAL_SHDATA;
+               }
+
+               if((changed&STANDARD_SHDATA) || shprog_changed)
+               {
+                       standard_shdata.apply();
+                       changed &= ~STANDARD_SHDATA;
                }
 
                bool extra_shdata = (shdata_stack.size()>state->shdata_count);
                }
 
                bool extra_shdata = (shdata_stack.size()>state->shdata_count);
@@ -389,19 +337,7 @@ void Renderer::apply_state()
                Program::unbind();
 
        if(state->mesh)
                Program::unbind();
 
        if(state->mesh)
-       {
-               if(legacy_bindings)
-               {
-                       Mesh::unbind();
-                       state->mesh->get_vertices().apply();
-                       if(const Buffer *ibuf = state->mesh->get_index_buffer())
-                               ibuf->bind_to(ELEMENT_ARRAY_BUFFER);
-                       else
-                               Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
-               }
-               else
-                       state->mesh->bind();
-       }
+               state->mesh->bind();
        else
        {
                Mesh::unbind();
        else
        {
                Mesh::unbind();
@@ -421,28 +357,6 @@ void Renderer::apply_state()
        }
        else
                WindingTest::unbind();
        }
        else
                WindingTest::unbind();
-
-       if(legacy_bindings)
-       {
-               if(!matrices_loaded)
-               {
-                       MatrixStack::modelview().push();
-                       MatrixStack::projection().push();
-                       matrices_loaded = true;
-               }
-
-               if(changed&LEGACY_PROJECTION)
-               {
-                       MatrixStack::projection() = state->camera->get_projection_matrix();
-                       changed &= ~LEGACY_PROJECTION;
-               }
-
-               if(changed&LEGACY_MATRIX)
-               {
-                       MatrixStack::modelview() = state->modelview_matrix;
-                       changed &= ~LEGACY_MATRIX;
-               }
-       }
 }
 
 
 }
 
 
index f997171c4403e9dfb8759833c1aea5b1ae80995c..4899b4f330d8bb173898ff73dfc061a4d9471688 100644 (file)
@@ -88,20 +88,14 @@ private:
 
        enum ChangeMask
        {
 
        enum ChangeMask
        {
-               LEGACY_MATRIX = 1,
-               MODERN_MATRIX = 2,
-               MATRIX = LEGACY_MATRIX|MODERN_MATRIX,
-               LEGACY_LIGHTING = 4,
-               LEGACY_CLIPPING = 8,
+               MATRIX = 2,
                SHADER_DATA = 16,
                MATERIAL_SHDATA = 32,
                SHADER_DATA = 16,
                MATERIAL_SHDATA = 32,
-               STANDARD_SHDATA = 64,
-               LEGACY_PROJECTION = 128
+               STANDARD_SHDATA = 64
        };
 
        const Camera *default_camera;
        unsigned char changed;
        };
 
        const Camera *default_camera;
        unsigned char changed;
-       bool matrices_loaded;
        std::vector<State> state_stack;
        State *state;
        ProgramData standard_shdata;
        std::vector<State> state_stack;
        State *state;
        ProgramData standard_shdata;
index dfb88e3fcc1e8553721eeaf100735cf616fe4f6f..b408bbe1780040cef29e600d2dab1b504b2d41b8 100644 (file)
@@ -36,7 +36,7 @@ void Text::set_text(const string &text, StringCodec::Decoder &dec)
        clear();
        width = font.get_string_width(text, dec);
        MeshBuilder bld(mesh);
        clear();
        width = font.get_string_width(text, dec);
        MeshBuilder bld(mesh);
-       bld.matrix() *= Matrix::translation(Vector3(-horz_align*width, vert_offset, 0.0f));
+       bld.transform(Matrix::translation(Vector3(-horz_align*width, vert_offset, 0.0f)));
        font.build_string(text, dec, bld);
 }
 
        font.build_string(text, dec, bld);
 }
 
index f1689145c8af9c5754569213a7561b0505e63b2c..a7e4898c1edae7d73de8efe9bf425dbb69ccc569 100644 (file)
@@ -4,7 +4,6 @@
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/ext_texture3d.h>
 #include <msp/gl/extensions/ext_texture_filter_anisotropic.h>
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/ext_texture3d.h>
 #include <msp/gl/extensions/ext_texture_filter_anisotropic.h>
-#include <msp/gl/extensions/sgis_generate_mipmap.h>
 #include <msp/io/memory.h>
 #include <msp/strings/format.h>
 #include "bindable.h"
 #include <msp/io/memory.h>
 #include <msp/strings/format.h>
 #include "bindable.h"
@@ -69,7 +68,7 @@ Texture::Texture(GLenum t, ResourceManager *m):
        wrap_s(REPEAT),
        wrap_t(REPEAT),
        wrap_r(REPEAT),
        wrap_s(REPEAT),
        wrap_t(REPEAT),
        wrap_r(REPEAT),
-       auto_gen_mipmap(0),
+       auto_gen_mipmap(false),
        compare(false),
        cmp_func(LEQUAL),
        dirty_params(0)
        compare(false),
        cmp_func(LEQUAL),
        dirty_params(0)
@@ -104,12 +103,12 @@ void Texture::set_internal_format(PixelFormat fmt)
        FormatSwizzle swiz = NO_SWIZZLE;
        if(ARB_texture_rg && ARB_texture_swizzle)
        {
        FormatSwizzle swiz = NO_SWIZZLE;
        if(ARB_texture_rg && ARB_texture_swizzle)
        {
-               if(fmt==LUMINANCE8 || fmt==SLUMINANCE8)
+               if(fmt==LUMINANCE8)
                {
                        fmt = R8;
                        swiz = R_TO_LUMINANCE;
                }
                {
                        fmt = R8;
                        swiz = R_TO_LUMINANCE;
                }
-               else if(fmt==LUMINANCE8_ALPHA8 || fmt==SLUMINANCE8_ALPHA8)
+               else if(fmt==LUMINANCE8_ALPHA8)
                {
                        fmt = RG8;
                        swiz = RG_TO_LUMINANCE_ALPHA;
                {
                        fmt = RG8;
                        swiz = RG_TO_LUMINANCE_ALPHA;
@@ -157,8 +156,6 @@ void Texture::update_parameter(int mask) const
                set_parameter_i(GL_TEXTURE_WRAP_T, wrap_t);
        if(mask&WRAP_R)
                set_parameter_i(GL_TEXTURE_WRAP_R, wrap_r);
                set_parameter_i(GL_TEXTURE_WRAP_T, wrap_t);
        if(mask&WRAP_R)
                set_parameter_i(GL_TEXTURE_WRAP_R, wrap_r);
-       if(mask&GENERATE_MIPMAP)
-               set_parameter_i(GL_GENERATE_MIPMAP, auto_gen_mipmap!=0);
        if(mask&COMPARE)
                set_parameter_i(GL_TEXTURE_COMPARE_MODE, (compare ? GL_COMPARE_R_TO_TEXTURE : GL_NONE));
        if(mask&COMPARE_FUNC)
        if(mask&COMPARE)
                set_parameter_i(GL_TEXTURE_COMPARE_MODE, (compare ? GL_COMPARE_R_TO_TEXTURE : GL_NONE));
        if(mask&COMPARE_FUNC)
@@ -264,7 +261,7 @@ void Texture::set_wrap_r(TextureWrap w)
 
 bool Texture::can_generate_mipmap()
 {
 
 bool Texture::can_generate_mipmap()
 {
-       return (EXT_framebuffer_object || SGIS_generate_mipmap);
+       return EXT_framebuffer_object;
 }
 
 void Texture::generate_mipmap()
 }
 
 void Texture::generate_mipmap()
@@ -283,16 +280,10 @@ void Texture::generate_mipmap()
 
 void Texture::set_auto_generate_mipmap(bool gm)
 {
 
 void Texture::set_auto_generate_mipmap(bool gm)
 {
-       if(EXT_framebuffer_object)
-               auto_gen_mipmap = gm;
-       else
-       {
-               if(gm)
-                       static Require _req(SGIS_generate_mipmap);
+       if(gm)
+               static Require _req(EXT_framebuffer_object);
 
 
-               auto_gen_mipmap = gm*2;
-               update_parameter(GENERATE_MIPMAP);
-       }
+       auto_gen_mipmap = gm;
 }
 
 void Texture::set_compare_enabled(bool c)
 }
 
 void Texture::set_compare_enabled(bool c)
@@ -318,7 +309,7 @@ void Texture::load_image(const string &fn, bool srgb)
        image(img, srgb);
 }
 
        image(img, srgb);
 }
 
-void Texture::bind_to(unsigned i, bool legacy) const
+void Texture::bind_to(unsigned i) const
 {
        if(!id)
        {
 {
        if(!id)
        {
@@ -331,28 +322,17 @@ void Texture::bind_to(unsigned i, bool legacy) const
                }
        }
 
                }
        }
 
-       legacy = (legacy && is_legacy_target(target));
-
        TexUnit &unit = TexUnit::get_unit(i);
        TexUnit &unit = TexUnit::get_unit(i);
-       const Texture *old = unit.get_texture();
-       bool old_legacy = unit.get_texture_legacy();
-       if(unit.set_texture(this, legacy))
+       if(unit.set_texture(this))
        {
                if(manager)
                        manager->resource_used(*this);
 
        {
                if(manager)
                        manager->resource_used(*this);
 
-               if(ARB_direct_state_access && !old_legacy && (!unit.supports_legacy() || !legacy))
+               if(ARB_direct_state_access)
                        glBindTextureUnit(i, id);
                else
                {
                        unit.bind();
                        glBindTextureUnit(i, id);
                else
                {
                        unit.bind();
-                       if(unit.supports_legacy())
-                       {
-                               if(old && old->target!=target && old_legacy)
-                                       glDisable(old->target);
-                               if((!old || old->target!=target) && legacy)
-                                       glEnable(target);
-                       }
                        glBindTexture(target, id);
                }
 
                        glBindTexture(target, id);
                }
 
@@ -373,26 +353,18 @@ void Texture::unbind_from(unsigned i)
 {
        TexUnit &unit = TexUnit::get_unit(i);
        const Texture *cur = unit.get_texture();
 {
        TexUnit &unit = TexUnit::get_unit(i);
        const Texture *cur = unit.get_texture();
-       bool legacy = unit.get_texture_legacy();
        if(unit.set_texture(0))
        {
        if(unit.set_texture(0))
        {
-               if(ARB_direct_state_access && !legacy)
+               if(ARB_direct_state_access)
                        glBindTextureUnit(i, 0);
                else
                {
                        unit.bind();
                        glBindTexture(cur->target, 0);
                        glBindTextureUnit(i, 0);
                else
                {
                        unit.bind();
                        glBindTexture(cur->target, 0);
-                       if(unit.supports_legacy() && legacy)
-                               glDisable(cur->target);
                }
        }
 }
 
                }
        }
 }
 
-bool Texture::is_legacy_target(GLenum target)
-{
-       return target<GL_TEXTURE_1D_ARRAY;
-}
-
 
 Texture::Loader::Loader(Texture &t):
        DataFile::CollectionObjectLoader<Texture>(t, 0)
 
 Texture::Loader::Loader(Texture &t):
        DataFile::CollectionObjectLoader<Texture>(t, 0)
index 19da006937cf536aef73bc9ae43e0ba3bc3472b1..bd000a325e520b7392a2afc404988879f7e3ecca 100644 (file)
@@ -102,7 +102,6 @@ protected:
                WRAP_S = 4,
                WRAP_T = 8,
                WRAP_R = 16,
                WRAP_S = 4,
                WRAP_T = 8,
                WRAP_R = 16,
-               GENERATE_MIPMAP = 32,
                COMPARE = 64,
                COMPARE_FUNC = 128,
                MAX_ANISOTROPY = 256,
                COMPARE = 64,
                COMPARE_FUNC = 128,
                MAX_ANISOTROPY = 256,
@@ -128,7 +127,7 @@ protected:
        TextureWrap wrap_s;
        TextureWrap wrap_t;
        TextureWrap wrap_r;
        TextureWrap wrap_s;
        TextureWrap wrap_t;
        TextureWrap wrap_r;
-       Msp::UInt8 auto_gen_mipmap;
+       bool auto_gen_mipmap;
        bool compare;
        Predicate cmp_func;
        mutable int dirty_params;
        bool compare;
        Predicate cmp_func;
        mutable int dirty_params;
@@ -202,16 +201,13 @@ public:
        GLenum get_target() const { return target; }
        unsigned get_id() const { return id; }
 
        GLenum get_target() const { return target; }
        unsigned get_id() const { return id; }
 
-       void bind(bool legacy = true) const { bind_to(0, legacy); }
-       void bind_to(unsigned, bool = true) const;
+       void bind() const { bind_to(0); }
+       void bind_to(unsigned) const;
 
        static const Texture *current(unsigned = 0);
        static void unbind() { unbind_from(0); }
        static void unbind_from(unsigned);
 
        static const Texture *current(unsigned = 0);
        static void unbind() { unbind_from(0); }
        static void unbind_from(unsigned);
-private:
-       static bool is_legacy_target(GLenum);
 
 
-public:
        virtual UInt64 get_data_size() const { return 0; }
 };
 
        virtual UInt64 get_data_size() const { return 0; }
 };
 
index 39782efd8124d357e5bacdb88278309ea578d2b3..d88b88c02e57c763d7c3b7731cbb4a159eb430d4 100644 (file)
@@ -74,7 +74,7 @@ void Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void
        glTexImage1D(target, level, ifmt, w, 0, get_upload_format(fmt), type, data);
 
        allocated |= 1<<level;
        glTexImage1D(target, level, ifmt, w, 0, get_upload_format(fmt), type, data);
 
        allocated |= 1<<level;
-       if(auto_gen_mipmap==1 && level==0)
+       if(auto_gen_mipmap && level==0)
        {
                generate_mipmap();
                allocated |= (1<<get_n_levels())-1;
        {
                generate_mipmap();
                allocated |= (1<<get_n_levels())-1;
@@ -95,7 +95,7 @@ void Texture1D::sub_image(unsigned level, int x, unsigned wd, PixelFormat fmt, D
        else
                glTexSubImage1D(target, level, x, wd, fmt, type, data);
 
        else
                glTexSubImage1D(target, level, x, wd, fmt, type, data);
 
-       if(auto_gen_mipmap==1 && level==0)
+       if(auto_gen_mipmap && level==0)
                generate_mipmap();
 }
 
                generate_mipmap();
 }
 
index 94224147c70434b53bcb8ef9ea78328e9f81284b..daede1836332ca9c2b72a41edf5634a99a09abb1 100644 (file)
@@ -104,7 +104,7 @@ void Texture2D::image(unsigned level, PixelFormat fmt, DataType type, const void
        glTexImage2D(target, level, ifmt, w, h, 0, get_upload_format(fmt), type, data);
 
        allocated |= 1<<level;
        glTexImage2D(target, level, ifmt, w, h, 0, get_upload_format(fmt), type, data);
 
        allocated |= 1<<level;
-       if(auto_gen_mipmap==1 && level==0)
+       if(auto_gen_mipmap && level==0)
        {
                generate_mipmap();
                allocated |= (1<<get_n_levels())-1;
        {
                generate_mipmap();
                allocated |= (1<<get_n_levels())-1;
@@ -125,7 +125,7 @@ void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht
        else
                glTexSubImage2D(target, level, x, y, wd, ht, fmt, type, data);
 
        else
                glTexSubImage2D(target, level, x, y, wd, ht, fmt, type, data);
 
-       if(auto_gen_mipmap==1 && level==0)
+       if(auto_gen_mipmap && level==0)
                generate_mipmap();
 }
 
                generate_mipmap();
 }
 
index 5b33c3c6e1ef9153b68a654586dc37c42b1da7d6..971d3f165393fd00ec631bd3620740111b3bfae5 100644 (file)
@@ -93,7 +93,7 @@ void Texture3D::image(unsigned level, PixelFormat fmt, DataType type, const void
        glTexImage3D(target, level, ifmt, width, height, depth, 0, get_upload_format(fmt), type, data);
 
        allocated |= 1<<level;
        glTexImage3D(target, level, ifmt, width, height, depth, 0, get_upload_format(fmt), type, data);
 
        allocated |= 1<<level;
-       if(auto_gen_mipmap==1 && level==0)
+       if(auto_gen_mipmap && level==0)
        {
                generate_mipmap();
                allocated |= (1<<get_n_levels())-1;
        {
                generate_mipmap();
                allocated |= (1<<get_n_levels())-1;
@@ -114,7 +114,7 @@ void Texture3D::sub_image(unsigned level, int x, int y, int z, unsigned wd, unsi
        else
                glTexSubImage3D(target, level, x, y, z, wd, ht, dp, fmt, type, data);
 
        else
                glTexSubImage3D(target, level, x, y, z, wd, ht, dp, fmt, type, data);
 
-       if(auto_gen_mipmap==1 && level==0)
+       if(auto_gen_mipmap && level==0)
                generate_mipmap();
 }
 
                generate_mipmap();
 }
 
index cd18c10d6909a2c459c4b2409789069900a67b88..da7bb9250c59377267f0453163898c27ccff5801 100644 (file)
@@ -106,7 +106,7 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
 
        // XXX Allocation should be tracked per-face, but we'll run out of bits
        allocated |= 1<<level;
 
        // XXX Allocation should be tracked per-face, but we'll run out of bits
        allocated |= 1<<level;
-       if(auto_gen_mipmap==1 && level==0)
+       if(auto_gen_mipmap && level==0)
        {
                // TODO Only do this once all faces are created
                generate_mipmap();
        {
                // TODO Only do this once all faces are created
                generate_mipmap();
@@ -124,7 +124,7 @@ void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y,
 
        glTexSubImage2D(face, level, x, y, wd, ht, get_upload_format(fmt), type, data);
 
 
        glTexSubImage2D(face, level, x, y, wd, ht, get_upload_format(fmt), type, data);
 
-       if(auto_gen_mipmap==1 && level==0)
+       if(auto_gen_mipmap && level==0)
                generate_mipmap();
 }
 
                generate_mipmap();
 }
 
index 77bb15435c7391a62a0298ea653f6699417eb55f..dff3757fdb6d9b8985234e87241153d94b41a80b 100644 (file)
@@ -7,8 +7,6 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
 namespace Msp {
 namespace GL {
 
-bool Texturing::legacy_used = true;
-
 Texturing::~Texturing()
 {
        if(current()==this)
 Texturing::~Texturing()
 {
        if(current()==this)
@@ -36,7 +34,7 @@ void Texturing::set_attachment(unsigned attch, const Texture *tex)
        attachments[attch] = tex;
 
        if(current()==this)
        attachments[attch] = tex;
 
        if(current()==this)
-               bind_attachment(attch, legacy_used);
+               bind_attachment(attch);
 }
 
 const Texture *Texturing::get_attached_texture(unsigned i) const
 }
 
 const Texture *Texturing::get_attached_texture(unsigned i) const
@@ -44,10 +42,10 @@ const Texture *Texturing::get_attached_texture(unsigned i) const
        return i<attachments.size() ? attachments[i] : 0;
 }
 
        return i<attachments.size() ? attachments[i] : 0;
 }
 
-void Texturing::bind_attachment(unsigned i, bool legacy) const
+void Texturing::bind_attachment(unsigned i) const
 {
        if(const Texture *tex = attachments[i])
 {
        if(const Texture *tex = attachments[i])
-               tex->bind_to(i, legacy);
+               tex->bind_to(i);
        else
                Texture::unbind_from(i);
 }
        else
                Texture::unbind_from(i);
 }
@@ -57,14 +55,13 @@ void Texturing::unbind_attachment(unsigned i)
        Texture::unbind_from(i);
 }
 
        Texture::unbind_from(i);
 }
 
-void Texturing::bind(bool legacy) const
+void Texturing::bind() const
 {
        const Texturing *old = current();
 {
        const Texturing *old = current();
-       if(set_current(this) || legacy!=legacy_used)
+       if(set_current(this))
        {
        {
-               legacy_used = legacy;
                for(unsigned i=0; i<attachments.size(); ++i)
                for(unsigned i=0; i<attachments.size(); ++i)
-                       bind_attachment(i, legacy);
+                       bind_attachment(i);
                if(old)
                {
                        for(unsigned i=attachments.size(); i<old->attachments.size(); ++i)
                if(old)
                {
                        for(unsigned i=attachments.size(); i<old->attachments.size(); ++i)
index 2b409d64fb713ee221a4842110832258bd92f711..0b3a9751b5f98ebe17f6e55a48fe3d4a998b92c1 100644 (file)
@@ -14,8 +14,6 @@ class Texturing: public Bindable<Texturing>
 private:
        std::vector<const Texture *> attachments;
 
 private:
        std::vector<const Texture *> attachments;
 
-       static bool legacy_used;
-
 public:
        ~Texturing();
 
 public:
        ~Texturing();
 
@@ -27,12 +25,12 @@ public:
        const Texture *get_attached_texture(unsigned) const;
 
 private:
        const Texture *get_attached_texture(unsigned) const;
 
 private:
-       void bind_attachment(unsigned, bool) const;
+       void bind_attachment(unsigned) const;
 
        static void unbind_attachment(unsigned);
 
 public:
 
        static void unbind_attachment(unsigned);
 
 public:
-       void bind(bool = true) const;
+       void bind() const;
 
        static void unbind();
 };
 
        static void unbind();
 };
index 9277c27704ebd8347c3c6a782fc1b6ff05fc8658..493a761133eaba7af8bafa85e45a9bf90c0827a2 100644 (file)
@@ -1,7 +1,6 @@
 #include <stdexcept>
 #include <msp/gl/extensions/arb_multitexture.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
 #include <stdexcept>
 #include <msp/gl/extensions/arb_multitexture.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include "gl.h"
 #include "misc.h"
 #include "texunit.h"
 #include "gl.h"
 #include "misc.h"
 #include "texunit.h"
@@ -15,17 +14,13 @@ vector<TexUnit> TexUnit::units;
 TexUnit *TexUnit::cur_unit = 0;
 
 TexUnit::TexUnit():
 TexUnit *TexUnit::cur_unit = 0;
 
 TexUnit::TexUnit():
-       legacy(false),
-       texture(0),
-       tex_legacy(false)
+       texture(0)
 { }
 
 { }
 
-bool TexUnit::set_texture(const Texture *tex, bool lgc)
+bool TexUnit::set_texture(const Texture *tex)
 {
 {
-       lgc = (lgc && legacy && tex);
-       bool result = (tex!=texture || lgc!=tex_legacy);
+       bool result = (tex!=texture);
        texture = tex;
        texture = tex;
-       tex_legacy = lgc;
        return result;
 }
 
        return result;
 }
 
@@ -51,19 +46,6 @@ unsigned TexUnit::get_n_units()
        return count;
 }
 
        return count;
 }
 
-unsigned TexUnit::get_n_legacy_units()
-{
-       static int count = -1;
-       if(count<0)
-       {
-               if(MSP_legacy_features)
-                       count = get_i(GL_MAX_TEXTURE_UNITS);
-               else
-                       count = 0;
-       }
-       return count;
-}
-
 TexUnit &TexUnit::get_unit(unsigned n)
 {
        if(n>0)
 TexUnit &TexUnit::get_unit(unsigned n)
 {
        if(n>0)
@@ -74,13 +56,9 @@ TexUnit &TexUnit::get_unit(unsigned n)
        if(units.size()<=n)
        {
                unsigned i = units.size();
        if(units.size()<=n)
        {
                unsigned i = units.size();
-               unsigned n_legacy = get_n_legacy_units();
                units.resize(n+1, TexUnit());
                for(; i<units.size(); ++i)
                units.resize(n+1, TexUnit());
                for(; i<units.size(); ++i)
-               {
                        units[i].index = i;
                        units[i].index = i;
-                       units[i].legacy = (i<n_legacy);
-               }
        }
 
        return units[n];
        }
 
        return units[n];
index 7cf43a7832b4dc6bb3949685f4f90f09a80c1bbb..f3f95e7e422b2179ffea94f6d9c3834891ea8bc9 100644 (file)
@@ -17,9 +17,7 @@ class TexUnit
 {
 private:
        unsigned index;
 {
 private:
        unsigned index;
-       bool legacy;
        const Texture *texture;
        const Texture *texture;
-       bool tex_legacy;
 
        static std::vector<TexUnit> units;
        static TexUnit *cur_unit;
 
        static std::vector<TexUnit> units;
        static TexUnit *cur_unit;
@@ -28,14 +26,11 @@ private:
 
 public:
        unsigned get_index() const { return index; }
 
 public:
        unsigned get_index() const { return index; }
-       bool supports_legacy() const { return legacy; }
-       bool set_texture(const Texture *, bool = true);
+       bool set_texture(const Texture *);
        const Texture *get_texture() const { return texture; }
        const Texture *get_texture() const { return texture; }
-       bool get_texture_legacy() const { return tex_legacy; }
        void bind();
 
        static unsigned get_n_units();
        void bind();
 
        static unsigned get_n_units();
-       static unsigned get_n_legacy_units();
        static TexUnit &get_unit(unsigned);
        static TexUnit &current();
        static TexUnit *find_unit(const Texture *);
        static TexUnit &get_unit(unsigned);
        static TexUnit &current();
        static TexUnit *find_unit(const Texture *);
index a4dffbb7bae4876af7c9535a1f965e8431b64f7b..9947ac1108a59ef5b5a9a72d9caaa7987ba11782 100644 (file)
@@ -1,6 +1,5 @@
 #include <msp/gl/extensions/arb_multitexture.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
 #include <msp/gl/extensions/arb_multitexture.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
-#include <msp/gl/extensions/msp_legacy_features.h>
 #include "buffer.h"
 #include "error.h"
 #include "gl.h"
 #include "buffer.h"
 #include "error.h"
 #include "gl.h"
@@ -12,8 +11,6 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
 namespace Msp {
 namespace GL {
 
-bool VertexArray::legacy_used = false;
-
 VertexArray::VertexArray(const VertexFormat &f)
 {
        reset(f);
 VertexArray::VertexArray(const VertexFormat &f)
 {
        reset(f);
@@ -32,7 +29,6 @@ void VertexArray::reset(const VertexFormat &f)
        clear();
        format = f;
        stride = get_stride(format);
        clear();
        format = f;
        stride = get_stride(format);
-       legacy = false;
 
        arrays.clear();
 
 
        arrays.clear();
 
@@ -47,9 +43,6 @@ void VertexArray::reset(const VertexFormat &f)
                arr.component = *c;
                arr.offset = offs;
 
                arr.component = *c;
                arr.offset = offs;
 
-               if(*c<ATTRIB1)
-                       legacy = true;
-
                offs += get_component_size(*c);
        }
 }
                offs += get_component_size(*c);
        }
 }
@@ -108,7 +101,7 @@ unsigned VertexArray::get_data_size() const
        return data.size()*sizeof(float);
 }
 
        return data.size()*sizeof(float);
 }
 
-void VertexArray::apply(bool use_legacy) const
+void VertexArray::apply() const
 {
        if(format.empty())
                throw invalid_operation("VertexArray::apply");
 {
        if(format.empty())
                throw invalid_operation("VertexArray::apply");
@@ -116,16 +109,7 @@ void VertexArray::apply(bool use_legacy) const
        if(Mesh::current())
                throw invalid_operation("VertexArray::apply");
 
        if(Mesh::current())
                throw invalid_operation("VertexArray::apply");
 
-       /* Unbind first if the legacy flag changes.  The logic for supporting it
-       directly in apply_arrays would get too complicated, and this also allows
-       rebinding the same array with different legacy setting. */
-       if(legacy_used!=use_legacy)
-               unbind();
-
-       if(!use_legacy)
-               static Require _req(ARB_vertex_shader);
-       else if(legacy)
-               static Require _req(MSP_legacy_features);
+       static Require _req(ARB_vertex_shader);
 
        const VertexArray *old = current();
        /* If the array has been modified, apply it even if it was the last one to
 
        const VertexArray *old = current();
        /* If the array has been modified, apply it even if it was the last one to
@@ -142,12 +126,11 @@ void VertexArray::apply(bool use_legacy) const
 
        const float *base = (vbuf ? reinterpret_cast<float *>(get_offset()) : &data[0]);
        unsigned stride_bytes = stride*sizeof(float);
 
        const float *base = (vbuf ? reinterpret_cast<float *>(get_offset()) : &data[0]);
        unsigned stride_bytes = stride*sizeof(float);
-       apply_arrays(&arrays, (old ? &old->arrays : 0), base, stride_bytes, use_legacy);
+       apply_arrays(&arrays, (old ? &old->arrays : 0), base, stride_bytes);
 }
 
 }
 
-void VertexArray::apply_arrays(const vector<Array> *arrays, const vector<Array> *old_arrays, const float *base, unsigned stride_bytes, bool use_legacy)
+void VertexArray::apply_arrays(const vector<Array> *arrays, const vector<Array> *old_arrays, const float *base, unsigned stride_bytes)
 {
 {
-       unsigned active_tex = 0;
        unsigned n_arrays = arrays ? arrays->size() : 0;
        if(old_arrays)
                n_arrays = max<unsigned>(n_arrays, old_arrays->size());
        unsigned n_arrays = arrays ? arrays->size() : 0;
        if(old_arrays)
                n_arrays = max<unsigned>(n_arrays, old_arrays->size());
@@ -161,56 +144,6 @@ void VertexArray::apply_arrays(const vector<Array> *arrays, const vector<Array>
                unsigned char comp = (arr ? arr->component : old_arr->component);
                unsigned sz = get_component_size(comp);
                unsigned t = get_component_type(comp);
                unsigned char comp = (arr ? arr->component : old_arr->component);
                unsigned sz = get_component_size(comp);
                unsigned t = get_component_type(comp);
-               if(use_legacy)
-               {
-                       GLenum array_type = 0;
-                       if(t==get_component_type(VERTEX3))
-                       {
-                               if(arr)
-                                       glVertexPointer(sz, GL_FLOAT, stride_bytes, base+arr->offset);
-                               array_type = GL_VERTEX_ARRAY;
-                       }
-                       else if(t==get_component_type(NORMAL3))
-                       {
-                               if(arr)
-                                       glNormalPointer(GL_FLOAT, stride_bytes, base+arr->offset);
-                               array_type = GL_NORMAL_ARRAY;
-                       }
-                       else if(t==get_component_type(COLOR4_FLOAT))
-                       {
-                               if(arr)
-                               {
-                                       if(sz==1)
-                                               glColorPointer(4, GL_UNSIGNED_BYTE, stride_bytes, base+arr->offset);
-                                       else
-                                               glColorPointer(sz, GL_FLOAT, stride_bytes, base+arr->offset);
-                               }
-                               array_type = GL_COLOR_ARRAY;
-                       }
-                       else if(comp>=TEXCOORD1 && comp<=TEXCOORD4+12)
-                       {
-                               t -= get_component_type(TEXCOORD1);
-                               if(t>0 || active_tex)
-                               {
-                                       glClientActiveTexture(GL_TEXTURE0+t);
-                                       active_tex = t;
-                               }
-                               if(arr)
-                                       glTexCoordPointer(sz, GL_FLOAT, stride_bytes, base+arr->offset);
-                               array_type = GL_TEXTURE_COORD_ARRAY;
-                       }
-
-                       if(array_type)
-                       {
-                               // Only change enable state if needed
-                               if(arr && !old_arr)
-                                       glEnableClientState(array_type);
-                               else if(old_arr && !arr)
-                                       glDisableClientState(array_type);
-
-                               continue;
-                       }
-               }
 
                if(t>=get_component_type(ATTRIB1))
                        t -= get_component_type(ATTRIB1);
 
                if(t>=get_component_type(ATTRIB1))
                        t -= get_component_type(ATTRIB1);
@@ -228,18 +161,13 @@ void VertexArray::apply_arrays(const vector<Array> *arrays, const vector<Array>
                else if(old_arr && !arr)
                        glDisableVertexAttribArray(t);
        }
                else if(old_arr && !arr)
                        glDisableVertexAttribArray(t);
        }
-
-       if(active_tex)
-               glClientActiveTexture(GL_TEXTURE0);
-
-       legacy_used = use_legacy;
 }
 
 void VertexArray::unbind()
 {
        const VertexArray *old = current();
        if(set_current(0))
 }
 
 void VertexArray::unbind()
 {
        const VertexArray *old = current();
        if(set_current(0))
-               apply_arrays(0, &old->arrays, 0, 0, legacy_used);
+               apply_arrays(0, &old->arrays, 0, 0);
 }
 
 
 }
 
 
index 6e54f681717f4269fb135f66bd18420b5d87943e..efbf8ce27cb2f4ef25c74c5b14c49ce1b2c2dd02 100644 (file)
@@ -18,8 +18,7 @@ namespace GL {
 class Buffer;
 
 /**
 class Buffer;
 
 /**
-Stores vertex data.  Both legacy and generic attributes are supported.  Mixing
-the two is possible but discouraged, as driver-specific issues may arise.
+Stores vertex data.
 
 The array's contents can be modified with the append and modify methods.  To
 obtain the location of an individual component within the vertex, use
 
 The array's contents can be modified with the append and modify methods.  To
 obtain the location of an individual component within the vertex, use
@@ -50,9 +49,6 @@ private:
        std::vector<float> data;
        unsigned stride;
        std::vector<Array> arrays;
        std::vector<float> data;
        unsigned stride;
        std::vector<Array> arrays;
-       bool legacy;
-
-       static bool legacy_used;
 
        VertexArray(const VertexArray &);
        VertexArray &operator=(const VertexArray &);
 
        VertexArray(const VertexArray &);
        VertexArray &operator=(const VertexArray &);
@@ -88,17 +84,14 @@ public:
        const std::vector<float> &get_data() const { return data; }
        const float *operator[](unsigned i) const { return &data[0]+i*stride; }
 
        const std::vector<float> &get_data() const { return data; }
        const float *operator[](unsigned i) const { return &data[0]+i*stride; }
 
-       /** Equivalent to apply(true).  For compatibility with the Bindable
-       interface. */
+       /// Equivalent to apply().  For compatibility with the Bindable interface.
        void bind() const { apply(); }
 
        void bind() const { apply(); }
 
-       /** Applies component arrays to the GL.  If legacy is true, they are applied
-       as is.  If legacy is false, any legacy attributes are converted to generic
-       attributes. */
-       void apply(bool legacy = true) const;
+       /// Applies component arrays to the GL.
+       void apply() const;
 
 private:
 
 private:
-       static void apply_arrays(const std::vector<Array> *, const std::vector<Array> *, const float *, unsigned, bool);
+       static void apply_arrays(const std::vector<Array> *, const std::vector<Array> *, const float *, unsigned);
 public:
        static void unbind();
 };
 public:
        static void unbind();
 };
index 49f0dcf5e38c89d69496bd6473b0027dee63ce8f..55f914a31a24b7400b7efbe9b786d32940fa882c 100644 (file)
@@ -21,8 +21,20 @@ data.  Attributes can be read from protected member variables.
 */
 class VertexBuilder
 {
 */
 class VertexBuilder
 {
+public:
+       class PushMatrix
+       {
+       private:
+               VertexBuilder &bld;
+               Matrix mtx;
+
+       public:
+               PushMatrix(VertexBuilder &b): bld(b), mtx(bld.mtx) { }
+               ~PushMatrix() { bld.mtx = mtx; }
+       };
+
 protected:
 protected:
-       MatrixStack mtx;
+       Matrix mtx;
        Vector3 nor;
        Color col;
        std::map<unsigned, Vector4> texc;
        Vector3 nor;
        Color col;
        std::map<unsigned, Vector4> texc;
@@ -40,10 +52,6 @@ public:
        { mtx *= m; }
 
        const Matrix &get_matrix() const
        { mtx *= m; }
 
        const Matrix &get_matrix() const
-       { return mtx.top(); }
-
-       // Deprecated
-       MatrixStack &matrix()
        { return mtx; }
 
        void vertex(float x, float y)
        { return mtx; }
 
        void vertex(float x, float y)
@@ -59,7 +67,7 @@ public:
        { vertex(Vector4(v.x, v.y, v.z, 1)); }
 
        void vertex(const Vector4 &v)
        { vertex(Vector4(v.x, v.y, v.z, 1)); }
 
        void vertex(const Vector4 &v)
-       { vertex_(mtx.top()*v); }
+       { vertex_(mtx*v); }
 
 protected:
        virtual void vertex_(const Vector4 &) = 0;
 
 protected:
        virtual void vertex_(const Vector4 &) = 0;
@@ -70,7 +78,7 @@ public:
 
        void normal(const Vector3 &n)
        {
 
        void normal(const Vector3 &n)
        {
-               Vector4 tn = mtx.top()*Vector4(n.x, n.y, n.z, 0);
+               Vector4 tn = mtx*Vector4(n.x, n.y, n.z, 0);
                nor = Vector3(tn.x, tn.y, tn.z);
        }
 
                nor = Vector3(tn.x, tn.y, tn.z);
        }
 
@@ -79,7 +87,7 @@ public:
 
        void tangent(const Vector3 &t)
        {
 
        void tangent(const Vector3 &t)
        {
-               Vector4 tt = mtx.top()*Vector4(t.x, t.y, t.z, 0);
+               Vector4 tt = mtx*Vector4(t.x, t.y, t.z, 0);
                attrib(get_component_type(TANGENT3), tt);
        }
 
                attrib(get_component_type(TANGENT3), tt);
        }
 
@@ -88,7 +96,7 @@ public:
 
        void binormal(const Vector3 &b)
        {
 
        void binormal(const Vector3 &b)
        {
-               Vector4 tb = mtx.top()*Vector4(b.x, b.y, b.z, 0);
+               Vector4 tb = mtx*Vector4(b.x, b.y, b.z, 0);
                attrib(get_component_type(BINORMAL3), tb);
        }
 
                attrib(get_component_type(BINORMAL3), tb);
        }
 
index 7edca1f3dcf74782d8fd5a94c7bfb25cd079c72d..bcb5b9251ebc73468237e83f2065f9c6a62187ed 100644 (file)
@@ -6,9 +6,9 @@
 namespace Msp {
 namespace GL {
 
 namespace Msp {
 namespace GL {
 
-/** A single vertex component.  Nvidia drivers have aliasing between the
-fixed-functions and generic vertex attributes, despite the standard not
-allowing it.  We use the same attribute indices here to avoid problems. */
+/** A single vertex component.  Symbolic names are provided for commonly used
+attributes.  These are aliased with with generic attributes, so be careful when
+picking your attribute indices. */
 enum VertexComponent
 {
        VERTEX2 = 1,
 enum VertexComponent
 {
        VERTEX2 = 1,