#include <msp/fs/utils.h>
+#include <msp/gl/extensions/sgis_generate_mipmap.h>
#include "animation.h"
#include "armature.h"
#include "font.h"
namespace GL {
Resources::Resources():
- default_tex_filter(LINEAR_MIPMAP_LINEAR),
+ default_tex_filter(SGIS_generate_mipmap ? LINEAR_MIPMAP_LINEAR : LINEAR),
srgb_conversion(false),
resource_manager(0)
{
#include <msp/gl/extensions/arb_shadow.h>
+#include <msp/gl/extensions/ext_framebuffer_object.h>
#include <msp/gl/extensions/ext_texture3d.h>
#include <msp/gl/extensions/ext_texture_filter_anisotropic.h>
#include <msp/gl/extensions/sgis_generate_mipmap.h>
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)
when a texture image is uploaded. */
void set_generate_mipmap(bool);
+protected:
+ void auto_generate_mipmap();
+
+public:
/** Sets depth texture comparison. Has no effect on other formats. When
comparison is enabled, the third component of the texture coordinate is
compared against the texel value, and the result is returned as the texture
allocated |= 1<<level;
if(gen_mipmap && level==0)
{
+ auto_generate_mipmap();
for(; w; w>>=1, ++level) ;
allocated |= (1<<level)-1;
}
allocated |= 1<<level;
if(gen_mipmap && level==0)
{
+ auto_generate_mipmap();
for(; (w || h); w>>=1, h>>=1, ++level) ;
allocated |= (1<<level)-1;
}
allocated |= 1<<level;
if(gen_mipmap && level==0)
{
+ auto_generate_mipmap();
for(; (w || h || d); w>>=1, h>>=1, d>>=1, ++level) ;
allocated |= (1<<level)-1;
}
allocated |= 1<<level;
if(gen_mipmap && level==0)
{
+ // TODO Only do this once all faces are created
+ auto_generate_mipmap();
for(; s; s>>=1, ++level) ;
allocated |= (1<<level)-1;
}