From: Mikko Rasa Date: Wed, 15 Oct 2014 16:40:16 +0000 (+0300) Subject: Remove a number of rarely used legacy features X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f1b12c992db974c679d85ae6ec22cd318199d0d5;p=libs%2Fgl.git Remove a number of rarely used legacy features ShadowMap will now need shaders to work, but it was already broken in fixed-function anyway due to using large texture unit numbers. Since all modern hardware supports shaders, even with free drivers, this is unlikely to be an issue. The removed pixel format GL_RED is used in ARB_texture_rg, but we don't support that extension yet. --- diff --git a/Build b/Build index 1aae9864..162e26ca 100644 --- a/Build +++ b/Build @@ -48,12 +48,6 @@ package "mspgl" use "mspgl"; }; - program "texturing" - { - source "demos/texturing.cpp"; - use "mspgl"; - }; - program "cubemap" { source "demos/cubemap.cpp"; diff --git a/demos/texturing.cpp b/demos/texturing.cpp deleted file mode 100644 index 7a1f779d..00000000 --- a/demos/texturing.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Msp; - -int main() -{ - Graphics::SimpleGLWindow wnd(400, 400); - - GL::Texture2D tex1; - GL::Texture2D tex2; - - unsigned char *data = new unsigned char[256*256*4]; - for(unsigned y=0; y<256; ++y) - for(unsigned x=0; x<256; ++x) - { - unsigned i = (x+y*256)*3; - data[i] = 255; - data[i+1] = (((x/32)+(y/32))&1 ? 255 : 0); - data[i+2] = 0; - } - tex1.storage(GL::RGB, 256, 256); - tex1.set_min_filter(GL::LINEAR); - tex1.image(0, GL::RGB, GL::UNSIGNED_BYTE, data); - - for(unsigned y=0; y<256; ++y) - for(unsigned x=0; x<256; ++x) - { - unsigned i = (x+y*256)*4; - data[i] = data[i+1] = data[i+2] = 0; - data[i+3] = (((x/32)+(y/32))&1 ? 255 : 0); - } - tex2.storage(GL::RGBA, 256, 256); - tex2.set_min_filter(GL::LINEAR); - tex2.image(0, GL::RGBA, GL::UNSIGNED_BYTE, data); - delete[] data; - - GL::Texturing texturing; - texturing.attach(0, tex1); - GL::TexEnv texenv; - texenv.set_mode(GL::DECAL); - texturing.attach(1, tex2, texenv); - - GL::MatrixStack::projection() = GL::Matrix::frustum_centered(0.2, 0.2, 0.2, 10); - GL::MatrixStack::modelview() = GL::Matrix::translation(0, 0, -3); - GL::MatrixStack::modelview() *= GL::Matrix::rotation(-45, 1, 0, 0); - - GL::Mesh mesh((GL::TEXCOORD2, GL::TEXCOORD2,1, GL::VERTEX3)); - GL::MeshBuilder bld(mesh); - bld.begin(GL::QUADS); - bld.texcoord(0, 0); - bld.multitexcoord(1, -0.2071, 0.5); - bld.vertex(-1, -1); - bld.texcoord(1, 0); - bld.multitexcoord(1, 0.5, -0.2071); - bld.vertex(1, -1); - bld.texcoord(1, 1); - bld.multitexcoord(1, 1.2071, 0.5); - bld.vertex(1, 1); - bld.texcoord(0, 1); - bld.multitexcoord(1, 0.5, 1.2071); - bld.vertex(-1, 1); - bld.end(); - - wnd.show(); - float angle = 0; - Time::TimeStamp last; - while(1) - { - for(unsigned i=0; i<4; ++i) - { - float *v = mesh.modify_vertex(i); - v[2] = 0.5+sin(angle)*0.1+cos(angle+i*M_PI/2)*0.7071; - v[3] = 0.5+cos(angle)*0.1+sin(angle+i*M_PI/2)*0.7071; - } - wnd.get_display().tick(); - GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT); - { - GL::Bind bind_tex(texturing); - mesh.draw(); - } - wnd.swap_buffers(); - Time::TimeStamp t = Time::now(); - if(last) - angle += 0.5*((t-last)/Time::sec); - last = t; - } - - return 0; -} diff --git a/source/batch.cpp b/source/batch.cpp index 1b0c47bf..e097fd63 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -122,7 +122,7 @@ bool Batch::can_append(PrimitiveType other_type) { if(other_type!=prim_type) return false; - else if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN || prim_type==POLYGON) + else if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN) return NV_primitive_restart; else return true; @@ -132,7 +132,7 @@ void Batch::append(const Batch &other) { if(other.prim_type!=prim_type) throw invalid_argument("Batch::append"); - if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN || prim_type==POLYGON) + if(prim_type==LINE_STRIP || prim_type==LINE_LOOP || prim_type==TRIANGLE_FAN) static Require _req(NV_primitive_restart); if(other.data.empty()) diff --git a/source/clip.cpp b/source/clip.cpp deleted file mode 100644 index 91641777..00000000 --- a/source/clip.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "clip.h" -#include "gl.h" - -namespace Msp { -namespace GL { - -ClipPlane::ClipPlane(double a, double b, double c, double d) -{ - eq[0] = a; - eq[1] = b; - eq[2] = c; - eq[3] = d; -} - -void ClipPlane::apply_to(unsigned n) -{ - glClipPlane(GL_CLIP_PLANE0+n, eq); - glEnable(GL_CLIP_PLANE0+n); -} - -void ClipPlane::disable(unsigned n) -{ - glDisable(GL_CLIP_PLANE0+n); -} - -} // namespace GL -} // namespace Msp diff --git a/source/clip.h b/source/clip.h deleted file mode 100644 index d6589509..00000000 --- a/source/clip.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef MSP_GL_CLIP_H_ -#define MSP_GL_CLIP_H_ - -namespace Msp { -namespace GL { - -class ClipPlane -{ -public: - double eq[4]; - - ClipPlane(double, double, double, double); - void apply_to(unsigned); - - static void disable(unsigned); -}; - -} // namespace GL -} // namespace Msp - -#endif diff --git a/source/datatype.h b/source/datatype.h index e0448c39..76c87bc8 100644 --- a/source/datatype.h +++ b/source/datatype.h @@ -14,8 +14,7 @@ enum DataType UNSIGNED_SHORT = GL_UNSIGNED_SHORT, INT = GL_INT, UNSIGNED_INT = GL_UNSIGNED_INT, - FLOAT = GL_FLOAT, - DOUBLE = GL_DOUBLE + FLOAT = GL_FLOAT }; } // namespace GL diff --git a/source/framebuffer.h b/source/framebuffer.h index f34ecf5c..2e29dbc3 100644 --- a/source/framebuffer.h +++ b/source/framebuffer.h @@ -40,8 +40,7 @@ enum BufferBits { COLOR_BUFFER_BIT = GL_COLOR_BUFFER_BIT, DEPTH_BUFFER_BIT = GL_DEPTH_BUFFER_BIT, - STENCIL_BUFFER_BIT = GL_STENCIL_BUFFER_BIT, - ACCUM_BUFFER_BIT = GL_ACCUM_BUFFER_BIT + STENCIL_BUFFER_BIT = GL_STENCIL_BUFFER_BIT }; enum RWBuffer diff --git a/source/pixelformat.cpp b/source/pixelformat.cpp index ee3cad09..cd3bb2aa 100644 --- a/source/pixelformat.cpp +++ b/source/pixelformat.cpp @@ -10,20 +10,10 @@ namespace GL { void operator>>(const LexicalConverter &conv, PixelFormat &fmt) { - if(conv.get()=="COLOR_INDEX") - fmt = COLOR_INDEX; - else if(conv.get()=="STENCIL_INDEX") + if(conv.get()=="STENCIL_INDEX") fmt = STENCIL_INDEX; else if(conv.get()=="DEPTH_COMPONENT") fmt = DEPTH_COMPONENT; - else if(conv.get()=="RED") - fmt = RED; - else if(conv.get()=="GREEN") - fmt = GREEN; - else if(conv.get()=="BLUE") - fmt = BLUE; - else if(conv.get()=="ALPHA") - fmt = ALPHA; else if(conv.get()=="RGB") fmt = RGB; else if(conv.get()=="RGBA") @@ -52,7 +42,6 @@ PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf) { switch(pf) { - case Graphics::COLOR_INDEX: return COLOR_INDEX; case Graphics::LUMINANCE: return LUMINANCE; case Graphics::LUMINANCE_ALPHA: return LUMINANCE_ALPHA; case Graphics::RGB: return RGB; @@ -125,12 +114,8 @@ unsigned get_component_count(PixelFormat pf) { switch(get_base_pixelformat(pf)) { - case COLOR_INDEX: case STENCIL_INDEX: case DEPTH_COMPONENT: - case RED: - case GREEN: - case BLUE: case LUMINANCE: case SLUMINANCE: return 1; diff --git a/source/pixelformat.h b/source/pixelformat.h index 4da1a151..a0e578a6 100644 --- a/source/pixelformat.h +++ b/source/pixelformat.h @@ -13,13 +13,8 @@ namespace GL { enum PixelFormat { - COLOR_INDEX = GL_COLOR_INDEX, STENCIL_INDEX = GL_STENCIL_INDEX, DEPTH_COMPONENT = GL_DEPTH_COMPONENT, - RED = GL_RED, - GREEN = GL_GREEN, - BLUE = GL_BLUE, - ALPHA = GL_ALPHA, RGB = GL_RGB, RGBA = GL_RGBA, RGB8 = GL_RGB8, diff --git a/source/primitivetype.cpp b/source/primitivetype.cpp index 7b47dfd8..98053660 100644 --- a/source/primitivetype.cpp +++ b/source/primitivetype.cpp @@ -24,8 +24,6 @@ void operator>>(const LexicalConverter &conv, PrimitiveType &pt) pt = QUADS; else if(conv.get()=="QUAD_STRIP") pt = QUAD_STRIP; - else if(conv.get()=="POLYGON") - pt = POLYGON; else throw lexical_error(format("conversion of '%s' to PrimitiveType", conv.get())); } diff --git a/source/primitivetype.h b/source/primitivetype.h index 52a6e875..777558a1 100644 --- a/source/primitivetype.h +++ b/source/primitivetype.h @@ -17,8 +17,7 @@ enum PrimitiveType TRIANGLE_STRIP = GL_TRIANGLE_STRIP, TRIANGLE_FAN = GL_TRIANGLE_FAN, QUADS = GL_QUADS, - QUAD_STRIP = GL_QUAD_STRIP, - POLYGON = GL_POLYGON + QUAD_STRIP = GL_QUAD_STRIP }; void operator>>(const LexicalConverter &, PrimitiveType &); diff --git a/source/programbuilder.cpp b/source/programbuilder.cpp index 1706b9d4..1e8f5577 100644 --- a/source/programbuilder.cpp +++ b/source/programbuilder.cpp @@ -106,8 +106,7 @@ const ProgramBuilder::VariableDefinition ProgramBuilder::standard_variables[] = { FRAGMENT, "tex_sample", "vec4", "texture2D(texture, texture_coord)", 0 }, { VERTEX, "gl_Position", "vec4", "projection_matrix*eye_vertex", 0 }, - { VERTEX, "shd_vertex", "vec3", "vec3(dot(eye_vertex, gl_EyePlaneS[shadow_unit]), dot(eye_vertex, gl_EyePlaneT[shadow_unit]), dot(eye_vertex, gl_EyePlaneR[shadow_unit]))", "g" }, - { VERTEX, "shd_vertex", "vec3", "(shd_eye_matrix*eye_vertex).xyz", "!g" }, + { VERTEX, "shd_vertex", "vec3", "(shd_eye_matrix*eye_vertex).xyz", 0 }, { VERTEX, "tbn_sky_dir", "vec3", "eye_sky_dir*eye_tbn_matrix", "n" }, { VERTEX, "tbn_light_dir[i]", "vec3", "eye_light_dir[i]*eye_tbn_matrix", 0 }, { VERTEX, "eye_light_dir[i]", "vec3", "normalize(eye_light_position[i].xyz-eye_vertex.xyz*eye_light_position[i].w)", 0 }, @@ -128,7 +127,6 @@ const ProgramBuilder::VariableDefinition ProgramBuilder::standard_variables[] = { ATTRIBUTE, "tangent", "vec3", 0, 0 }, { ATTRIBUTE, "binormal", "vec3", 0, 0 }, - { UNIFORM, "ShadowMap::shadow_unit", "int", 0, 0 }, { UNIFORM, "texture", "sampler2D", 0, 0 }, { UNIFORM, "shadow", "sampler2DShadow", 0, 0 }, { UNIFORM, "ShadowMap::shadow_darkness", "float", 0, 0 }, diff --git a/source/renderpass.cpp b/source/renderpass.cpp index 448db60a..45ed6af7 100644 --- a/source/renderpass.cpp +++ b/source/renderpass.cpp @@ -6,7 +6,6 @@ #include "program.h" #include "programdata.h" #include "renderer.h" -#include "texenv.h" #include "texture.h" #include "texture2d.h" #include "texturing.h" @@ -151,22 +150,11 @@ void RenderPass::TextureLoader::finish() { if(tex) { - if(env) - obj.attach(index, *tex, *env); - else - obj.attach(index, *tex); + obj.attach(index, *tex); tex.release(); - env.release(); } } -void RenderPass::TextureLoader::texenv() -{ - throw runtime_error("TexEnvs can't be loaded yet"); - /*env = new TexEnv; - load_sub(*env);*/ -} - void RenderPass::TextureLoader::texture(const string &name) { tex = &get_collection().get(name); diff --git a/source/renderpass.h b/source/renderpass.h index 934a213e..eec60793 100644 --- a/source/renderpass.h +++ b/source/renderpass.h @@ -12,7 +12,6 @@ class Material; class Program; class ProgramData; class Renderer; -class TexEnv; class Texture; class Texturing; @@ -46,14 +45,12 @@ private: private: unsigned index; RefPtr tex; - RefPtr env; public: TextureLoader(Texturing &, unsigned, Collection *); private: virtual void finish(); - void texenv(); void texture(const std::string &); void texture2d(); }; diff --git a/source/shadowmap.cpp b/source/shadowmap.cpp index 7575051e..dd689935 100644 --- a/source/shadowmap.cpp +++ b/source/shadowmap.cpp @@ -8,7 +8,6 @@ #include "scene.h" #include "shadowmap.h" #include "tests.h" -#include "texgen.h" #include "texunit.h" using namespace std; @@ -126,16 +125,8 @@ void ShadowMap::render(Renderer &renderer, const Tag &tag) const unsigned unit = renderer.allocate_effect_texunit(); int iunit = unit; shdata.uniform("shadow", iunit); - shdata.uniform("shadow_unit", iunit); Bind _bind_depth(depth_buf, unit); - TexGen tg_s, tg_t, tg_r; - tg_s.set_plane(Vector4(shadow_matrix(0, 0), shadow_matrix(0, 1), shadow_matrix(0, 2), shadow_matrix(0, 3))); - tg_t.set_plane(Vector4(shadow_matrix(1, 0), shadow_matrix(1, 1), shadow_matrix(1, 2), shadow_matrix(1, 3))); - tg_r.set_plane(Vector4(shadow_matrix(2, 0), shadow_matrix(2, 1), shadow_matrix(2, 2), shadow_matrix(2, 3))); - tg_s.bind_to(unit, SCOORD); - tg_t.bind_to(unit, TCOORD); - tg_r.bind_to(unit, RCOORD); if(const Camera *camera = renderer.get_camera()) /* Multiply by camera's object matrix to form a matrix that transforms @@ -146,10 +137,6 @@ void ShadowMap::render(Renderer &renderer, const Tag &tag) const renderer.add_shader_data(shdata); renderer.render(renderable, tag); - - TexGen::unbind_from(unit, SCOORD); - TexGen::unbind_from(unit, TCOORD); - TexGen::unbind_from(unit, RCOORD); } } // namespace GL diff --git a/source/tests.cpp b/source/tests.cpp index f8489ede..8e24bb52 100644 --- a/source/tests.cpp +++ b/source/tests.cpp @@ -3,32 +3,6 @@ namespace Msp { namespace GL { -AlphaTest::AlphaTest(): - pred(ALWAYS), - ref(0) -{ } - -AlphaTest::AlphaTest(Predicate p, float r): - pred(p), - ref(r) -{ } - -void AlphaTest::bind() const -{ - if(set_current(this)) - { - glEnable(GL_ALPHA_TEST); - glAlphaFunc(pred, ref); - } -} - -void AlphaTest::unbind() -{ - if(set_current(0)) - glDisable(GL_ALPHA_TEST); -} - - DepthTest::DepthTest(): write(true), pred(LESS) diff --git a/source/tests.h b/source/tests.h index 0d7e2384..f7d72950 100644 --- a/source/tests.h +++ b/source/tests.h @@ -8,26 +8,6 @@ namespace Msp { namespace GL { -/** -Tests incoming fragment alpha values against a reference. If the test fails, -the fragment is discarded. -*/ -class AlphaTest: public Bindable -{ -private: - Predicate pred; - float ref; - -public: - AlphaTest(); - AlphaTest(Predicate, float); - - void bind() const; - - static void unbind(); -}; - - /** Tests incoming fragment depth values against the depth buffer. If the test fails, the fragment is discarded. diff --git a/source/texenv.cpp b/source/texenv.cpp deleted file mode 100644 index c8af55f8..00000000 --- a/source/texenv.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "texenv.h" -#include "texunit.h" - -namespace Msp { -namespace GL { - -TexEnv::TexEnv(): - mode(MODULATE), - color(0, 0, 0, 0) -{ } - -TexEnv::~TexEnv() -{ - if(this!=&default_object()) - { - while(TexUnit *unit = TexUnit::find_unit(this)) - unbind_from(unit->get_index()); - } -} - -const TexEnv &TexEnv::default_object() -{ - static TexEnv obj; - return obj; -} - -void TexEnv::update_parameter(int mask) const -{ - if(TexUnit::current().get_texenv()!=this) - { - TexUnit *unit = TexUnit::find_unit(this); - if(!unit) - return; - - unit->bind(); - } - - if(mask&MODE) - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode); - if(mask&COLOR) - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &color.r); -} - -void TexEnv::set_mode(TexEnvMode m) -{ - mode = m; - update_parameter(MODE); -} - -void TexEnv::set_color(const Color &c) -{ - color = c; - update_parameter(COLOR); -} - -void TexEnv::bind_to(unsigned i) const -{ - TexUnit &unit = TexUnit::get_unit(i); - if(unit.set_texenv(this)) - { - unit.bind(); - update_parameter(-1); - } -} - -const TexEnv *TexEnv::current(unsigned i) -{ - return TexUnit::get_unit(i).get_texenv(); -} - -void TexEnv::unbind_from(unsigned i) -{ - default_object().bind_to(i); -} - -} // namespace GL -} // namespace Msp diff --git a/source/texenv.h b/source/texenv.h deleted file mode 100644 index c422331a..00000000 --- a/source/texenv.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef MSP_GL_TEXENV_H_ -#define MSP_GL_TEXENV_H_ - -#include "color.h" -#include "gl.h" - -namespace Msp { -namespace GL { - -enum TexEnvMode -{ - REPLACE = GL_REPLACE, - MODULATE = GL_MODULATE, - DECAL = GL_DECAL, - BLEND = GL_BLEND, - ADD = GL_ADD, - COMBINE = GL_COMBINE -}; - -class TexEnv -{ -private: - enum ParameterMask - { - MODE = 1, - COLOR = 2 - }; - - TexEnvMode mode; - Color color; - -public: - TexEnv(); - ~TexEnv(); - - static const TexEnv &default_object(); - -private: - void update_parameter(int) const; - -public: - void set_mode(TexEnvMode); - void set_color(const Color &); - TexEnvMode get_mode() const { return mode; } - const Color &get_color() const { return color; } - void bind() const { bind_to(0); } - void bind_to(unsigned) const; - - static const TexEnv *current(unsigned = 0); - static void unbind() { unbind_from(0); } - static void unbind_from(unsigned); -}; - -} // namespace GL -} // namespace Msp - -#endif diff --git a/source/texgen.cpp b/source/texgen.cpp deleted file mode 100644 index 4310d19a..00000000 --- a/source/texgen.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include "misc.h" -#include "texgen.h" -#include "texunit.h" - -using namespace std; - -namespace Msp { -namespace GL { - -TexGen::TexGen(): - mode(EYE_LINEAR) -{ } - -TexGen::~TexGen() -{ - // TODO unbind -} - -void TexGen::set_mode(TexGenMode m) -{ - mode = m; -} - -void TexGen::set_plane(const Vector4 &p) -{ - plane = p; -} - -void TexGen::bind_to(unsigned i, TexCoordComponent c) const -{ - TexUnit &unit = TexUnit::get_unit(i); - if(unit.set_texgen(coord_index(c), this)) - { - unit.bind(); - glTexGeni(c, GL_TEXTURE_GEN_MODE, mode); - if(mode==EYE_LINEAR) - glTexGenfv(c, GL_EYE_PLANE, &plane.x); - else if(mode==OBJECT_LINEAR) - glTexGenfv(c, GL_OBJECT_PLANE, &plane.x); - enable(GL_TEXTURE_GEN_S+coord_index(c)); - } -} - -const TexGen *TexGen::current(unsigned i, TexCoordComponent c) -{ - return TexUnit::get_unit(i).get_texgen(coord_index(c)); -} - -void TexGen::unbind_from(unsigned i, TexCoordComponent c) -{ - TexUnit &unit = TexUnit::get_unit(i); - if(unit.set_texgen(coord_index(c), 0)) - { - unit.bind(); - disable(GL_TEXTURE_GEN_S+coord_index(c)); - } -} - -unsigned TexGen::coord_index(TexCoordComponent c) -{ - switch(c) - { - case SCOORD: return 0; - case TCOORD: return 1; - case RCOORD: return 2; - case QCOORD: return 3; - default: throw invalid_argument("TexGen::coord_index"); - } -} - -} // namespace GL -} // namespace Msp diff --git a/source/texgen.h b/source/texgen.h deleted file mode 100644 index 5858efb4..00000000 --- a/source/texgen.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef MSP_GL_TEXGEN_H_ -#define MSP_GL_TEXGEN_H_ - -#include "gl.h" -#include "vector.h" - -namespace Msp { -namespace GL { - -enum TexCoordComponent -{ - SCOORD = GL_S, - TCOORD = GL_T, - RCOORD = GL_R, - QCOORD = GL_Q -}; - -enum TexGenMode -{ - EYE_LINEAR = GL_EYE_LINEAR, - OBJECT_LINEAR = GL_OBJECT_LINEAR, - REFLECTION_MAP = GL_REFLECTION_MAP, - NORMAL_MAP = GL_NORMAL_MAP -}; - -class TexGen -{ -private: - TexGenMode mode; - Vector4 plane; - -public: - TexGen(); - ~TexGen(); - - void set_mode(TexGenMode); - void set_plane(const Vector4 &); - - void bind_to(TexCoordComponent c) const { bind_to(0, c); } - void bind_to(unsigned, TexCoordComponent) const; - - static const TexGen *current(TexCoordComponent c) { return current(0, c); } - static const TexGen *current(unsigned, TexCoordComponent); - static void unbind_from(TexCoordComponent c) { unbind_from(0, c); } - static void unbind_from(unsigned, TexCoordComponent); -private: - static unsigned coord_index(TexCoordComponent); -}; - -} // namespace GL -} // namespace Msp - -#endif diff --git a/source/texturing.cpp b/source/texturing.cpp index 1c8410c5..db8ee653 100644 --- a/source/texturing.cpp +++ b/source/texturing.cpp @@ -1,4 +1,3 @@ -#include "texenv.h" #include "texture.h" #include "texturing.h" #include "texunit.h" @@ -16,20 +15,15 @@ Texturing::~Texturing() void Texturing::attach(unsigned attch, const Texture &tex) { - set_attachment(attch, &tex, 0); -} - -void Texturing::attach(unsigned attch, const Texture &tex, const TexEnv &env) -{ - set_attachment(attch, &tex, &env); + set_attachment(attch, &tex); } void Texturing::detach(unsigned attch) { - set_attachment(attch, 0, 0); + set_attachment(attch, 0); } -void Texturing::set_attachment(unsigned attch, const Texture *tex, const TexEnv *env) +void Texturing::set_attachment(unsigned attch, const Texture *tex) { if(attch>=TexUnit::get_n_units()) throw out_of_range("Texturing::set_attachment"); @@ -38,7 +32,6 @@ void Texturing::set_attachment(unsigned attch, const Texture *tex, const TexEnv attachments.resize(attch+1); attachments[attch].tex = tex; - attachments[attch].env = env; if(current()==this) bind_attachment(attch); @@ -51,16 +44,11 @@ void Texturing::bind_attachment(unsigned i) const attch.tex->bind_to(i); else Texture::unbind_from(i); - if(attch.env) - attch.env->bind_to(i); - else - TexEnv::unbind_from(i); } void Texturing::unbind_attachment(unsigned i) { Texture::unbind_from(i); - TexEnv::unbind_from(i); } void Texturing::bind() const @@ -90,8 +78,7 @@ void Texturing::unbind() Texturing::Attachment::Attachment(): - tex(0), - env(0) + tex(0) { } } // namespace GL diff --git a/source/texturing.h b/source/texturing.h index 51070ffa..daeb2bb8 100644 --- a/source/texturing.h +++ b/source/texturing.h @@ -7,7 +7,6 @@ namespace Msp { namespace GL { -class TexEnv; class Texture; class Texturing: public Bindable @@ -16,7 +15,6 @@ private: struct Attachment { const Texture *tex; - const TexEnv *env; Attachment(); }; @@ -27,10 +25,9 @@ public: ~Texturing(); void attach(unsigned, const Texture &); - void attach(unsigned, const Texture &, const TexEnv &); void detach(unsigned); private: - void set_attachment(unsigned, const Texture *, const TexEnv *); + void set_attachment(unsigned, const Texture *); void bind_attachment(unsigned) const; static void unbind_attachment(unsigned); diff --git a/source/texunit.cpp b/source/texunit.cpp index fd36a4f1..9b905120 100644 --- a/source/texunit.cpp +++ b/source/texunit.cpp @@ -14,11 +14,8 @@ vector TexUnit::units; TexUnit *TexUnit::cur_unit = 0; TexUnit::TexUnit(): - texture(0), - texenv(0) -{ - fill(texgen, texgen+4, static_cast(0)); -} + texture(0) +{ } bool TexUnit::set_texture(const Texture *tex) { @@ -27,29 +24,6 @@ bool TexUnit::set_texture(const Texture *tex) return result; } -bool TexUnit::set_texenv(const TexEnv *env) -{ - bool result = (texenv!=env); - texenv = env; - return result; -} - -bool TexUnit::set_texgen(unsigned i, const TexGen *gen) -{ - if(i>=4) - throw out_of_range("TexUnit::set_texgen"); - bool result = (texgen[i]!=gen); - texgen[i] = gen; - return result; -} - -const TexGen *TexUnit::get_texgen(unsigned i) -{ - if(i>=4) - throw out_of_range("TexUnit::get_texgen"); - return texgen[i]; -} - void TexUnit::bind() { if(cur_unit!=this && (cur_unit || index)) @@ -105,13 +79,5 @@ TexUnit *TexUnit::find_unit(const Texture *tex) return 0; } -TexUnit *TexUnit::find_unit(const TexEnv *env) -{ - for(vector::iterator i=units.begin(); i!=units.end(); ++i) - if(i->texenv==env) - return &*i; - return 0; -} - } // namespace GL } // namespace Msp diff --git a/source/texunit.h b/source/texunit.h index 9c4d93f6..f3f95e7e 100644 --- a/source/texunit.h +++ b/source/texunit.h @@ -18,8 +18,6 @@ class TexUnit private: unsigned index; const Texture *texture; - const TexEnv *texenv; - const TexGen *texgen[4]; static std::vector units; static TexUnit *cur_unit; @@ -30,17 +28,12 @@ public: unsigned get_index() const { return index; } bool set_texture(const Texture *); const Texture *get_texture() const { return texture; } - bool set_texenv(const TexEnv *); - const TexEnv *get_texenv() const { return texenv; } - bool set_texgen(unsigned, const TexGen *); - const TexGen *get_texgen(unsigned); void bind(); static unsigned get_n_units(); static TexUnit &get_unit(unsigned); static TexUnit ¤t(); static TexUnit *find_unit(const Texture *); - static TexUnit *find_unit(const TexEnv *); }; } // namespace GL