X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexturing.cpp;h=dff3757fdb6d9b8985234e87241153d94b41a80b;hp=69c2b3ca55cdae1ff6df19a9227b7d4ddbfa24bf;hb=975162f86071985913b59a835d38046e1c271594;hpb=abc16c5ab0fff0945d724febe9d5d3889fb8a6ce diff --git a/source/texturing.cpp b/source/texturing.cpp index 69c2b3ca..dff3757f 100644 --- a/source/texturing.cpp +++ b/source/texturing.cpp @@ -1,15 +1,9 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include "texenv.h" #include "texture.h" #include "texturing.h" #include "texunit.h" +using namespace std; + namespace Msp { namespace GL { @@ -21,53 +15,44 @@ 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 InvalidParameterValue("Invalid texture attachment"); + throw out_of_range("Texturing::set_attachment"); if(attachments.size()<=attch) attachments.resize(attch+1); - attachments[attch].tex = tex; - attachments[attch].env = env; + attachments[attch] = tex; if(current()==this) bind_attachment(attch); } +const Texture *Texturing::get_attached_texture(unsigned i) const +{ + return ibind(); + if(const Texture *tex = attachments[i]) + tex->bind_to(i); else - Texture::unbind(); - if(attch.env) - attch.env->bind(); - else - TexEnv::unbind(); + Texture::unbind_from(i); } void Texturing::unbind_attachment(unsigned i) { - TexUnit::activate(i); - Texture::unbind(); - TexEnv::unbind(); + Texture::unbind_from(i); } void Texturing::bind() const @@ -95,11 +80,5 @@ void Texturing::unbind() } } - -Texturing::Attachment::Attachment(): - tex(0), - env(0) -{ } - } // namespace GL } // namespace Msp;