-#include "except.h"
+#include <msp/strings/format.h>
+#include "error.h"
+#include "extension.h"
#include "texture.h"
#include "texunit.h"
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()));
}
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()));
}
void Texture::set_generate_mipmap(bool gm)
{
+ if(gm)
+ static RequireExtension _ext("GL_SGIS_generate_mipmap");
gen_mipmap = gm;
update_parameter(GENERATE_MIPMAP);
}
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)
{