X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Ftexturecube.cpp;h=4984985c807489b28d6f5737c2f2ba03286488d3;hp=543bb9d40ec00e954ce894d9699e86c364405dd8;hb=9b3bce7ae76ff8c0c81315d2505ea96bf422a318;hpb=a482029babea3210840d8c62e9df9ece4342b2b9 diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index 543bb9d4..4984985c 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -82,9 +82,23 @@ void TextureCube::allocate(unsigned level) if(allocated&(64< _bind(!ARB_direct_state_access, this); if(ARB_direct_state_access) glTextureStorage2D(id, levels, storage_fmt, size, size); else @@ -95,7 +109,7 @@ void TextureCube::allocate(unsigned level) else { for(unsigned i=0; i<6; ++i) - image(enumerate_faces(i), level, 0); + image_(enumerate_faces(i), level, 0); } } @@ -106,41 +120,50 @@ void TextureCube::image(TextureCubeFace face, unsigned level, const void *data) if(level>=levels) throw out_of_range("TextureCube::image"); - unsigned s = get_level_size(level); - 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<