X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Ftexture1d.cpp;h=df8dd06c75c705e06b31547b0501ea4a86e1c1fb;hp=d472527c92322f4d05b0fe39640f7f91905133a9;hb=3a1b9cbe2441ae670a97541dc8ccb0a2860c8302;hpb=4ae2ffa3057af9524a84ba322c0db32d6fcae8f2 diff --git a/source/core/texture1d.cpp b/source/core/texture1d.cpp index d472527c..df8dd06c 100644 --- a/source/core/texture1d.cpp +++ b/source/core/texture1d.cpp @@ -2,7 +2,6 @@ #include #include #include -#include "bindable.h" #include "error.h" #include "texture1d.h" @@ -48,11 +47,14 @@ void Texture1D::allocate(unsigned level) if(ARB_texture_storage) { - Conditional _bind(!ARB_direct_state_access, this); + GLenum fmt = get_gl_pixelformat(storage_fmt); if(ARB_direct_state_access) - glTextureStorage1D(id, levels, storage_fmt, width); + glTextureStorage1D(id, levels, fmt, width); else - glTexStorage1D(target, levels, storage_fmt, width); + { + bind_scratch(); + glTexStorage1D(target, levels, fmt, width); + } apply_swizzle(); allocated |= (1<=levels) + throw out_of_range("Texture1D::image"); if(ARB_texture_storage) - return sub_image(level, 0, w, data); + return sub_image(level, 0, get_level_size(level), data); - BindRestore _bind(this); + bind_scratch(); if(!allocated) { @@ -78,16 +80,12 @@ void Texture1D::image(unsigned level, const void *data) apply_swizzle(); } - PixelComponents comp = get_components(storage_fmt); + 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)); - glTexImage1D(target, level, storage_fmt, w, 0, comp, type, data); + glTexImage1D(target, level, fmt, get_level_size(level), 0, comp, type, data); allocated |= 1<=levels) + throw out_of_range("Texture1D::sub_image"); - Conditional _bind(!ARB_direct_state_access, this); allocate(level); - PixelComponents comp = get_components(storage_fmt); + GLenum comp = get_gl_components(get_components(storage_fmt)); GLenum type = get_gl_type(get_component_type(storage_fmt)); if(ARB_direct_state_access) glTextureSubImage1D(id, level, x, wd, comp, type, data); else + { + bind_scratch(); glTexSubImage1D(target, level, x, wd, comp, type, data); - - if(auto_gen_mipmap && level==0) - generate_mipmap(); + } } void Texture1D::sub_image(unsigned level, int x, unsigned wd, PixelComponents comp, DataType type, const void *data) @@ -147,7 +146,7 @@ unsigned Texture1D::get_level_size(unsigned level) const return width>>level; } -UInt64 Texture1D::get_data_size() const +uint64_t Texture1D::get_data_size() const { return id ? width*get_pixel_size(storage_fmt) : 0; }