X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexturecube.cpp;h=5c7f61029c3c736eb3245e99b559b29c7e79f2aa;hb=a92362ad19b65f66b98e0dc4d034da5e4eb5cf36;hp=93faa3703ab993ee29e05710347c56be82c3bca2;hpb=aff68a183a4b33653750acc57a021fd7ed6c555c;p=libs%2Fgl.git diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index 93faa370..5c7f6102 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -7,7 +7,6 @@ #include #include "bindable.h" #include "error.h" -#include "pixelstore.h" #include "texturecube.h" using namespace std; @@ -82,9 +81,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 +108,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); } } @@ -103,44 +116,53 @@ void TextureCube::image(TextureCubeFace face, unsigned level, const void *data) { if(size==0) throw invalid_operation("TextureCube::image"); - - unsigned s = get_level_size(level); - if(s==0) + if(level>=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); + + image_(face, level, data); - BindRestore _bind(this); + 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)