X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexturecube.cpp;h=460c109e91879b986129b4ea01ec36a6369c00e2;hb=cf1676a405c2a81413fd565bc83331b7a8778eb5;hp=a2c6c8eb62725c21ce21553cf30926b01fe127e8;hpb=7b569bbfcfb65d8d88b47ac42ee1df6a7d27e784;p=libs%2Fgl.git diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index a2c6c8eb..460c109e 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -45,12 +45,18 @@ unsigned TextureCube::orientations[12] = TextureCube::TextureCube(): Texture(GL_TEXTURE_CUBE_MAP), - size(0), - allocated(0) + size(0) { static Require _req(ARB_texture_cube_map); if(ARB_seamless_cube_map) - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + { + static bool seamless_init = false; + if(!seamless_init) + { + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + seamless_init = true; + } + } } void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv) @@ -69,88 +75,39 @@ void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv) levels = get_n_levels(); if(lv>0) levels = min(levels, lv); -} - -void TextureCube::allocate(unsigned level) -{ - if(size==0) - throw invalid_operation("TextureCube::allocate"); - if(level>=levels) - throw invalid_argument("TextureCube::allocate"); - if(allocated&(64<=levels) - throw out_of_range("TextureCube::image"); - - unsigned lsz = get_level_size(level); - - if(ARB_texture_storage) - return sub_image(face, level, 0, 0, lsz, lsz, data); - - if(!allocated) - { - glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1); - apply_swizzle(); - } - - GLenum fmt = get_gl_pixelformat(storage_fmt); - GLenum comp = get_gl_components(get_components(storage_fmt)); - GLenum type = get_gl_type(get_component_type(storage_fmt)); - glTexImage2D(face, level, fmt, lsz, lsz, 0, comp, type, data); - - if(level==0) - { - allocated |= 1<=levels) throw out_of_range("TextureCube::sub_image"); - allocate(level); - GLenum comp = get_gl_components(get_components(storage_fmt)); GLenum type = get_gl_type(get_component_type(storage_fmt)); if(ARB_direct_state_access) @@ -171,16 +126,6 @@ void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y, bind_scratch(); glTexSubImage2D(face, level, x, y, wd, ht, comp, type, data); } - - if(auto_gen_mipmap && level==0) - generate_mipmap(); -} - -void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y, unsigned wd, unsigned ht, PixelComponents comp, DataType type, const void *data) -{ - if(comp!=get_components(format) || type!=get_component_type(format)) - throw incompatible_data("TextureCube::subimage"); - sub_image(face, level, x, y, wd, ht, data); } void TextureCube::image(TextureCubeFace face, const Graphics::Image &img) @@ -196,11 +141,6 @@ void TextureCube::image(TextureCubeFace face, const Graphics::Image &img) image(face, 0, img.get_pixels()); } -void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool) -{ - image(face, img); -} - void TextureCube::image(const Graphics::Image &img, unsigned lv) { unsigned w = img.get_width(); @@ -280,7 +220,7 @@ Vector3 TextureCube::get_texel_direction(TextureCubeFace face, unsigned u, unsig return fv+s*sv+t*tv; } -UInt64 TextureCube::get_data_size() const +uint64_t TextureCube::get_data_size() const { return id ? size*size*6*get_pixel_size(storage_fmt) : 0; }