X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexturecube.cpp;h=4984985c807489b28d6f5737c2f2ba03286488d3;hb=9b3bce7ae76ff8c0c81315d2505ea96bf422a318;hp=6ec3662523dea02903e024bb9113b91125e4b711;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index 6ec36625..4984985c 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -49,12 +51,18 @@ TextureCube::TextureCube(): allocated(0) { static Require _req(ARB_texture_cube_map); + if(ARB_seamless_cube_map) + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); } void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv) { if(size>0) - throw invalid_operation("TextureCube::storage"); + { + if(fmt!=format || sz!=size || (lv && lv!=levels)) + throw incompatible_data("TextureCube::storage"); + return; + } if(sz==0) throw invalid_argument("TextureCube::storage"); @@ -74,17 +82,34 @@ void TextureCube::allocate(unsigned level) if(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); + } - BindRestore _bind(this); + glActiveTexture(GL_TEXTURE0); + glBindTexture(target, id); + + 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"); - BindRestore _bind(this); - allocate(level); + bool direct = (ARB_direct_state_access && (ARB_texture_storage || (allocated&(1<