X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture.cpp;h=c8a1371c5b0a7724effdeb33ec7f529e70372a47;hb=6afbace895a7bbcf216ab8e48280ea0303ab5892;hp=f4e7d705d142332652396160bb144009aa6c0364;hpb=10b5a32fef9f63254a54378a879142793975efe0;p=libs%2Fgl.git diff --git a/source/texture.cpp b/source/texture.cpp index f4e7d705..c8a1371c 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -1,11 +1,6 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include "except.h" +#include +#include "error.h" +#include "sgis_generate_mipmap.h" #include "texture.h" #include "texunit.h" @@ -14,27 +9,22 @@ using namespace std; namespace Msp { namespace GL { -istream &operator>>(istream &in, TextureFilter &tf) +void operator>>(const LexicalConverter &c, TextureFilter &tf) { - string str; - in>>str; - - if(str=="NEAREST") + if(c.get()=="NEAREST") tf = NEAREST; - else if(str=="LINEAR") + else if(c.get()=="LINEAR") tf = LINEAR; - else if(str=="NEAREST_MIPMAP_NEAREST") + else if(c.get()=="NEAREST_MIPMAP_NEAREST") tf = NEAREST_MIPMAP_NEAREST; - else if(str=="NEAREST_MIPMAP_LINEAR") + else if(c.get()=="NEAREST_MIPMAP_LINEAR") tf = NEAREST_MIPMAP_LINEAR; - else if(str=="LINEAR_MIPMAP_NEAREST") + else if(c.get()=="LINEAR_MIPMAP_NEAREST") tf = LINEAR_MIPMAP_NEAREST; - else if(str=="LINEAR_MIPMAP_LINEAR") + else if(c.get()=="LINEAR_MIPMAP_LINEAR") tf = LINEAR_MIPMAP_LINEAR; else - in.setstate(ios_base::failbit); - - return in; + throw lexical_error(format("conversion of '%s' to TextureFilter", c.get())); } @@ -47,7 +37,7 @@ void operator>>(const LexicalConverter &c, TextureWrap &tw) else if(c.get()=="MIRRORED_REPEAT") tw = MIRRORED_REPEAT; else - throw LexicalError("Invalid input in TextureWrap conversion"); + throw lexical_error(format("conversion of '%s' to TextureWrap", c.get())); } @@ -135,6 +125,8 @@ void Texture::set_wrap_r(TextureWrap w) void Texture::set_generate_mipmap(bool gm) { + if(gm) + static Require _req(SGIS_generate_mipmap); gen_mipmap = gm; update_parameter(GENERATE_MIPMAP); } @@ -153,9 +145,6 @@ void Texture::set_compare_func(Predicate f) void Texture::bind() const { - if(!target) - throw InvalidState("Attempt to bind a texture without target (should never happen)"); - const Texture *cur = TexUnit::current().get_texture(); if(cur!=this) {