X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Ftexture.cc;h=ca1a6dbfe30a3f1a9c0c0e33f7a1faf6fe17890a;hp=ff4d1b57c4244825832f31ceb8593bb43dffa12f;hb=6ef619c6d92c698728576a4ec1c798a0f716d9a4;hpb=e6e1e5deb60ccbb4fa175066820d81ad1bf1cefa diff --git a/src/texture.cc b/src/texture.cc index ff4d1b5..ca1a6db 100644 --- a/src/texture.cc +++ b/src/texture.cc @@ -43,6 +43,17 @@ void bind_texture(Texture *tex, int tunit) } } +int next_pow2(int x) +{ + x--; + x = (x >> 1) | x; + x = (x >> 2) | x; + x = (x >> 4) | x; + x = (x >> 8) | x; + x = (x >> 16) | x; + return x + 1; +} + Image *Texture::default_img; @@ -126,6 +137,16 @@ int Texture::get_size(int dim) const return sz[dim]; } +int Texture::get_width() const +{ + return sz[0]; +} + +int Texture::get_height() const +{ + return sz[1]; +} + unsigned int Texture::get_id() const { return id; @@ -164,7 +185,7 @@ void Texture::create(int xsz, int ysz, TextureType textype, unsigned int ifmt) glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - switch(type) { + switch(textype) { case TEX_2D: glTexImage2D(GL_TEXTURE_2D, 0, glifmt_from_ifmt(ifmt), xsz, ysz, 0, fmt, type, 0); break; @@ -495,7 +516,7 @@ Texture *TextureSet::get_texture(const char *name, TextureType type, const DataM Texture *res = create(); data[fname] = res; res->create_default(type); - resman_lookup(rman, fname, res); + resman_add(rman, fname, res); return res; }