Since it's no longer guaranteed that calling ResourceManager::resource_used
will result in Resource::load being called, it's better to avoid the
binding logic entirely in the unloaded case. In particular, parameters
must not be updated until the GL texture object has been created.
Generating an ID for the texture has been delayed to the last phase of
loading to further differentiate the loaded and unloaded states.
void Texture::bind_to(unsigned i) const
{
+ if(!id)
+ {
+ if(manager)
+ manager->resource_used(*this);
+ if(!id)
+ {
+ unbind_from(i);
+ return;
+ }
+ }
+
TexUnit &unit = TexUnit::get_unit(i);
const Texture *cur = unit.get_texture();
if(unit.set_texture(this))
pixel_buffer(PIXEL_UNPACK_BUFFER),
mapped_address(0),
phase(0)
-{
- if(!texture.id)
- glGenTextures(1, &texture.id);
-}
+{ }
bool Texture2D::AsyncLoader::needs_sync() const
{
return false;
}
+ if(!texture.id)
+ glGenTextures(1, &texture.id);
texture.image(image, false, true);
}