From 2508306f82675546be3c98e1eb556bae62ed2ccd Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 1 Feb 2010 20:02:33 +0000 Subject: [PATCH] Add static Texture::unbind_from function Handle generic attributes in PrimitiveBuilder --- source/primitivebuilder.cpp | 4 +++- source/texture.cpp | 6 ++++++ source/texture.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/primitivebuilder.cpp b/source/primitivebuilder.cpp index 6a4d9bf0..95faa3fb 100644 --- a/source/primitivebuilder.cpp +++ b/source/primitivebuilder.cpp @@ -55,9 +55,11 @@ PrimitiveType PrimitiveBuilder::get_type() const void PrimitiveBuilder::vertex_(float x, float y, float z, float w) { - vab.texcoord(ts, tt, tr,tq); + vab.texcoord(ts, tt, tr, tq); vab.color(cr, cg, cb, ca); vab.normal(nx, ny, nz); + for(std::map::iterator i=av.begin(); i!=av.end(); ++i) + vab.attrib(i->first, i->second.x, i->second.y, i->second.z, i->second.w); vab.vertex(x, y, z, w); if(in_batch) diff --git a/source/texture.cpp b/source/texture.cpp index d71f38c2..47b6ba37 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -91,6 +91,12 @@ void Texture::unbind() TexUnit::current().set_texture(0); } +void Texture::unbind_from(unsigned i) +{ + TexUnit::activate(i); + unbind(); +} + Texture::Texture(): target(0) { diff --git a/source/texture.h b/source/texture.h index 61b1bebd..48f551f0 100644 --- a/source/texture.h +++ b/source/texture.h @@ -62,6 +62,7 @@ public: uint get_id() const { return id; } static void unbind(); + static void unbind_from(unsigned); protected: uint id; GLenum target; -- 2.45.2