void Texture::set_generate_mipmap(bool gm)
{
- if(gm)
+ if(gm && !EXT_framebuffer_object)
static Require _req(SGIS_generate_mipmap);
gen_mipmap = gm;
- if(get_gl_api()!=OPENGL_ES2)
+ if(!EXT_framebuffer_object)
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 is defined here
+ if(EXT_framebuffer_object)
glGenerateMipmap(target);
- }
}
void Texture::set_compare_enabled(bool c)
BindRestore _bind(this);
if(ARB_texture_storage)
- sub_image(level, 0, w, fmt, type, data);
- else
- glTexImage1D(target, level, ifmt, w, 0, fmt, type, data);
+ return sub_image(level, 0, w, fmt, type, data);
+
+ glTexImage1D(target, level, ifmt, w, 0, fmt, type, data);
allocated |= 1<<level;
if(gen_mipmap && level==0)
BindRestore _bind(this);
glTexSubImage1D(target, level, x, wd, fmt, type, data);
+
+ if(gen_mipmap && level==0)
+ auto_generate_mipmap();
}
void Texture1D::image(const Graphics::Image &img, bool srgb)
BindRestore _bind(this);
if(ARB_texture_storage)
- sub_image(level, 0, 0, w, h, fmt, type, data);
- else
- glTexImage2D(target, level, ifmt, w, h, 0, fmt, type, data);
+ return sub_image(level, 0, 0, w, h, fmt, type, data);
+
+ glTexImage2D(target, level, ifmt, w, h, 0, fmt, type, data);
allocated |= 1<<level;
if(gen_mipmap && level==0)
BindRestore _bind(this);
glTexSubImage2D(target, level, x, y, wd, ht, fmt, type, data);
+
+ if(gen_mipmap && level==0)
+ auto_generate_mipmap();
}
void Texture2D::image(const Graphics::Image &img, bool srgb)
BindRestore _bind(this);
if(ARB_texture_storage)
- sub_image(level, 0, 0, 0, w, h, d, fmt, type, data);
- else
- glTexImage3D(target, level, ifmt, width, height, depth, 0, fmt, type, data);
+ return sub_image(level, 0, 0, 0, w, h, d, fmt, type, data);
+
+ glTexImage3D(target, level, ifmt, width, height, depth, 0, fmt, type, data);
allocated |= 1<<level;
if(gen_mipmap && level==0)
BindRestore _bind(this);
glTexSubImage3D(target, level, x, y, z, wd, ht, dp, fmt, type, data);
+
+ if(gen_mipmap && level==0)
+ auto_generate_mipmap();
}
void Texture3D::load_image(const string &fn, int dp)
BindRestore _bind(this);
if(ARB_texture_storage)
- sub_image(face, level, 0, 0, s, s, fmt, type, data);
- else
- glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
+ return sub_image(face, level, 0, 0, s, s, fmt, type, data);
+
+ glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
// XXX Allocation should be tracked per-face, but we'll run out of bits
allocated |= 1<<level;
BindRestore _bind(this);
glTexSubImage2D(face, level, x, y, wd, ht, fmt, type, data);
+
+ if(gen_mipmap && level==0)
+ auto_generate_mipmap();
}
void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool srgb)