X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture.cpp;h=c8a1371c5b0a7724effdeb33ec7f529e70372a47;hb=6afbace895a7bbcf216ab8e48280ea0303ab5892;hp=c2ea8ff7b854c95cf6bee17e5bfd43aed772f710;hpb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8;p=libs%2Fgl.git diff --git a/source/texture.cpp b/source/texture.cpp index c2ea8ff7..c8a1371c 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -1,4 +1,6 @@ -#include "except.h" +#include +#include "error.h" +#include "sgis_generate_mipmap.h" #include "texture.h" #include "texunit.h" @@ -7,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())); } @@ -40,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())); } @@ -128,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); } @@ -146,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) {