-void Texture2D::allocate(unsigned level)
-{
- if(width==0 || height==0)
- throw invalid_operation("Texture2D::allocate");
- if(level>=levels)
- throw invalid_argument("Texture2D::allocate");
-
- bool direct = ARB_texture_storage && ARB_direct_state_access;
- if(!direct)
- {
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(target, id);
- }
-
- allocate_(level);
-
- if(!direct)
- glBindTexture(target, 0);
-}
-
-void Texture2D::allocate_(unsigned level)
-{
- if(allocated&(1<<level))
- return;
-
- if(ARB_texture_storage)
- {
- if(ARB_direct_state_access)
- glTextureStorage2D(id, levels, storage_fmt, width, height);
- else
- glTexStorage2D(target, levels, storage_fmt, width, height);
- apply_swizzle();
- allocated |= (1<<levels)-1;
- }
- else
- image_(level, 0);