X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexturecube.cpp;h=2db1b63b92162c358618c7c3d7a6a0831ce3cb5e;hb=e92de029768eef5f0fd744329e589161b46d0762;hp=93faa3703ab993ee29e05710347c56be82c3bca2;hpb=aff68a183a4b33653750acc57a021fd7ed6c555c;p=libs%2Fgl.git diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index 93faa370..2db1b63b 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -5,9 +5,7 @@ #include #include #include -#include "bindable.h" #include "error.h" -#include "pixelstore.h" #include "texturecube.h" using namespace std; @@ -79,23 +77,39 @@ void TextureCube::allocate(unsigned level) throw invalid_operation("TextureCube::allocate"); if(level>=levels) throw invalid_argument("TextureCube::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 TextureCube::allocate_(unsigned level) +{ if(allocated&(64< _bind(!ARB_direct_state_access, this); + GLenum fmt = get_gl_pixelformat(storage_fmt); if(ARB_direct_state_access) - glTextureStorage2D(id, levels, storage_fmt, size, size); + glTextureStorage2D(id, levels, fmt, size, size); else - glTexStorage2D(target, levels, storage_fmt, size, size); + glTexStorage2D(target, levels, fmt, size, size); apply_swizzle(); allocated |= (64<=levels) throw out_of_range("TextureCube::image"); if(ARB_texture_storage) - return sub_image(face, level, 0, 0, s, s, data); + { + unsigned lsz = get_level_size(level); + return sub_image(face, level, 0, 0, lsz, lsz, data); + } + + glActiveTexture(GL_TEXTURE0); + glBindTexture(target, id); - BindRestore _bind(this); + image_(face, level, data); + if(auto_gen_mipmap && level==0 && (allocated&63)==63) + { + generate_mipmap_(); + allocated |= (64<=levels) + throw out_of_range("TextureCube::sub_image"); - Conditional _bind(!ARB_direct_state_acess, this); - allocate(level); + bool direct = (ARB_direct_state_access && (ARB_texture_storage || (allocated&(1<(img.get_pixels()); unsigned face_size = img.get_stride()*size; for(unsigned i=0; i<6; ++i)