X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ftexture.cc;h=dddc0d1ee5f81a059946b6327b907f75bfdebb42;hb=3aacec4aee795e703e8eb9d6852ca47a3be065ee;hp=5bf291db4f6dac0d8904b36d6c5f2c990f760799;hpb=8137121400748ee8afb1608253aae15323c5e3a2;p=laserbrain_demo diff --git a/src/texture.cc b/src/texture.cc index 5bf291d..dddc0d1 100644 --- a/src/texture.cc +++ b/src/texture.cc @@ -1,4 +1,5 @@ #include +#include #include "texture.h" #include "image.h" #include "opengl.h" @@ -35,6 +36,7 @@ void bind_texture(Texture *tex, int tunit) } else { glActiveTexture(GL_TEXTURE0 + tunit); glBindTexture(cur_target[tunit], 0); + assert(glGetError() == GL_NO_ERROR); glActiveTexture(GL_TEXTURE0); } } @@ -69,6 +71,7 @@ void Texture::set_wrapping(unsigned int wrap) } glBindTexture(target, id); + assert(glGetError() == GL_NO_ERROR); glTexParameteri(target, GL_TEXTURE_WRAP_S, wrap); glTexParameteri(target, GL_TEXTURE_WRAP_T, wrap); glTexParameteri(target, GL_TEXTURE_WRAP_R, wrap); @@ -103,6 +106,7 @@ void Texture::set_filtering(unsigned int filt) void Texture::set_filtering(unsigned int min_filt, unsigned int mag_filt) { glBindTexture(target, id); + assert(glGetError() == GL_NO_ERROR); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, min_filt); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, mag_filt); } @@ -134,6 +138,7 @@ void Texture::bind(int tex_unit) const { glActiveTexture(GL_TEXTURE0 + tex_unit); glBindTexture(target, id); + assert(glGetError() == GL_NO_ERROR); glActiveTexture(GL_TEXTURE0); cur_target[tex_unit] = target; @@ -153,6 +158,7 @@ void Texture::create(int xsz, int ysz, TextureType textype, unsigned int ifmt) target = type_to_target(textype); glBindTexture(target, id); + assert(glGetError() == GL_NO_ERROR); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -191,8 +197,10 @@ void Texture::create_default(TextureType type) pixels[1] = 64; pixels[2] = chess ? 32 : 255; pixels[3] = 255; + pixels += 4; } } + default_img->save("/tmp/foo.png"); } switch(type) { @@ -230,6 +238,7 @@ void Texture::set_image_2d(const Image &img) target = GL_TEXTURE_2D; glBindTexture(target, id); + assert(glGetError() == GL_NO_ERROR); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -266,6 +275,7 @@ bool Texture::set_image_cube(const Image &img, int idx) target = GL_TEXTURE_CUBE_MAP; glBindTexture(target, id); + assert(glGetError() == GL_NO_ERROR); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -459,12 +469,13 @@ TextureSet::TextureSet() Texture *TextureSet::get_texture(const char *name, TextureType type) const { - typename std::map::const_iterator iter = data.find(name); + std::map::const_iterator iter = data.find(name); if(iter != data.end()) { return iter->second; } Texture *res = create(); + data[name] = res; res->create_default(type); resman_lookup(rman, name, res); return res;