X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture.cpp;h=8d43143c9d734c218211d070890bf4cd080b42ed;hb=661073576254a203fa497fb4c2f550dc269cd5de;hp=81373c97b8793bb99f66c5669e6bc7f761c5d7d9;hpb=e1672476c5a258ff67fe1fcb47dd9a40b89169cb;p=libs%2Fgl.git diff --git a/source/texture.cpp b/source/texture.cpp index 81373c97..8d43143c 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -74,6 +75,11 @@ Texture::~Texture() glDeleteTextures(1, &id); } +DataType Texture::get_alloc_type(PixelFormat fmt) +{ + return (fmt==DEPTH_COMPONENT ? UNSIGNED_SHORT : UNSIGNED_BYTE); +} + void Texture::update_parameter(int mask) const { if(TexUnit::current().get_texture()!=this) @@ -168,12 +174,24 @@ void Texture::set_generate_mipmap(bool gm) if(gm) static Require _req(SGIS_generate_mipmap); gen_mipmap = gm; - update_parameter(GENERATE_MIPMAP); + if(get_gl_api()!=OPENGL_ES2) + update_parameter(GENERATE_MIPMAP); +} + +void Texture::auto_generate_mipmap() +{ + if(get_gl_api()==OPENGL_ES2) + { + // glGenerateMipmap is defined here + static Require _req(EXT_framebuffer_object); + glGenerateMipmap(target); + } } void Texture::set_compare_enabled(bool c) { - static Require _req(ARB_shadow); + if(c) + static Require _req(ARB_shadow); compare = c; update_parameter(COMPARE); }