X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexturecube.cpp;h=93faa3703ab993ee29e05710347c56be82c3bca2;hb=aff68a183a4b33653750acc57a021fd7ed6c555c;hp=d006e383cc998af09fa478b18bb8bc4ce047ecfc;hpb=efb45a6851563cdb8077b6aad3ab92d4006d8790;p=libs%2Fgl.git diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index d006e383..93faa370 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"); @@ -76,10 +84,13 @@ void TextureCube::allocate(unsigned level) if(ARB_texture_storage) { - BindRestore _bind(this); - glTexStorage2D(target, levels, storage_fmt, size, size); + Conditional _bind(!ARB_direct_state_access, this); + if(ARB_direct_state_access) + glTextureStorage2D(id, levels, storage_fmt, size, size); + else + glTexStorage2D(target, levels, storage_fmt, size, size); apply_swizzle(); - allocated |= (1< _bind(!ARB_direct_state_acess, this); allocate(level); PixelComponents comp = get_components(storage_fmt); GLenum type = get_gl_type(get_component_type(storage_fmt)); - glTexSubImage2D(face, level, x, y, wd, ht, comp, type, data); + if(ARB_direct_state_access) + glTextureSubImage3D(id, level, x, y, get_face_index(face), wd, ht, 1, comp, type, data); + else + glTexSubImage2D(face, level, x, y, wd, ht, comp, type, data); if(auto_gen_mipmap && level==0) generate_mipmap(); @@ -169,17 +183,12 @@ void TextureCube::image(TextureCubeFace face, const Graphics::Image &img) { unsigned w = img.get_width(); unsigned h = img.get_height(); - PixelFormat fmt = pixelformat_from_image(img); - if(size==0) - { - if(w!=h) - throw incompatible_data("TextureCube::image"); - - storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w); - } - else if(w!=size || h!=size) + if(w!=h) throw incompatible_data("TextureCube::image"); + PixelFormat fmt = pixelformat_from_image(img); + storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w); + PixelStore pstore = PixelStore::from_image(img); BindRestore _bind_ps(pstore);